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

Never return an error

← Cookbook

Fall through an India-resident route → an open-weight fallback → a global model automatically, with circuit-breaker failover.

Collections + circuit breakersReliabilityIntermediate10 min

A single provider will have a bad five minutes. A Collection is an ordered, versioned chain of {model, provider} steps; the gateway walks it top-to-bottom and serves the first healthy step, tripping a circuit breaker on the ones that fail.

You'll use: saved fallback chains (Collections) + automatic circuit-breaker failover. Reference: Collections.

Define the chain

Create a Collection in the console (or via the API), then call it by slug. The chain below tries an India-resident route first and only reaches for global routes if it fails. Every step runs on your BharatRouter credit — no provider keys needed:

OrderModelProviderWhy
1gemma-4-e4b-itkrutrimCheapest India route, tried first
2llama-3.3-70bgroqOpen-weight fallback (global, runs on credit)
3gpt-oss-120bfireworksGlobal safety net (runs on credit)
from openai import OpenAI

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

r = client.chat.completions.create(
    model="@my-org/resilient-chat",   # your Collection slug
    messages=[{"role": "user", "content": "namaste"}],
)
# x-br-provider tells you which step actually served the request

How failover works

  • A step that errors or times out is skipped; the next step is tried in the same request — your client sees one response, not an error.
  • Repeated failures open that route's circuit breaker, so it is skipped fast until it recovers, instead of adding latency to every call.
  • Collections are versioned and shareable — fork one, tweak the order, publish it back.

Harden it further: add your own endpoint as a ₹0 last step with BYOE, and canary the chain so you're alerted before users notice.

More recipes in the Cookbook, or see the fullAPI reference.