- Docs
- API reference
- Messages
Messages
POST
https://api.airoutly.com/v1/messagesAnthropic's native API for Claude models, used by the Anthropic SDKs and Claude Code. Set the SDK's Base URL to https://api.airoutly.com, without /v1.
Authentication
Send x-api-key: <key> (what the Anthropic SDKs do) or Authorization: Bearer <key>. The anthropic-version header is accepted as usual.
Request body
| Parameter | Description |
|---|---|
modelstringrequired | A model that lists Msg on the models page, such as claude-sonnet-4-5. |
max_tokensintegerrequired | Upper limit on generated tokens. |
messagesarrayrequired | Alternating user and assistant turns; content can include text, images and tool results. |
systemstring | array | System prompt. Use the array form to add cache_control. |
streamboolean | Stream the reply as server-sent events. |
toolsarray | Tools the model may call. |
thinkingobject | Extended thinking on models that support it, for example {"type": "enabled", "budget_tokens": 4096}. |
Example request
curl https://api.airoutly.com/v1/messages \
-H "x-api-key: $AIROUTLY_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.airoutly.com", api_key=os.environ["AIROUTLY_API_KEY"])
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.airoutly.com", apiKey: process.env.AIROUTLY_API_KEY });
const msg = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});Prompt caching
Mark long, repeated content with cache_control. Writing to the cache is billed at the cache-write price, and later hits at the much lower cache-read price, both shown on each model’s page.
Python
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
system=[{
"type": "text",
"text": LONG_SYSTEM_PROMPT,
"cache_control": {"type": "ephemeral"},
}],
messages=[{"role": "user", "content": "Summarise section 3."}],
)
print(msg.usage.cache_creation_input_tokens, msg.usage.cache_read_input_tokens)Response
200 OK
{
"id": "msg_123",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-5",
"content": [{ "type": "text", "text": "Hello! How can I help?" }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 9, "output_tokens": 8, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 }
}Token countingThe
/v1/messages/count_tokens endpoint isn’t available. Read token counts from usage in the response instead.