🎬 New — watch the 2-minute guide videos →

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 the four BharatRouter extensions (optimize, provider, data_policy, upstream_key) — 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": "krutrim-2",
    "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": "krutrim-2",
  "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/embeddings

OpenAI-compatible embeddings with the same extensions, routing, and failover as chat.

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" }'

Audio

Self-hosted speech models — full guide on the Audio page.

EndpointWhat it does
POST /v1/audio/transcriptionsSpeech → text (multipart, whisper-large-v3, ≤25 MB). Billed per minute of audio.
POST /v1/audio/speechText → speech (kokoro-82m, Hindi voices). Billed per 1M input characters.

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=="krutrim-2")'

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. Max 5 active keys per org in beta.
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–1000 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).

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.

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, vllm).
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).
Active keys per org5 (beta).
Top-up₹100–₹1,000 per transaction (beta).

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