Skip to content
Rapid Router
API reference · Inference

Anthropic Messages

POST /messages in the native Anthropic format, so Anthropic SDKs work with a base URL change.

POST /api/v1/messages speaks the native Anthropic Messages API: content blocks, a top-level system, tools with input_schema, tool_choice, thinking budgets, stop_sequences and a required max_tokens. Auth is your normal Rapid Router key, as a bearer token or in x-api-key, which is where Anthropic's SDKs put it. The request runs through the same routing, failover and billing as chat completions, and the answer comes back in the Anthropic shape, streaming included, whichever provider actually served it, so a client built on Anthropic's SDK works by changing the base URL and key. The reply's usage.cost and provider say what was billed and who served it; on a stream they ride the final message_delta.

In an Anthropic SDK the base URL is https://rapidrouter.ai/api, without /v1: the SDK adds /v1/messages itself, so the usual base URL would send it to /api/v1/v1/messages and a 404.

Provider routing preferences pass through the same provider object as chat completions, and :free works here too. Validation errors from this endpoint use Anthropic's error envelope; errors from deeper in the pipeline keep the gateway's usual shape.

curl
curl https://rapidrouter.ai/api/v1/messages \
  -H "Authorization: Bearer $RAPIDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "max_tokens": 256,
    "messages": [{ "role": "user", "content": "Hi" }]
  }'