API Token Route

Home / Guides / Anthropic native API integration

Anthropic native API integration

Keep the Anthropic Messages API shape. Change the host and the key.

Use https://api.apitokenroute.com as the Anthropic base URL, without /v1, and send POST /v1/messages with x-api-key and anthropic-version: 2023-06-01. The Anthropic SDK only needs base_url changed; streaming, prompt caching and the response schema stay native. Billing is per token from the prepaid balance.

Updated: 2026-12-02

Endpoint and headers

ItemValue
Base URLhttps://api.apitokenroute.com (no /v1)
EndpointPOST /v1/messages
Authenticationx-api-key: sk-atr-...
Version headeranthropic-version: 2023-06-01
Content typeapplication/json
Model IDsCatalog IDs with hyphens, for example claude-fable-5-1

Anthropic models are billed per token. Live prices from the catalog:

Model / IDInputOutputCache readContextDiscount
Claude Sonnet 5.5
claude-sonnet-5-5
$0.576$2.88$0.02881.0M-71%
Claude Opus 5.5
claude-opus-5-5
$1.16$5.8$0.0581.0M-71%
Claude Fable 5.2
claude-fable-5-2
$2.432$12.16$0.06081.0M-70%

USD per 1M tokens from the live catalog; your console bill is the final record.

First request

curl https://api.apitokenroute.com/v1/messages -H "x-api-key: sk-atr-..." -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{"model":"claude-fable-5-1","max_tokens":1024,"messages":[{"role":"user","content":"Introduce yourself in one sentence"}]}'

The response keeps the Messages API shape: id, type, role, model, a content array, stop_reason, and a usage object with input_tokens and output_tokens. max_tokens is required.

SDK base URL

With the official Python SDK, pass base_url without /v1:

from anthropic import Anthropic

client = Anthropic(
    api_key="sk-atr-...",
    base_url="https://api.apitokenroute.com",
)

resp = client.messages.create(
    model="claude-fable-5-1",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)

Other Anthropic SDKs accept the same base URL option. The SDK appends /v1/messages itself, which is why the base URL must not already include /v1.

Streaming

Add "stream": true to the request body. The response is text/event-stream and follows the native event sequence:

message_start → content_block_start → one or more content_block_delta → content_block_stop → message_delta → message_stop.

Streaming is the practical setting for long agent turns. Large models can take seconds to tens of seconds to produce the first token during reasoning; a stream keeps the connection alive and lets the client render partial output. Raise the client read timeout as well. The server accepts requests up to 600 seconds.

Prompt caching

Claude caching is opt-in. With the native Messages API, add "cache_control": {"type": "ephemeral"} at the end of the content you want to reuse, typically the last system block, the last tool, and the latest message.

{
  "model": "claude-fable-5-1",
  "max_tokens": 1024,
  "system": [
    {"type": "text", "text": "A long, fixed system prompt", "cache_control": {"type": "ephemeral"}}
  ],
  "messages": [
    {"role": "user", "content": [
      {"type": "text", "text": "Introduce yourself in one sentence", "cache_control": {"type": "ephemeral"}}
    ]}
  ]
}

Caching matches by prefix: everything before a cache_control marker must stay identical across requests. Changing any part invalidates the cache after it. Content shorter than the model's minimum cacheable length is not cached.

After caching is enabled, usage.cache_creation_input_tokens is the cache write and usage.cache_read_input_tokens is the cache read. If both are 0, the marker is missing, the prefix changed, or the request went through the OpenAI-compatible format, which does not enable Claude caching automatically.

Errors and limits

Request timeouts can also come from a slow first token, not a failed request. Stream, raise the client read timeout, and keep requests under the 600-second server limit.

When native Anthropic is not the right choice

Use the native /v1/messages path for Claude models whenever you rely on prompt caching, extended thinking, tool use or agentic coding. Calling Claude through the OpenAI-compatible format can lose prompt cache and thinking, which raises cost and lowers quality; it is only suitable for simple chat.

If your application is built entirely around OpenAI Chat Completions and only needs basic text, /v1/chat/completions is simpler. If it uses the Responses API, remember that /v1/responses serves GPT models only and returns 400 for Claude or Gemini. Gemini has its own native format at /v1beta/models/{model}:generateContent.

Related: API integration guide, Claude Code troubleshooting, OpenAI-compatible API, model catalog.

FAQ

Does the Anthropic base URL include /v1?

No. Use https://api.apitokenroute.com. The endpoint is /v1/messages, and the SDK adds that path itself.

Which headers does the native API need?

x-api-key with your sk-atr- key, anthropic-version: 2023-06-01, and content-type: application/json. OpenAI-format calls use Authorization: Bearer instead.

Why are cache reads and cache writes both 0?

Caching is opt-in. Add cache_control with type ephemeral to the content you reuse, keep everything before the marker identical, and make sure the request uses the Anthropic format, not the OpenAI format.

Is streaming supported?

Yes. Set stream to true and consume the SSE events from message_start through message_stop.

Can I call Claude with the OpenAI SDK?

It works for simple chat through /v1/chat/completions, but it can lose prompt caching and thinking. Use the native Anthropic protocol for Claude in agent or coding workloads.

Is max_tokens required?

Yes. Include max_tokens in every Messages API request.