Claude native format

Anthropic's Messages API, served as-is for the Anthropic SDK.

POSThttps://clawrouter.com/v1/messages

This is Anthropic's Messages API. Reach for it when you want Claude-specific features the OpenAI shape cannot express — fine-grained cache control, thinking blocks, or the tool format the Anthropic SDK expects.

Authentication

Both header styles work, so the Anthropic SDK drops in without a shim: send your key as x-api-key, or as a normal bearer token. Anthropic's current SDKs (Python 2, TypeScript 1, Go 2 and later) send it as a bearer token; point their base URL at {{BASE}} and nothing else changes.

curl https://clawrouter.com/v1/messages \
  -H "x-api-key: $CLAWROUTER_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

API versions

Both anthropic-version 2026-10-21 and 2023-06-01 are accepted, and the Anthropic SDKs set the header for you. Version 2026-10-21 removes temperature, top_p and top_k; Claude Opus 4.7 and later models accept only their defaults under either version, so the gateway leaves these parameters out for them rather than failing the request.

Prompt caching

The simplest way is a top-level cache_control: it caches everything up to the last cacheable block, so a conversation reuses its own history on the next turn. To put the breakpoint somewhere else, mark individual blocks instead. Cache reads are billed at a fraction of the normal input rate, and the cached, written and uncached portions are itemised separately in your usage log.

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "cache_control": { "type": "ephemeral" },
  "system": "<a long, stable instruction block>",
  "messages": [{ "role": "user", "content": "Hello" }]
}

System messages mid-conversation

To change the rules partway through a conversation, append a message with role system instead of editing the top-level system prompt. The history before it stays byte-identical, so its cache keeps working. It must follow a user message and be either the last message or followed by an assistant turn.

JSON
{
  "model": "claude-opus-5-5",
  "max_tokens": 1024,
  "messages": [
    { "role": "user", "content": "What is the capital of Japan?" },
    { "role": "assistant", "content": "Tokyo." },
    { "role": "user", "content": "And France?" },
    { "role": "system", "content": "From now on, answer in one short English sentence." }
  ]
}

Supported on Claude Opus 5.5, Opus 5, Opus 4.8, Sonnet 5.5, Haiku 5.5 and Fable 5 / 5.1. Claude Sonnet 5 rejects it; use the top-level system prompt there.

Not available

  • POST /v1/messages/count_tokens is not served. Estimate from the usage block of a response instead.
  • speed (fast mode), inference_geo and fallbacks change what a request costs, so they are removed before the request is forwarded. The request still succeeds, at standard speed and on the model you named.