Protocol · Claude Messages

Send requests in the Claude Messages format.

This route is for clients that natively produce the Messages contract. It does not mean every catalog model is a Claude model.

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

Get started in four steps

Use this route only for models whose catalog entry carries the Claude Messages badge.

  1. 01

    Create a key

    Generate a RouterLab key and keep it in a server-side environment variable.

  2. 02

    Check the route

    In the catalog, choose a model explicitly compatible with Claude Messages.

  3. 03

    Build the message

    Send model, max_tokens and messages using the Messages format.

  4. 04

    Handle the response

    Read the content blocks and usage information returned by the route.

Examples ready to adapt

These examples use the RouterLab contract currently exposed at /v1/messages.

cURL
shell
curl https://api.routerlab.ch/v1/messages \
  -H "Authorization: Bearer $ROUTERLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
TypeScript · fetch
typescript
const response = await fetch("https://api.routerlab.ch/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ROUTERLAB_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    max_tokens: 512,
    messages: [{ role: "user", content: "Hello" }],
  }),
});

const data = await response.json();
Python · requests
python
import os
import requests

response = requests.post(
    "https://api.routerlab.ch/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['ROUTERLAB_API_KEY']}"},
    json={
        "model": "claude-sonnet-4-5",
        "max_tokens": 512,
        "messages": [{"role": "user", "content": "Hello"}],
    },
)
response.raise_for_status()
print(response.json())

What this route represents

Claude Messages is an exchange format. The model remains a separate choice controlled by its identifier and capabilities.

Messages format

The request uses messages, max_tokens and the content blocks expected by this protocol.

Declared route

Only use models showing the Claude Messages badge in the catalog.

Variable capabilities

Tools, vision, context and reasoning depend on the selected model.

Another protocol is available

If your SDK expects chat/completions, use the OpenAI-compatible guide.

Claude Code uses ScioNos

For the Claude Code tool, use the ScioNos wrapper: it configures the terminal and authentication. This page documents the direct HTTP API.

Common errors

First check the Messages format and the model route compatibility.

HTTPLikely causeAction
400A required field is missing or content is malformed.Check model, max_tokens and messages in particular.
401Missing, invalid or revoked key.Check the Bearer value sent in Authorization.
404Unknown or unavailable model.Choose an identifier exposed by GET /v1/models.
429Rate or credit limit reached.Reduce request rate and review the RouterLab account.
503Route temporarily unavailable.Retry with backoff or select another compatible route.

Need Claude Code or Codex CLI?

ScioNos is the dedicated integration for terminal coding agents. It avoids rebuilding their configuration by hand.

Configure agents with ScioNos