API
Anthropic Messages
POST /v1/messages speaks Anthropic's Messages format for every text model on sale.
POST /v1/messages takes Anthropic's Messages request and returns Anthropic's response and stream events.
It's the route Claude Code and the Anthropic SDKs use.
The gateway converts the request for the model you name, so every text model on sale answers here, not only Claude models.
POST/v1/messages
Base URL: https://api.azrouter.dev (no /v1; the client adds /v1/messages).
Claude models
Every Claude model listed on the Models page is on sale here, for example anthropic/ or anthropic/; any other text model's slug works in model too.
The prompt cache TTL is 5 minutes: a "ttl": "1h" marker is served and billed as a 5-minute cache write.
Only cache_control markers on content blocks are cached: see Prompt caching.
Headers
| Parameter | Details |
|---|---|
x-api-keystringheader | Your API key. Send it here or as |
anthropic-versionstringheader |
|
Request body
| Parameter | Details |
|---|---|
modelstringrequired | A slug from the model list. Any text model on sale answers here, not only Claude models. |
max_tokensintegerrequired | Upper bound on output tokens, a reasoning model's thinking included. |
messagesobject[]required | The conversation so far, as Anthropic Show child attributesHide child attributes
Text, or content blocks: A |
systemstring or object[] | Instructions for the model, as text or text blocks. A |
streamboolean | Send Anthropic's server-sent events. See Streaming. |
toolsobject[] | Your own tools, converted in both directions, streamed or not. Server tools such as web search are refused with 400 Show child attributesHide child attributes
The tool's name.
What the tool does.
Its input as a JSON Schema. |
Response
Anthropic's response shape.
| Parameter | Details |
|---|---|
typestring |
|
rolestring |
|
contentobject[] | The reply as blocks. A reasoning model's thinking arrives as a |
stop_reasonstring |
|
modelstring | The model that answered. |
usageobject |
|
Anthropic SDK
Point the SDK at the base URL without /v1:
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.azrouter.dev",
api_key=os.environ["AZROUTER_API_KEY"],
)
message = client.messages.create(
model="qwen/qwen3.8-flash",
max_tokens=200,
messages=[{"role": "user", "content": "Reply with exactly: Hello from AZRouter"}],
)
print(next(block.text for block in message.content if block.type == "text"))Streaming
Add "stream": true to get Anthropic's server-sent events: message_start, content_block_start, content_block_delta, content_block_stop, message_delta and message_stop.
Tools
Tool definitions (tools with input_schema) and tool_use / tool_result blocks are converted in both directions, streamed or not.
As on Chat Completions, only your own tools are accepted; server tools such as web search are refused with 400 invalid_request.
Token counting is not available
POST /v1/messages/count_tokens returns 404:
curl -i https://api.azrouter.dev/v1/messages/count_tokens \
-H "x-api-key: $AZROUTER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "qwen/qwen3.8-flash", "messages": [{"role": "user", "content": "Hello"}]}'Claude Code treats this endpoint as optional and estimates token counts itself, so its context meter is approximate.
The bill uses the token counts the model reports.