Skip to content

API Usage

In addition to CLI tools, you can call RouterBus APIs directly via HTTP requests.

API Information

  • OpenAI-compatible endpoint: https://www.routerbus.com/v1
  • Claude native endpoint: https://www.routerbus.com
  • Gemini native endpoint: https://www.routerbus.com/v1beta
  • Authentication: Bearer token (x-api-key for the Claude native format, x-goog-api-key for the Gemini native one)

The model IDs in the examples below are just examples — the IDs that actually work are the ones in Model Square.

Chat Completions

Request Example

bash
curl https://www.routerbus.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Streaming

bash
curl https://www.routerbus.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ],
    "stream": true
  }'

Python SDK

Using the OpenAI Python SDK:

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    base_url="https://www.routerbus.com/v1"
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

Node.js SDK

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  baseURL: 'https://www.routerbus.com/v1',
});

const response = await client.chat.completions.create({
  model: 'claude-sonnet-4-6',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);

Claude Native API Format

To use Claude's native Messages API format:

bash
curl https://www.routerbus.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Gemini native format

bash
curl "https://www.routerbus.com/v1beta/models/MODEL_ID:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -d '{
    "contents": [
      {"parts": [{"text": "Hello!"}]}
    ]
  }'

Replace MODEL_ID with a Gemini model ID from Model Square.

TIP

Prefer the OpenAI-compatible format: nearly every model is open on it, so switching models means changing one string rather than your code. Each model's detail page in Model Square says which endpoints it accepts.

RouterBus API Documentation