Anthropic Messages

The Anthropic Messages API at /v1/messages, so Anthropic SDKs and Claude Code work unchanged on every catalog model.

Send a message

Base URL is the bare origin https://api.experientiallabs.ai (the SDK appends /v1/messages; a /v1 base doubles the path). Authenticate with x-api-key or Authorization: Bearer. Any catalog slug works, not just Claude. Claude slugs use the dot form (claude-opus-5, claude-fable-5.1); Anthropic's dashed ids are accepted, dated ids answer 403 model_not_granted.

POST/v1/messages
curl https://api.experientiallabs.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-opus-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

Streaming and usage

stream: true returns Anthropic SSE (message_start, content_block_delta, message_stop). The final message_delta carries authoritative usage and usage.cost; on non-Anthropic routes message_start holds an estimate. Usage has all four legs including cache_read_input_tokens and cache_creation_input_tokens.

with client.messages.stream(
    model="claude-opus-5", max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="")

What translates across models

FeatureBehavior
Extended thinkingVerbatim on all-Anthropic routes, signatures intact. Elsewhere mapped to the nearest reasoning effort (disclosed thinking->reasoning_effort:<tier>); budget_tokens must be below max_tokens. Signed thinking replayed to a non-Anthropic route is dropped with disclosure, not a 400
cache_controlPreserved on Anthropic and OpenRouter adapters, mapped to Bedrock checkpoints; one-hour writes bill 2x input, five-minute 1.25x
ImagesUp to 100 per request on image-capable routes
PDF documentsNeed a document-capable route, else a 400 naming messages
tool_result.is_errorNative on Anthropic, folded into the result text elsewhere
Web search, tool search server toolsServed on every route (Tool calling)
Idempotency-KeyNot honored
msg = client.messages.create(
    model="gpt-6-astra", max_tokens=8000,
    thinking={"type": "enabled", "budget_tokens": 4000},
    messages=[{"role": "user", "content": "Is 2^61 - 1 prime?"}],
)

Count tokens

Answers with the gateway's own estimate for the route (disclosed as an estimate, not a billing quote). Nothing is charged.

POST/v1/messages/count_tokens
curl https://api.experientiallabs.ai/v1/messages/count_tokens \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-opus-5", "messages": [{"role": "user", "content": "Hello"}]}'

Retries and errors

gateway.retry and gateway.routing work here too (Model selection); pass them through extra_body in Python and set max_retries=0 if your app owns retries. Errors use Anthropic's envelope at the same statuses as the OpenAI routes; see Errors. Claude Code setup is on Coding agents.

{"type": "error", "error": {"type": "invalid_request_error", "message": "..."}}