Guides
Anthropic API surface
ezrouter exposes a second wire format alongside the OpenAI-compatible endpoint: an Anthropic-compatible surface at https://www.ezrouter.dev/anthropic. It accepts the same API key as the OpenAI surface and routes against the same upstream models.
Use this surface when your client is already shaped around the Anthropic SDK or Claude Code, or when you need claude-family features (extended thinking, prompt caching) in their native wire format.
When to pick which surface
| Want… | Use |
|---|---|
OpenAI SDK with base_url override | OpenAI surface (/v1) |
Anthropic SDK with base_url override | Anthropic surface (/anthropic/v1) |
| Claude Code (env-var configuration) | Anthropic surface (/anthropic) |
Plain chat against deepseek- / gpt- / glm- / kimi- | OpenAI surface |
Tool calls on claude-opus-4-7 | either; both verified |
| Reliable extended thinking across multi-turn | Anthropic surface (OpenAI surface drops reasoning_content between turns — see thinking mode) |
Both surfaces share one account, one key, one billing line.
Python SDK quickstart
pip install anthropicimport anthropic
import os
client = anthropic.Anthropic(
base_url="https://www.ezrouter.dev/anthropic",
api_key=os.environ["EZROUTER_API_KEY"],
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": "Hi, how are you?"}],
)
print(message.content[0].text)The Anthropic SDK calls ${base_url}/v1/messages, so set base_url to the surface root (no trailing /v1).
Routing non-claude models
You can pass any catalog model ID, not just claude:
client.messages.create(model="deepseek-v4-pro", max_tokens=512, ...)The gateway translates the request from the Anthropic wire format to whatever the upstream provider expects, and translates the response back. Most fields round-trip; some advanced ones do not (see below).
Field support
This page intentionally does not republish the per-field compatibility matrix that existed in the upstream documentation — those entries described an upstream gateway with different translation behavior. For ezrouter, the verified posture is:
| Area | Status |
|---|---|
Plain text messages, system, max_tokens, temperature, top_p, stop_sequences, stream | Works |
tools + tool_choice (basic shape: auto, any, tool, none) | Works on claude-opus-4-7; other models may not emit parseable tool deltas — see tool calls |
thinking block (claude extended thinking) | Works on claude models; non-claude models do not have an analogue |
cache_control for prompt caching | Auto-cache active on most models; explicit cache_control markers not yet exhaustively verified — see KV cache |
| Image / document / search-result content blocks | Not verified. Treat as unsupported on ezrouter until probed. |
anthropic-beta / anthropic-version headers | Likely ignored by the gateway; rely on model behavior, not header negotiation |
| MCP / web-search / code-execution tool blocks | Not supported on the gateway today |
When in doubt, test the field against the model you intend to use. A one-call probe with an OpenAI SDK chat completion or the Anthropic SDK above is enough to confirm whether the gateway accepts or drops a given parameter for the model you care about.
Headers and auth
The Anthropic surface accepts either header for auth:
x-api-key: ${EZROUTER_API_KEY}(native Anthropic style)Authorization: Bearer ${EZROUTER_API_KEY}(also accepted)
The SDK uses x-api-key by default; either form ends up at the same account.
Errors
Errors on this surface share the ezrouter error envelope shape on the gateway level. The Anthropic SDK may surface them through its own exception types (anthropic.AuthenticationError, anthropic.APIStatusError); switch on HTTP status code rather than on exception class when writing portable error handling.
Related
- Coding agents — which agents use this surface.
- Claude Code — end-to-end env-var
setup.
- Thinking mode — extended thinking caveats.
- Tool calls — per-model tool-use reliability.