Esc to close · ⌘K / Ctrl-K opens search anywhere
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.
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.
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:
| Header | Use 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!"}] }'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" }'| Endpoint | Returns |
|---|---|
GET /v1/models | The full catalog: per-model INR pricing (₹/Mtok), residency, language tags, context length, and live per-route health. |
GET /v1/models/:id/stats | 7-day traffic stats for one model — success rate, p50/p95 latency, tokens/sec. |
GET /v1/providers | Provider registry: configured status, residency, BYOK support, platform-key fallback. |
GET /v1/pricing/compare | Price comparison against OpenRouter, FX-converted to INR (cached hourly). |
GET /v1/rankings | Most-used catalog models by token volume, 7-day and 30-day windows. See Usage. |
GET /v1/collections | Public collections registry. GET /v1/collections/:slug for one with version history. |
GET /health | Provider configuration plus per-route circuit-breaker state. |
curl -s https://api.bharatrouter.com/v1/models | jq '.data[] | select(.id=="qwen2.5-7b-instruct")'GET /openapi.json | OpenAPI 3.1 schema. |
GET /llms.txt | LLM-readable API summary. |
GET /.well-known/mcp/server-card.json | MCP server metadata (streamable HTTP, bearer auth). See MCP for agents. |
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.
| Endpoint | What it does |
|---|---|
GET /me | Current user + org (id, email, role, org name, domain). |
PATCH /me | Update display name or remove avatar. |
PATCH /me/org | Rename the org (owner). |
Full semantics on API keys & limits.
| Endpoint | What it does |
|---|---|
GET /me/keys | List keys: prefix, name, tier, rpm/daily limits, monthly ₹ budget, spend this month, last used. |
POST /me/keys | Mint a key — name?, budget_inr?, expires_days? (1–365). The full key is shown exactly once. |
PATCH /me/keys/:id | Update rpm_limit, daily_limit, budget_inr (owner/admin). Takes effect within 60 s. |
DELETE /me/keys/:id | Revoke a key (owner/admin). Effective within 60 s. |
Full guide on the BYOK page.
| Endpoint | What it does |
|---|---|
GET /me/byok | Providers that accept BYOK + your saved keys (masked). |
PUT /me/byok/:provider | Save or replace a provider key — key, label?, always_use? (owner). Verified live, encrypted at rest; models are discovered on save. |
POST /me/byok/:provider/test | Re-verify a saved key: ok / rejected / unreachable (owner). |
GET /me/byok/:provider/models | Models discovered with your key, addressable as provider/model-id. |
DELETE /me/byok/:provider | Remove the saved key (owner). |
Full semantics on Credits & billing.
| Endpoint | What it does |
|---|---|
GET /me/billing | Balance (₹), low-balance threshold, money-event ledger, payments, 30-day usage, billing address. |
POST /me/billing/address | Set the billing address (required before the first top-up, for GST place-of-supply) (owner). |
GET /me/billing/pincode/:pin | India Post PIN lookup → city/state autofill. |
POST /me/billing/orders | Create a Razorpay order — amount_inr (whole ₹, 100–100000 in beta), promo_code? (owner). |
POST /me/billing/verify | Verify checkout signature and credit the balance (idempotent) (owner). |
POST /me/billing/promo/check | Validate a promo code before paying (owner). |
POST /me/billing/settings | Set or clear the low-balance email threshold (₹) (owner). |
GET /me/billing/receipts/:paymentId | Printable HTML payment receipt (owner). |
GET /me/invoices | List GST tax invoices (B2C) — one per captured top-up, with invoice number and download link. |
GET /me/invoices/:paymentId | One invoice as printable HTML (CGST/SGST or IGST, SAC 998315, gapless number). |
GET /me/billing/profile | Read the org's billing/GST profile. |
POST /me/billing/profile | Set the billing/GST profile (owner). B2B GSTIN invoicing is gated until IRN/e-invoicing is enabled. |
POST /me/billing/validate-gstin | Validate a GSTIN and derive PAN/state for place-of-supply (owner). |
Saved org-wide fallback chains — full guide on Routing.
| Endpoint | What it does |
|---|---|
GET /me/routing | List saved chains; GET /me/routing/:model for one. |
PUT /me/routing/:model | Save/replace a model's chain — steps (1–10) (owner/admin). |
DELETE /me/routing/:model | Remove it; routing returns to default (owner/admin). |
Full guide on Collections.
| Endpoint | What it does |
|---|---|
GET /me/collections | Your org's collections (private + public + forked). |
POST /me/collections | Create — name, model, steps, readme_md?, public? (owner/admin). |
PATCH /me/collections/:id · DELETE /me/collections/:id | Edit (bumps version) or delete (owner/admin). |
POST /me/collections/star/:slug | Toggle a star (one per org). |
POST /me/collections/fork/:slug | Fork a public collection into your org. |
POST /me/collections/import/:slug | Fork-if-foreign, then apply as your routing (owner/admin). |
Full guide on Bring your own endpoint.
| Endpoint | What it does |
|---|---|
GET /me/endpoints | List registered endpoints (keys masked, with compliance status). |
POST /me/endpoints | Register + compliance-test inline (owner/admin). |
POST /me/endpoints/test | Compliance-test an unsaved config (no write). |
POST /me/endpoints/:id/retest · DELETE /me/endpoints/:id | Re-test or remove (owner/admin). |
Full guide on Reliability monitoring.
| Endpoint | What it does |
|---|---|
POST /me/collections/:slug/monitor | Toggle monitoring on/off (monitored) (owner/admin). |
POST /me/collections/:slug/check | Canary every step now and return fresh health. |
GET /me/collections/:slug/health | Per-step uptime + p95 latency + last canary (?days= 1–90, default 7). |
GET/POST /me/collections/:slug/alerts · DELETE …/alerts/:id | List, create or remove alerts on error_rate/latency_p95 → email/webhook (owner/admin to mutate). |
Full guide on Teams & workspaces.
| Endpoint | What it does |
|---|---|
GET /me/orgs · POST /me/orgs · POST /me/orgs/switch | List orgs, create a team org, switch active org. |
GET /me/members · POST /me/members | List members + pending; invite by email + role (owner/admin). |
PATCH /me/members/:id · DELETE /me/members/:id | Change 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/:id | List/create workspaces; PATCH renames or sets a monthly_budget_inr cap; DELETE archives (owner/admin to mutate). |
Full guide on Usage, activity & rankings.
| Endpoint | What it does |
|---|---|
GET /me/usage | Per-key requests and tokens, today (IST) and last 30 days. |
GET /me/usage/daily | Last 30 days grouped by day and model — powers the dashboard chart. |
GET /me/activity | Spend/volume aggregates over a date range — day×model, top models/keys, per-provider cost split. |
GET /me/activity/events | Per-request drill-down, newest first, keyset-paginated. |
POST /me/attribution | One-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. |
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.
| Endpoint | What 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". |
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.
| Endpoint | What 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.
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.
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.
| Endpoint | What 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. |
| Path | Who reads | Who writes |
|---|---|---|
org/records/ | Everyone in the org | Promotion only (admin) |
workspaces/<ws>/records/ | Workspace team | Promotion only (admin) |
workspaces/<ws>/journal/ | Workspace team | Workspace team (TTL'd) |
shared/<space>/ | Share owner + granted same-org members | Share owner + granted same-org members |
users/<uid>/ | Owner only | Owner only |
agents/ | Any key in the org | Any 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 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.
| Endpoint | What it does |
|---|---|
GET /v1/me/memory/shares | List shares the caller owns or belongs to, including owner/member UIDs and the caller's role. |
POST /v1/me/memory/shares | Create {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/:uid | Grant a live member of the same org (owner or org owner/admin; idempotent). |
DELETE /v1/me/memory/shares/:space/members/:uid | Revoke one member immediately; safe to repeat. The owner cannot be revoked. |
DELETE /v1/me/memory/shares/:space | Retire the share and delete its grants (share owner or org owner/admin). Stored objects are not silently purged; the logical space remains permanently reserved. |
| Endpoint | What it does |
|---|---|
GET /v1/me/memory/paths | Your 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_mb → 413. |
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.
| Endpoint | Notes |
|---|---|
POST /webhooks/razorpay | Razorpay events (payment.captured, payment.failed), verified via the x-razorpay-signature HMAC header. Crediting is idempotent across webhook and checkout-verify paths. |
| Header | Meaning |
|---|---|
x-br-provider | Provider that served the request (e.g. krutrim, bharatrouter). |
retry-after | On 429 responses: seconds to wait before retrying. |
| Limit | Value |
|---|---|
| Gateway rate limit | 120 requests/min per key (or per IP when unauthenticated). |
| Trial keys | 60 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.