API Reference
Messages
POST /v1/messages: Anthropic-compatible requests, through routers or a Claude Proxy.
POST /v1/messages accepts requests in the Anthropic Messages format, so Anthropic SDKs and tools work with Multi-Router by changing their base URL to https://api.multi-router.ai. It needs the inference scope, accepts bodies up to 32 MB, accepts the key in x-api-key as well as Authorization, and returns errors in the Anthropic format.
Routing
A Messages request is served in one of two ways:
| Request | Served by |
|---|---|
A router or alias in the model field | That router, as on Chat Completions. |
x-mr-router names a Claude Proxy | The Claude Proxy, which serves the request on its route with the route's model id and key. |
x-mr-router names an Adaptive Router | The Adaptive Router, which plans it with its rules. See Adaptive Router. |
| Otherwise | The router named in x-mr-router, or the model in the model field. |
Request body
The body takes the Anthropic Messages fields:
| Field | Type |
|---|---|
model | string, required |
| A router, alias, or model, as on Chat Completions. | |
messages | array, required |
| The conversation, with text, image and tool content blocks. | |
max_tokens | integer, required |
| The most tokens to generate. | |
system | string or array |
| The system prompt, as text or content blocks with cache control. | |
stream | boolean |
| Streams the reply as server-sent events. | |
temperature | number |
| Sampling temperature. | |
top_p | number |
| Nucleus sampling. | |
top_k | integer |
| Top-k sampling. | |
stop_sequences | array |
| Stop sequences. | |
tools | array |
| Tools with an input schema. | |
tool_choice | object |
| auto, any, a named tool, or none. | |
thinking | object |
| Extended thinking, with a token budget. | |
metadata.user_id | string |
| The caller's end user, recorded in Traffic as the customer id. | |
prompt_variables | object |
| Values for the router's bound prompt variables. | |
Example
A request to a router and its response, which echoes the request's model field:
Errors
Errors use the Anthropic format, with a type that follows the status: 400 invalid_request_error, 401 authentication_error, 403 permission_error, 404 not_found_error, 413 request_too_large, 429 rate_limit_error, 503 overloaded_error, and api_error for other statuses. The message carries the detail.