🎬 New — watch the 2-minute guide videos →
Documentation

Use Claude through BharatRouter

← Cookbook

Reach Anthropic's Claude over the gateway — on the platform key or your own Anthropic key — and wire Claude Code in as an agent over MCP, with your routing, residency and budgets on every call.

BYOK (Anthropic) + MCP server Agents Beginner 6 min

BharatRouter speaks the OpenAI wire format (/v1/chat/completions) and ships a native MCP server. So there are two clean ways to put Claude to work: call Claude models through the gateway from any OpenAI-compatible client, and connect Claude Code as an agent over MCP. Either way, your org's routing rules, residency policy, per-key budgets and INR metering apply to every call.

Part A — Call Claude through the gateway

Claude is just another model id — point your existing OpenAI code at BharatRouter and pass a Claude model. No Anthropic SDK required.

1 · On the platform key — claude-haiku-4.5

claude-haiku-4.5 is in the catalog today (text + vision + reasoning). Change two lines of OpenAI code:

from openai import OpenAI

client = OpenAI(base_url="https://api.bharatrouter.com/v1", api_key="br-...")

resp = client.chat.completions.create(
    model="claude-haiku-4.5",
    messages=[{"role": "user", "content": "Summarise this ticket in one line: ..."}],
)
print(resp.choices[0].message.content)

2 · Your own Anthropic key — the full lineup (BYOK)

Want claude-opus-4-8 or claude-sonnet-4-6? Save your Anthropic key once under BYOK (org owner), and the gateway discovers every Claude model on your account as anthropic/<model>. Requests bill to your Anthropic account at your rate limits; routing, budgets and metering still apply.

curl -X PUT https://api.bharatrouter.com/me/byok/anthropic \
  -H "Authorization: Bearer br-..." \
  -d '{"key": "sk-ant-...", "label": "prod"}'

Then call any discovered model — same client, just the anthropic/ prefix:

resp = client.chat.completions.create(
    model="anthropic/claude-opus-4-8",
    messages=[{"role": "user", "content": "Draft a release note for v0.6."}],
)

Residency: Anthropic is a global (US) provider, so a Claude call leaves India — it will not satisfy data_policy: "india_only". For India-resident work, route a sovereign model (e.g. qwen2.5-7b-instruct) and reserve Claude for calls where offshore is acceptable. See india_only.

Part B — Wire Claude Code as an agent (MCP)

Claude Code is an agent, not just an API client — connect it to the gateway's MCP server and Claude can discover and call every BharatRouter model (Claude included) as a governed tool, inheriting your routing and residency on each step.

claude mcp add --transport http bharatrouter \
  https://api.bharatrouter.com/mcp \
  --header "Authorization: Bearer br-..."

Can you just point ANTHROPIC_BASE_URL at the gateway? Yes — BharatRouter now serves the Anthropic Messages API (/v1/messages) and translates non-Anthropic models on it, so you can repoint Claude Code's base URL at the gateway and run an open model like GLM through it — see Run Claude Code on GLM. To keep using real Claude on that surface (subscription-first, with metered overflow), see Govern Claude Code. Or use the OpenAI SDK (Part A) to call Claude as a model, and MCP (above) to govern any agent.

Same governance, human or agent

A human REST call and an autonomous agent step take the same path: same br-… key, same routing, same per-key ₹ budgets, same residency policy, same x-br-provider response header and usage metering. Pin data_policy and budgets on the key's defaults once, and every Claude call — yours or your agent's — inherits them.

Next: the full MCP agent recipe, save a BYOK key, or put Claude on a Sangam consensus panel.

More recipes in the Cookbook, or see the full API reference.