Provider guide

Anthropic Claude through one OpenAI-compatible gateway

Use Claude with the OpenAI SDK you already have. Routeplane translates your OpenAI-shaped request to Anthropic’s Messages API and back, so you never touch the native format — and get fallback, guardrails, and residency on top.

Anthropic’s API is not OpenAI-shaped — it uses /v1/messages, an x-api-key header, a top-level system field, and input_tokens/output_tokens in usage. Routeplane’s adapter does that translation in both directions, so from your side it is an ordinary OpenAI chat completion.

That means you can put Claude behind the same endpoint as every other provider, mix it into a fallback chain, and keep one client library across your whole fleet.

Drop in your OpenAI client

Point your existing OpenAI SDK at the gateway and add two headers — your virtual key and the provider. Nothing else about your code changes.

bashcurl
curl https://api.routeplane.ai/v1/chat/completions \
  -H "content-type: application/json" \
  -H "x-routeplane-api-key: rp_your_gateway_key" \
  -H "x-routeplane-provider: anthropic" \
  -d '{"model":"claude-sonnet-4-5","messages":[{"role":"user","content":"Hello!"}]}'
pythonopenai SDK
import openai

client = openai.OpenAI(
    api_key="rp_your_gateway_key",
    base_url="https://api.routeplane.ai/v1",
    default_headers={
        "x-routeplane-api-key": "rp_your_gateway_key",
        "x-routeplane-provider": "anthropic",   # route to Anthropic
    },
)

resp = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
typescriptopenai SDK
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'rp_your_gateway_key',
  baseURL: 'https://api.routeplane.ai/v1',
  defaultHeaders: {
    'x-routeplane-api-key': 'rp_your_gateway_key',
    'x-routeplane-provider': 'anthropic', // route to Anthropic
  },
});

const completion = await client.chat.completions.create({
  model: 'claude-sonnet-4-5',
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0]?.message.content);

Or use the Routeplane SDK

The Routeplane SDKs subclass the official OpenAI clients, wire up the x-routeplane-* headers for you, and add typed access to routing metadata and the non-OpenAI surfaces.

bashinstall
pip install routeplane
pythonrouteplane SDK
from routeplane import Routeplane

client = Routeplane(
    api_key="rp_your_gateway_key",
    provider="anthropic",   # route to Anthropic
)

resp = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
bashinstall
npm i @routeplane/sdk
typescript@routeplane/sdk
import { Routeplane } from '@routeplane/sdk';

const client = new Routeplane({
  apiKey: process.env.ROUTEPLANE_API_KEY!, // rp_...
  provider: 'anthropic',                 // route to Anthropic
});

const completion = await client.chat.completions.create({
  model: 'claude-sonnet-4-5',
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0]?.message.content);

Add a fallback chain

Send Claude first; fall back to OpenAI if Anthropic is unavailable. Make the provider header a comma-separated list and the gateway walks it in order, skipping any provider whose circuit is open.

bashcurl
curl https://api.routeplane.ai/v1/chat/completions \
  -H "content-type: application/json" \
  -H "x-routeplane-api-key: rp_your_gateway_key" \
  -H "x-routeplane-provider: anthropic,openai" \
  -d '{"model":"claude-sonnet-4-5","messages":[{"role":"user","content":"Hello!"}]}'

Anthropic on the gateway

The adapter supports chat completions and native streaming. Embeddings and other non-chat surfaces route to providers that offer them (e.g. OpenAI or Cohere) via the same gateway.

max_tokens is filled in for you

Anthropic requires max_tokens; the OpenAI shape treats it as optional. When you omit it, the adapter defaults to 1024 so the call still succeeds. Pass your own max_tokens (or max_completion_tokens) and it is threaded through unchanged.

Faithful field mapping

System messages are lifted to Anthropic’s top-level system, tool schemas map to input_schema, tool_callstool_use, and temperature is clamped to Anthropic’s 0..1 range. Requests Anthropic can’t represent (for example n > 1) return a clean 422 rather than a silent wrong answer.

Anthropic model pricing

List prices for the Anthropic models you can call through the gateway — click any model for its per-token cost page.

Sovereign routing

Sovereign routing works with Anthropic the same way it works everywhere: add x-routeplane-residency to a request, and when the gateway classifies regulated personal data in it, only providers resident in the requested region stay eligible — a hard constraint that overrides the provider header. Combine Anthropic with a region-locked deployment and declare its region so it becomes eligible for in-region routing.

Keep reading

Frequently asked questions

Is Routeplane a drop-in replacement for calling Anthropic directly?

Yes. The gateway is OpenAI-compatible, so switching is a base-URL change — point your existing OpenAI SDK at https://api.routeplane.ai/v1 and set the x-routeplane-provider header to anthropic. You keep your code and gain automatic fallback, in-data-plane PII guardrails, sovereign routing, and per-team cost attribution. Routeplane translates your OpenAI-shaped request into Anthropic's native API and maps the response back, so you never touch that format.

Which Anthropic models can I use through Routeplane?

Any Anthropic model the provider serves. See the list prices linked above for the ones we publish.

Can I enforce data residency on Anthropic requests?

Yes. Add the x-routeplane-residency header (for example IN) and, when a request carries regulated personal data, the gateway restricts routing to providers eligible in that region — overriding the provider header if it has to. Declare the region your Anthropic deployment serves so it becomes eligible.

Route your first request this week.

Point your existing OpenAI-compatible client at Routeplane, set one header, and get fallback, guardrails, and sovereign routing across every provider.