Chat

Anthropic Messages and Claude Code

Claude models also speak Anthropic’s Messages API, so Anthropic’s SDKs, Claude Code and anything built for them work with a new base URL and key.

POST/v1/messages

Base URL https://api.zurelay.com (the SDKs add /v1/messages). Send the key as x-api-key or Authorization: Bearer, with anthropic-version: 2023-06-01. Only Claude models are served here; other models use /v1/chat/completions.

With Anthropic’s SDKs

import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.zurelay.com",
api_key=os.environ["ZURELAY_API_KEY"],
)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
system="You are a careful code reviewer.",
messages=[{"role": "user", "content": "Review this function: def add(a, b): return a - b"}],
)
print(message.content[0].text)

Everything in Anthropic’s Messages API passes through (except metadata, which stays with us): system as a string or blocks (with cache_control for prompt caching), tools, thinking, output_config, stop_sequences, temperature, streaming with the same events, and anthropic-beta headers. Images and PDFs go in as image and document blocks: see Images, PDFs, audio and video. Anthropic refuses temperature, top_p and top_k on Claude from Opus 4.7 on, so for those models we leave them out of the request instead of failing it.

Thinking

Claude thinks adaptively: it decides how much a request needs, and output_config.effort sets how hard it works: low, medium, high, xhigh (extra high) or max. Add display: "summarized" to thinking to get a summary of the thinking back in thinking blocks.

import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.zurelay.com",
api_key=os.environ["ZURELAY_API_KEY"],
)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=32000,
thinking={"type": "adaptive", "display": "summarized"},
output_config={"effort": "xhigh"},
messages=[{"role": "user", "content": "How many primes are there below 1,000?"}],
)
for block in message.content:
print(block.thinking if block.type == "thinking" else block.text)
  • Claude Opus 5.5 and the Fable models always think: Opus 5.5 at medium unless you set a level, Fable at high. Asked not to think, they run at low.
  • Claude Sonnet 5.5 and Opus 5 think at high by default, and Claude Haiku 5.5 at medium. Opus 4.6 to 4.8 think only when you send thinking. Opus 4.6 has no xhigh, so it runs at high.
  • The older form, thinking: { type: "enabled", budget_tokens }, works on every Claude model: those that refuse it think adaptively at the closest level instead. Claude Haiku 4.5 takes only that form, and gets a budget when you send adaptive thinking.
  • Thinking is billed as output tokens, so leave room for it in max_tokens at xhigh and max, and stream long answers. When you set a level, the x-zurelay-reasoning-effort header says which one ran.

Prompt caching

Caching works as it does with Anthropic: put cache_control on the blocks to cache, or on the whole request, to keep them for five minutes, or add "ttl": "1h" to keep them for an hour. Each part of the input is billed the way Anthropic bills it:

InputBilled atIn usage
Read from the cacheThe model’s cached pricecache_read_input_tokens
Written to the cache for five minutes1.25 times the input priceephemeral_5m_input_tokens
Written to the cache for an hour2 times the input priceephemeral_1h_input_tokens
Everything elseThe input priceinput_tokens

The two kinds of writes are in usage.cache_creation, and cache_creation_input_tokens is both together. Each model page shows its cache prices. Only what you ask to cache is billed as a write: a request without cache_control pays the input price for everything it doesn’t read from the cache, and input you asked to keep for five minutes is never billed as an hour’s.

Claude Code

Point Claude Code at Zurelay with five environment variables (the base URL, your key and the three model aliases), then run it as usual:

Shell
export ANTHROPIC_BASE_URL="https://api.zurelay.com"
export ANTHROPIC_AUTH_TOKEN="$ZURELAY_API_KEY"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"
claude

To keep it, put the same values in the env block of ~/.claude/settings.json. The full guide, and guides for Cursor, Cline and others, are under Integrations.

Claude Code’s /effort levels reach the model as output_config.effort, so xhigh and max work as they do with Anthropic. Ultracode is a Claude Code setting, not an effort level: it runs at the session’s level (xhigh when you start Claude Code with --effort ultracode).

Counting tokens

POST/v1/messages/count_tokens

Takes the same body as /v1/messages and returns { "input_tokens": 1234 }, an estimate of what the request would count. Free.

Errors

Errors come back in Anthropic’s shape ({ "type": "error", "error": { "type", "message" } }), with the same meanings as on the errors page. They carry no code: use the HTTP status and error.type.

A few Claude models read PDFs only through /v1/chat/completions. Send one to /v1/messages and the error says which endpoint to use. The table on Images, PDFs, audio and video shows what each model reads.
  • Tip: Anthropic’s token counter and ours can differ slightly; usage in the response is what’s billed.

Questions, or something missing? Ask our support team and we’ll answer by email, usually within a minute.