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":"glm-5.3-flash-trial","max_tokens":128,"messages":[{"role":"user","content":"Hello RouterLab"}]}'

Python · OpenAI SDK python

import os
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="glm-5.3-flash-trial",
    max_tokens=128,
    messages=[{"role": "user", "content": "Hello RouterLab"}],
)
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: "glm-5.3-flash-trial",
  messages: [{ role: "user", content: "Hello" }],
});

From your first call to your application

Start with a short request, check its response and usage, then add only the features published for the selected model.

Choose an accessible model

GET /v1/models with your RouterLab key lists the IDs available to your account. A public model page does not guarantee access on your plan. The trial is limited to models marked Trial.

Keep the protocol consistent

Use /v1 as the SDK base URL and an exact ID from /v1/models. This guide covers chat/completions; it does not imply support for every other SDK endpoint or parameter.

Tools and structured outputs

Check the model badges before adding tools or an output format. Your application executes tools and validates returned data. Support depends on the model and route.

Check completion and budget

Streaming requires the Streaming badge. An interrupted connection does not prove the call completed. On 429, distinguish a rate limit from an exhausted budget; do not automatically repeat a generation that already returned partial output.

Stream with the example model python

import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["ROUTERLAB_API_KEY"], base_url="https://api.routerlab.ch/v1")
stream = client.chat.completions.create(
    model="glm-5.3-flash-trial",
    max_tokens=128,
    messages=[{"role": "user", "content": "Hello RouterLab"}],
    stream=True,
)
for part in stream:
    if part.choices and part.choices[0].delta.content:
        print(part.choices[0].delta.content, end="", flush=True)

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

Audience measurement

Allow Google Analytics and RouterLab to measure public visits and link campaign sources to your signup? This is optional and can be changed at any time. If you decline, only anonymous visit totals are kept.