1. Docs
  2. API reference
  3. Messages

Messages

POSThttps://api.airoutly.com/v1/messages

Anthropic'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

ParameterDescription
modelstringrequiredA model that lists Msg on the models page, such as claude-sonnet-4-5.
max_tokensintegerrequiredUpper limit on generated tokens.
messagesarrayrequiredAlternating user and assistant turns; content can include text, images and tool results.
systemstring | arraySystem prompt. Use the array form to add cache_control.
streambooleanStream the reply as server-sent events.
toolsarrayTools the model may call.
thinkingobjectExtended 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"}]
  }'

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.