Same request shape
Messages, roles, streaming and tools follow the OpenAI contract when the route supports them.
Protocol · OpenAI-compatible
Keep the OpenAI request shape. Only the base URL, API key and model identifier change.
OpenAI compatibility lets you reuse SDKs and tools that accept a custom base URL.
Generate a key in the RouterLab dashboard and keep it server-side.
Call GET /v1/models to retrieve model identifiers that are actually available.
Configure your client to use https://api.routerlab.ch/v1.
Use the exact model identifier and the usual chat/completions format.
The same contract works over direct HTTP or with the OpenAI SDK.
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"}]
}'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)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" }],
});RouterLab normalizes access, but capabilities still depend on the selected model.
Messages, roles, streaming and tools follow the OpenAI contract when the route supports them.
The model field must contain an identifier returned by GET /v1/models.
Vision, tools, context and structured output are shown in the catalog.
You can change model families without changing SDK when the same route is available.
They are model families. Keep this integration and only change the model field. Always check route badges in the catalog.
Start by checking the key, model identifier and balance.
| HTTP | Likely cause | Action |
|---|---|---|
| 400 | Invalid body or unsupported parameter. | Compare the request with the chat/completions contract and model capabilities. |
| 401 | Missing, invalid or revoked key. | Check the Authorization header and regenerate the key if needed. |
| 404 | Unknown model identifier. | Read the list returned by GET /v1/models again. |
| 429 | Rate or available-credit limit reached. | Reduce request rate, then review limits in the dashboard. |
| 503 | Route temporarily unavailable. | Retry with backoff or select another compatible model. |
Use RouterLab’s second documented protocol instead of artificially adapting requests.
Read the Claude Messages guide