Messages
Anthropic’s own Messages format, for the Claude models. A request written for Anthropic’s API is passed to the model as you send it, so the format works here as Anthropic documents it.
POST https://api.exoticrouter.com/v1/messages
A request
Section titled “A request”curl https://api.exoticrouter.com/v1/messages \ -H "x-api-key: $EXOTIC_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-5-5", "max_tokens": 400, "messages": [{"role": "user", "content": "Why is the sky blue?"}] }'import osfrom anthropic import Anthropic
client = Anthropic( base_url="https://api.exoticrouter.com", api_key=os.environ["EXOTIC_API_KEY"],)
message = client.messages.create( model="anthropic/claude-sonnet-5-5", max_tokens=400, messages=[{"role": "user", "content": "Why is the sky blue?"}],)print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.exoticrouter.com", apiKey: process.env.EXOTIC_API_KEY,});
const message = await client.messages.create({ model: "anthropic/claude-sonnet-5-5", max_tokens: 400, messages: [{ role: "user", content: "Why is the sky blue?" }],});console.log(message.content[0].type === "text" ? message.content[0].text : "");The Anthropic SDK takes the gateway’s address without /v1: it adds the path itself. Anthropic SDK has the setup.
What is passed on
Section titled “What is passed on”modelhas to be there. Every text model answers on this endpoint: the Claude models take the request as you send it, and any other (openai/gpt-6.2-astra, a Gemini or DeepSeek model) has it translated to Chat Completions by the gateway and answers in this format. Any spelling the gateway understands works,claude-sonnet-5-5included.- On a Claude model the rest of the body goes to the model untouched, fields the gateway does not know included:
system,tools,thinking,metadataand so on. max_tokensis part of the format and has to be there.- Of the request’s headers,
anthropic-versionandanthropic-betaare passed on, withcontent-typeandaccept. Without ananthropic-versionthe gateway sends2023-06-01. Other headers are not passed on.
The answer
Section titled “The answer”{ "id": "msg_Q4tJ8vK2mN7pR1sW9xYzAb3C", "type": "message", "role": "assistant", "model": "anthropic/claude-sonnet-5-5", "content": [ { "type": "text", "text": "Sunlight is scattered by the air, and blue light is scattered the most." } ], "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 14, "output_tokens": 18 }}- It is Anthropic’s message object.
modelis the model’s full id andidis the gateway’s own. usageis the model’s own report. The input figure you are billed on is the gateway’s own count and can differ from it.
Streaming
Section titled “Streaming”With "stream": true the answer comes as Anthropic’s own events, each with its name: message_start, the content block events, message_delta, and message_stop at the end.
with client.messages.stream( model="anthropic/claude-sonnet-5-5", max_tokens=400, messages=[{"role": "user", "content": "Write a haiku about glass."}],) as stream: for text in stream.text_stream: print(text, end="", flush=True)const stream = client.messages.stream({ model: "anthropic/claude-sonnet-5-5", max_tokens: 400, messages: [{ role: "user", content: "Write a haiku about glass." }],});stream.on("text", (text) => process.stdout.write(text));await stream.finalMessage();- While the model is silent the gateway sends a
pingevent every 15 seconds, as Anthropic’s API does. - If the model fails after the stream has begun, the stream ends with one
errorevent and nomessage_stop.
Errors
Section titled “Errors”On this endpoint errors are shaped the way Anthropic shapes them, so the SDK raises its usual exceptions.
{ "type": "error", "error": { "type": "not_found_error", "message": "The model `claude-unknown` does not exist." }}The type follows the status: authentication_error for 401, billing_error for 402, rate_limit_error for 429, overloaded_error for 503. A request the model itself refuses, a tool schema it does not accept for instance, answers 400 with the model’s own reason. A prompt too long for the model says so in Anthropic’s words, with the numbers. Errors lists them all.
Where next
Section titled “Where next”- Anthropic SDK: Python and TypeScript, with the base URL changed.
- Claude Code: The agent that speaks this format.