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

API reference

Everything the gateway exposes, grouped by auth model. Inference endpoints take an API key (Authorization: Bearer br-…); dashboard endpoints use the browser session cookie set at sign-in and are listed here for completeness — most people use them through the dashboard UI. A machine-readable schema lives at openapi.json.

Inference (API key)

POST /v1/chat/completions

OpenAI-compatible chat completions, streaming and non-streaming. Accepts theBharatRouter extensions (optimize,optimize_weights, provider, data_policy,upstream_key, fallbacks, …) — they are consumed by the router and stripped before the request leaves the gateway. The provider that actually served the request is echoed in the x-br-provider response header.

curl https://api.bharatrouter.com/v1/chat/completions \
  -H "Authorization: Bearer br-..." -H "Content-Type: application/json" \
  -d '{
    "model": "qwen2.5-7b-instruct",
    "messages": [
      {"role": "system", "content": "You answer in Hindi."},
      {"role": "user", "content": "What is the capital of Maharashtra?"}
    ],
    "max_tokens": 200,
    "optimize": "uptime"
  }'

Response (non-streaming) is a standard chat-completion object with token usage:

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "qwen2.5-7b-instruct",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "मुंबई ..." }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 28, "completion_tokens": 41, "total_tokens": 69 }
}

With "stream": true the response is text/event-stream. The gateway injects stream_options.include_usage on providers that support it, so the final chunk before [DONE] carries the usage block.

POST /v1/messages

Anthropic-native Messages API surface — same wire format Claude Code and the Anthropic SDKs already speak, so you can repoint an existing Anthropic client at BharatRouter without rewriting to the OpenAI shape. Serves the Claude models (claude-sonnet-5, claude-opus-4.8, claude-haiku-4.5) with the same routing, residency and INR metering as the chat surface.

Three ways to present your br- gateway key, in precedence order — pick whichever your client makes easy:

HeaderUse it when
x-br-api-key: br-…You also forward a personal Anthropic/Claude Max credential on Authorization for BYOK/passthrough — the gateway key takes this side channel so Authorization reaches upstream untouched. This is how brcode/Claude Code wire it via ANTHROPIC_CUSTOM_HEADERS.
Authorization: Bearer br-…Plain gateway auth, no forwarded upstream credential — the OpenAI-style default.
x-api-key: br-…Drop-in for the Anthropic SDK. The SDK's default api_key= sends this header, so Anthropic(base_url="https://api.bharatrouter.com", api_key="br-…") works unmodified. Only a br-/Ekam-shaped value is read as the gateway key here — a passthrough sk-ant-… is never mistaken for one.
# Anthropic SDK — one line changes (base_url), your br- key goes in api_key
from anthropic import Anthropic
client = Anthropic(base_url="https://api.bharatrouter.com", api_key="br-...")
client.messages.create(model="claude-sonnet-5", max_tokens=256,
  messages=[{"role": "user", "content": "Namaste!"}])

# curl, native format
curl https://api.bharatrouter.com/v1/messages \
  -H "x-api-key: br-..." -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{ "model": "claude-sonnet-5", "max_tokens": 256,
    "messages": [{"role": "user", "content": "Namaste!"}] }'

POST /v1/embeddings

OpenAI-compatible embeddings with the same extensions, routing, and failover as chat. India-resident models served on the platform key: bge-m3 (1024-dim).

curl https://api.bharatrouter.com/v1/embeddings \
  -H "Authorization: Bearer br-..." -H "Content-Type: application/json" \
  -d '{ "model": "bge-m3", "input": ["namaste", "vanakkam"], "data_policy": "india_only" }'

Catalog & health (public, no auth)

EndpointReturns
GET /v1/modelsThe full catalog: per-model INR pricing (₹/Mtok), residency, language tags, context length, and live per-route health.
GET /v1/models/:id/stats7-day traffic stats for one model — success rate, p50/p95 latency, tokens/sec.
GET /v1/providersProvider registry: configured status, residency, BYOK support, platform-key fallback.
GET /v1/pricing/comparePrice comparison against OpenRouter, FX-converted to INR (cached hourly).
GET /v1/rankingsMost-used catalog models by token volume, 7-day and 30-day windows. See Usage.
GET /v1/collectionsPublic collections registry. GET /v1/collections/:slug for one with version history.
GET /healthProvider configuration plus per-route circuit-breaker state.
curl -s https://api.bharatrouter.com/v1/models | jq '.data[] | select(.id=="qwen2.5-7b-instruct")'

Discovery (public)

GET /openapi.jsonOpenAPI 3.1 schema.
GET /llms.txtLLM-readable API summary.
GET /.well-known/mcp/server-card.jsonMCP server metadata (streamable HTTP, bearer auth). See MCP for agents.

Dashboard API (session cookie)

Set by GitHub/Google OAuth at sign-in(GET /auth/:provider → callback → br_session cookie;POST /auth/logout clears it). Org owners can do everything; some endpoints are owner-only as marked.

Account

EndpointWhat it does
GET /meCurrent user + org (id, email, role, org name, domain).
PATCH /meUpdate display name or remove avatar.
PATCH /me/orgRename the org (owner).

API keys

Full semantics on API keys & limits.

EndpointWhat it does
GET /me/keysList keys: prefix, name, tier, rpm/daily limits, monthly ₹ budget, spend this month, last used.
POST /me/keysMint a key — name?, budget_inr?, expires_days? (1–365). The full key is shown exactly once.
PATCH /me/keys/:idUpdate rpm_limit, daily_limit, budget_inr (owner/admin). Takes effect within 60 s.
DELETE /me/keys/:idRevoke a key (owner/admin). Effective within 60 s.

BYOK keys

Full guide on the BYOK page.

EndpointWhat it does
GET /me/byokProviders that accept BYOK + your saved keys (masked).
PUT /me/byok/:providerSave or replace a provider key — key, label?, always_use? (owner). Verified live, encrypted at rest; models are discovered on save.
POST /me/byok/:provider/testRe-verify a saved key: ok / rejected / unreachable (owner).
GET /me/byok/:provider/modelsModels discovered with your key, addressable as provider/model-id.
DELETE /me/byok/:providerRemove the saved key (owner).

Billing

Full semantics on Credits & billing.

EndpointWhat it does
GET /me/billingBalance (₹), low-balance threshold, money-event ledger, payments, 30-day usage, billing address.
POST /me/billing/addressSet the billing address (required before the first top-up, for GST place-of-supply) (owner).
GET /me/billing/pincode/:pinIndia Post PIN lookup → city/state autofill.
POST /me/billing/ordersCreate a Razorpay order — amount_inr (whole ₹, 100–100000 in beta), promo_code? (owner).
POST /me/billing/verifyVerify checkout signature and credit the balance (idempotent) (owner).
POST /me/billing/promo/checkValidate a promo code before paying (owner).
POST /me/billing/settingsSet or clear the low-balance email threshold (₹) (owner).
GET /me/billing/receipts/:paymentIdPrintable HTML payment receipt (owner).
GET /me/invoicesList GST tax invoices (B2C) — one per captured top-up, with invoice number and download link.
GET /me/invoices/:paymentIdOne invoice as printable HTML (CGST/SGST or IGST, SAC 998315, gapless number).
GET /me/billing/profileRead the org's billing/GST profile.
POST /me/billing/profileSet the billing/GST profile (owner). B2B GSTIN invoicing is gated until IRN/e-invoicing is enabled.
POST /me/billing/validate-gstinValidate a GSTIN and derive PAN/state for place-of-supply (owner).

Routing chains

Saved org-wide fallback chains — full guide on Routing.

EndpointWhat it does
GET /me/routingList saved chains; GET /me/routing/:model for one.
PUT /me/routing/:modelSave/replace a model's chain — steps (1–10) (owner/admin).
DELETE /me/routing/:modelRemove it; routing returns to default (owner/admin).

Collections

Full guide on Collections.

EndpointWhat it does
GET /me/collectionsYour org's collections (private + public + forked).
POST /me/collectionsCreate — name, model, steps, readme_md?, public? (owner/admin).
PATCH /me/collections/:id · DELETE /me/collections/:idEdit (bumps version) or delete (owner/admin).
POST /me/collections/star/:slugToggle a star (one per org).
POST /me/collections/fork/:slugFork a public collection into your org.
POST /me/collections/import/:slugFork-if-foreign, then apply as your routing (owner/admin).

Custom endpoints (BYOE)

Full guide on Bring your own endpoint.

EndpointWhat it does
GET /me/endpointsList registered endpoints (keys masked, with compliance status).
POST /me/endpointsRegister + compliance-test inline (owner/admin).
POST /me/endpoints/testCompliance-test an unsaved config (no write).
POST /me/endpoints/:id/retest · DELETE /me/endpoints/:idRe-test or remove (owner/admin).

Reliability monitoring

Full guide on Reliability monitoring.

EndpointWhat it does
POST /me/collections/:slug/monitorToggle monitoring on/off (monitored) (owner/admin).
POST /me/collections/:slug/checkCanary every step now and return fresh health.
GET /me/collections/:slug/healthPer-step uptime + p95 latency + last canary (?days= 1–90, default 7).
GET/POST /me/collections/:slug/alerts · DELETE …/alerts/:idList, create or remove alerts on error_rate/latency_p95 → email/webhook (owner/admin to mutate).

Teams & workspaces

Full guide on Teams & workspaces.

EndpointWhat it does
GET /me/orgs · POST /me/orgs · POST /me/orgs/switchList orgs, create a team org, switch active org.
GET /me/members · POST /me/membersList members + pending; invite by email + role (owner/admin).
PATCH /me/members/:id · DELETE /me/members/:idChange role (owner) · remove or leave.
GET /me/invitations · POST /me/invitations/:id/(accept|decline)Your invitations; accept or decline.
GET/POST /me/workspaces · PATCH/DELETE /me/workspaces/:idList/create workspaces; PATCH renames or sets a monthly_budget_inr cap; DELETE archives (owner/admin to mutate).

Usage & activity

Full guide on Usage, activity & rankings.

EndpointWhat it does
GET /me/usagePer-key requests and tokens, today (IST) and last 30 days.
GET /me/usage/dailyLast 30 days grouped by day and model — powers the dashboard chart.
GET /me/activitySpend/volume aggregates over a date range — day×model, top models/keys, per-provider cost split.
GET /me/activity/eventsPer-request drill-down, newest first, keyset-paginated.
POST /me/attributionOne-time "where did you hear about us?" signup survey.
GET /v1/usage (API key)Programmatic usage statement: totals + by_model + by_agent (spend per agent identity) over a date range (from/to, IST). ?format=csv or /v1/usage.csv for the day×model×provider export.

Coding agent (brcode CLI)

BharatRouter Code (brcode) runs a coding agent on GLM through the gateway. One org profile — default model, MCP connectors, and optional rules — lets a teammate inherit your whole setup with brcode login && brcode init.

EndpointWhat it does
GET /v1/me/profile (API key)Your org's coding profile: model, connectors[] (MCP servers), rules. Returns sane defaults when unset. The CLI reads this on init.
PUT /v1/me/profile (API key)Set the profile — model?, connectors[]?, rules?. Connectors declare env-var names only, never secret values. Inference-scoped keys cannot write.
GET /cli/login?port=&state= (browser)Zero-paste CLI login: when you're signed in it mints a brcode CLI key and hands it to the CLI over a localhost loopback; otherwise it routes through sign-in first. Used by brcode login.
GET/POST /v1/me/agents · POST /v1/me/agents/:id/token|revoke (API key)Agent identities from the CLI plane: list (incl. monthly_budget_inr), create (idempotent by name), broker a short-lived identity token, kill-switch. Inference-scoped keys can list but never mint.
POST /v1/me/agents/:id/budget (API key)Set or clear one agent's monthly ₹ cap — monthly_budget_inr (null/0 clears). Enforced per IST month against that agent's attributed spend; once exhausted its calls get 429 agent_budget_exceeded. Console equivalent: POST /me/budgets with scope:"agent".

Agent identity (Ekam)

Every machine running a coding agent gets an invisible per-machine agent principal — an Ekam-governed identity created once and reused thereafter, so spend, memory writes and audit trails attribute to the agent rather than the human's key. The claude-native installer wires this automatically via Claude Code's apiKeyHelper; toggle withbr-mode identity on|off. Admins see and revoke agents in the console.

EndpointWhat it does
POST /v1/me/agents (API key)Create-or-reuse an agent principal (idempotent by name — the same machine always resolves to the same agent).
POST /v1/me/agents/:id/token (API key)Broker a short-lived JWT for the agent, usable as a Bearer credential on any BharatRouter endpoint. This is what apiKeyHelper returns to Claude Code.
POST /v1/me/agents/:id/revoke (API key)Kill-switch: revoke the agent; outstanding tokens stop working.
POST /v1/me/agents/:id/budget (API key)Set or clear the agent's monthly ₹ cap (monthly_budget_inr; null/0 clears).

Requests carrying an agent identity are attributed in GET /v1/usage'sby_agent split and stamped onto shared-memory writes viax-br-agent-id.

Shared memory (agents)

An org-level object store the gateway fronts for agent memory: journals, records and private notes live under your own S3/KOS bucket, scope-checked per key. Default-on for users — it activates the moment an admin configures the store; until then memory endpoints return404 code memory_not_configured. All keys are validated (no ..or absolute paths) and joined under the org's base_prefix server-side.

Store setup (admin)

Owner/admin only — via the console's Memory storage card or the API. Credentials are encrypted at rest (same envelope as BYOK keys) and never returned.

EndpointWhat it does
PUT /v1/me/memory-store (API key, admin)Configure the org store — endpoint, bucket, access_key, secret_key, optional region, quota_mb (default 1024), journal_ttl_days (default 30). Returns {"ok": true}. Repointing a store that already holds memory returns 409 store_path_change_in_use with usage evidence — nothing is migrated; re-submit with confirm_path_change: true to proceed anyway. Credential fields left blank on update keep the sealed ones.
GET /v1/me/memory-store (API key){configured:false}, or the config with bytes_used and access_key_masked — the secret is never echoed.
PUT/GET /me/memory-store (cookie, owner/admin)Console twins of the above.

Scope model

PathWho readsWho writes
org/records/Everyone in the orgPromotion only (admin)
workspaces/<ws>/records/Workspace teamPromotion only (admin)
workspaces/<ws>/journal/Workspace teamWorkspace team (TTL'd)
shared/<space>/Share owner + granted same-org membersShare owner + granted same-org members
users/<uid>/Owner onlyOwner only
agents/Any key in the orgAny key (agent working state)

PII posture: the personal users/<uid>/ scope is never readable via team paths; the pattern is extraction, not transcription — agents write distilled facts, not raw conversation; every object carries provenance metadata so erasure requests can be honoured.

Peer shares

Peer shares add an explicit, tenant-local collaboration scope without widening personal, workspace or org access. A safe space slug resolves toshared/<space>/. Owners always have access; each granted member gets read/write access. Org owners/admins may administer a share but do not gain data access unless they are its owner or a granted member. ACL changes require a full-scope, user-backed key.

EndpointWhat it does
GET /v1/me/memory/sharesList shares the caller owns or belongs to, including owner/member UIDs and the caller's role.
POST /v1/me/memory/sharesCreate {space, member_uids?}. Replays by the same owner are idempotent and add only missing grants. A deleted/retired space cannot be reused, so retained objects can never become visible to a later owner.
PUT /v1/me/memory/shares/:space/members/:uidGrant a live member of the same org (owner or org owner/admin; idempotent).
DELETE /v1/me/memory/shares/:space/members/:uidRevoke one member immediately; safe to repeat. The owner cannot be revoked.
DELETE /v1/me/memory/shares/:spaceRetire the share and delete its grants (share owner or org owner/admin). Stored objects are not silently purged; the logical space remains permanently reserved.

Objects & journal

EndpointWhat it does
GET /v1/me/memory/pathsYour resolved scope prefixes: {scopes:{user, workspace?, org, shared?[]}} (optional fields are omitted when absent).
GET /v1/me/memory/o?key=…Read an object, scope-checked — raw text/plain body; 404 if missing.
PUT /v1/me/memory/o?key=…Write (body = raw content) into a write scope. Stamps x-amz-meta-br-user, x-amz-meta-br-ts, and x-amz-meta-br-agent when x-br-agent-id is present. Quota-enforced: over quota_mb413.
GET /v1/me/memory/list?prefix=…Scope-checked listing — {keys:[{key,size,modified}]}. Journal entries older than journal_ttl_days are filtered out (two-tier journal → records).
DELETE /v1/me/memory/o?key=…Delete from your own write scopes; frees quota.
POST /v1/me/memory/promote (admin)The human-approval promotion gate: {workspace_id?, name, content, source_keys?} writes a durable record to workspaces/<ws>/records/ (or org/records/) with provenance metadata x-amz-meta-br-promoted-by and x-amz-meta-br-sources.

In Claude Code the memory plane surfaces as automatic SessionStart recall plus/br-remember (team journal), /br-remember-me (private note) and/br-memory status. Journal entries expire after journal_ttl_days; anything worth keeping is promoted — by a human — into records.

Webhooks

EndpointNotes
POST /webhooks/razorpayRazorpay events (payment.captured, payment.failed), verified via the x-razorpay-signature HMAC header. Crediting is idempotent across webhook and checkout-verify paths.

Response headers

HeaderMeaning
x-br-providerProvider that served the request (e.g. krutrim, bharatrouter).
retry-afterOn 429 responses: seconds to wait before retrying.

Platform limits

LimitValue
Gateway rate limit120 requests/min per key (or per IP when unauthenticated).
Trial keys60 requests/min, 200 requests/day (resets midnight IST).
Top-up₹100–₹1,00,000 per transaction (beta).

Per-key limits and monthly ₹ budgets are configurable — seeAPI keys & limits. Errors use a single JSON envelope — see Errors.