Skip to content
exoticrouter.com ↗

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

cURL
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?"}]
}'
Python
import os
from 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)
TypeScript
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.

  • model has 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-5 included.
  • On a Claude model the rest of the body goes to the model untouched, fields the gateway does not know included: system, tools, thinking, metadata and so on.
  • max_tokens is part of the format and has to be there.
  • Of the request’s headers, anthropic-version and anthropic-beta are passed on, with content-type and accept. Without an anthropic-version the gateway sends 2023-06-01. Other headers are not passed on.
{
"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. model is the model’s full id and id is the gateway’s own.
  • usage is the model’s own report. The input figure you are billed on is the gateway’s own count and can differ from it.

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.

Python
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)
TypeScript
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 ping event every 15 seconds, as Anthropic’s API does.
  • If the model fails after the stream has begun, the stream ends with one error event and no message_stop.

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.