Protocol · OpenAI-compatible

Connect your OpenAI client to RouterLab.

Keep the OpenAI request shape. Only the base URL, API key and model identifier change.

Request contractready
Base URL
https://api.routerlab.ch/v1
Endpoint
POST /v1/chat/completions
Authentication
Authorization: Bearer $ROUTERLAB_API_KEY
Model IDs
GET /v1/models

Get started in four steps

OpenAI compatibility lets you reuse SDKs and tools that accept a custom base URL.

  1. 01

    Create a key

    Generate a key in the RouterLab dashboard and keep it server-side.

  2. 02

    List models

    Call GET /v1/models to retrieve model identifiers that are actually available.

  3. 03

    Change the base URL

    Configure your client to use https://api.routerlab.ch/v1.

  4. 04

    Send the request

    Use the exact model identifier and the usual chat/completions format.

Examples ready to adapt

The same contract works over direct HTTP or with the OpenAI SDK.

cURL
shell
curl https://api.routerlab.ch/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Python · OpenAI SDK
python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ROUTERLAB_API_KEY"],
    base_url="https://api.routerlab.ch/v1",
)

response = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
TypeScript · OpenAI SDK
typescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ROUTERLAB_API_KEY,
  baseURL: "https://api.routerlab.ch/v1",
});

const response = await client.chat.completions.create({
  model: "deepseek-v4-flash",
  messages: [{ role: "user", content: "Hello" }],
});

What compatibility guarantees

RouterLab normalizes access, but capabilities still depend on the selected model.

Same request shape

Messages, roles, streaming and tools follow the OpenAI contract when the route supports them.

RouterLab identifiers

The model field must contain an identifier returned by GET /v1/models.

Per-model capabilities

Vision, tools, context and structured output are shown in the catalog.

Interchangeable families

You can change model families without changing SDK when the same route is available.

DeepSeek and GLM are not new APIs

They are model families. Keep this integration and only change the model field. Always check route badges in the catalog.

Common errors

Start by checking the key, model identifier and balance.

HTTPLikely causeAction
400Invalid body or unsupported parameter.Compare the request with the chat/completions contract and model capabilities.
401Missing, invalid or revoked key.Check the Authorization header and regenerate the key if needed.
404Unknown model identifier.Read the list returned by GET /v1/models again.
429Rate or available-credit limit reached.Reduce request rate, then review limits in the dashboard.
503Route temporarily unavailable.Retry with backoff or select another compatible model.

Does your tool use Claude Messages?

Use RouterLab’s second documented protocol instead of artificially adapting requests.

Read the Claude Messages guide