⚡ New — Kimi K3 is live: bring your own Moonshot key →
Documentation

Migrate from Anthropic (Claude)

← All migration guides

Frontier APIwire-format change

Move from the Anthropic Messages API to the OpenAI shape — then it's the usual swap.

The change

Before — Anthropic (Claude)

# Anthropic Messages API (native shape)
from anthropic import Anthropic

client = Anthropic(api_key="sk-ant-...")
msg = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=512,
    messages=[{"role": "user", "content": "namaste"}],
)

After — BharatRouter

# OpenAI shape through BharatRouter
from openai import OpenAI

client = OpenAI(
    base_url="https://api.bharatrouter.com/v1",
    api_key="br-...",
)
r = client.chat.completions.create(
    model="claude-sonnet-4-6",   # via BYOK
    messages=[{"role": "user", "content": "namaste"}],
    max_tokens=512,
)

What maps to what

Anthropic (Claude)BharatRouter
client.messages.create()client.chat.completions.create()
Top-level system stringA {"role": "system"} message
max_tokens (required)max_tokens (optional, but supported)
x-api-key headerAuthorization: Bearer br-…

What you gain

  • Use Claude alongside Krutrim, Sarvam and others through one OpenAI-style client.
  • INR billing and routing/failover that Anthropic's direct API doesn't offer.

Watch out for

  • Different wire format: Anthropic's native Messages API isn't OpenAI-shaped — switch your calls to chat completions as shown above.
  • Claude models route via BYOK today; add your Anthropic key once.
  • Anthropic is not India-resident — excluded under data_policy: "india_only".

Stuck on a migration? Email [email protected], see the FAQ, or keep your accounts and rates with BYOK.