Skip to main content
Everything else in a request, such as tools, stream or max_tokens, works as in the OpenAI and Anthropic APIs.

Cost and quality per call

For a finer dial than target, send routing.cost_quality_tradeoff, from 0 (best quality) to 10 (cheapest). It applies to that call only:

Conversations

A request that continues an earlier conversation stays on that conversation’s model, so the model’s prompt cache keeps working. To group requests yourself, send the same X-Routing-Conversation-Id header (up to 256 characters) on each of them.

Fallbacks

With "auto", a request that fails before the model starts answering is retried on the router’s next choice. The X-Routing-Rank response header is 1 for the first choice and 2 for the fallback.

Images

Requests that contain images go only to models that accept images. A named model that doesn’t accept them returns 400 with code: "unsupported_modality".

Long prompts

"auto" leaves out models whose context can’t hold the request. When no model can, the answer is 400 with code: "context_length_exceeded".

Count tokens

POST /v1/messages/count_tokens takes an Anthropic Messages body and returns an estimate of its input tokens:
Error bodies are in Errors.