Batchrouter Docs

How routing works

How Batchrouter scores provider lanes on price, SLA, capacity, and tools, selects one or more lanes per batch, and records rejection receipts.

Not open yet

Sign-up is not open yet. The API routes for batches, chat completions and the OpenAI-compatible endpoints are not yet available.

Batchrouter is a control plane between your batch and many AI providers. You submit one job; Batchrouter decides which provider lane (or lanes) actually run it. That decision is computed at quote time, is explainable, and is recorded so you can audit why a lane was chosen or rejected.

This page explains the routing pipeline conceptually — what a "lane" is, how lanes are scored and selected, why one batch can split across several lanes, and what the rejection codes mean. For the request/response field details, see the interactive API reference.

Lanes: the unit of routing

A lane is one concrete way to run part of your batch: a specific provider, on a specific model offering version, with its own price, capacity, SLA window, and region.

The key idea is that one customer batch is not necessarily one lane. You keep a single batch_id and a single set of results, but internally Batchrouter may execute your items across several lanes. A quote therefore returns a set of quote_lanes: each lane is flagged selected or not, and every non-selected lane (filtered out, or eligible-looking but not chosen) carries a rejection_code, a customer-safe rejection_reason, and a rejection_receipt explaining why. After a batch settles, the dedicated rejected_lanes array appears on the billing and usage receipts.

By default you do not address a lane. You express requirements (model, SLA, region, tools, price ceiling) and, if you want, provider preferences, and Batchrouter resolves those into lanes. This keeps your integration stable even as providers, prices, and capacity change underneath you. Each lane has a stable lane_id, listed on the model catalog and on quote lanes.

The pipeline

Routing happens when you create a quote (POST /v1/quotes/model) and is re-checked when you submit the batch (POST /v1/batches). It runs in two stages: hard gates first, then scoring.

  1. Preflight validation. Before any provider is considered, Batchrouter validates the request shape: JSONL/item shape, file types, context-window fit, JSON-schema/runtime capability, and webhook configuration. Failures return 400 with the problem under error.details.preflight, so you fix them before spending credits.

  2. Hard gates (eligibility). Each candidate lane must pass every gate to be considered at all. A lane is gated out if the provider does not support the requested task type or model, lacks the rate-limit capacity to finish inside the window, fails your region or provider-preference constraints (including data_collection and zdr), is paused or unhealthy, or is priced above your max_price. Lanes that fail a gate become non-selected lanes with a rejection code (see below).

  3. Scoring (ranking). Surviving lanes are ranked. For direct routes, price is the dominant factor after the gates — the default outcome is the cheapest eligible lane. Scoring also weighs declared and observed capacity, estimated completion time, historical SLA adherence, recent error/retry/timeout rates, result-validation success, and provider trust tier.

  4. Selection. The top-ranked lane(s) win. The selected lanes, the estimated price, the expected completion window, and a routing explanation come back in the quote.

  5. Splitting (when needed). If no single lane can finish the whole batch in time — or splitting lowers price or reduces risk and you allow it — Batchrouter assigns different items to different lanes under the same batch_id. See Multi-lane splitting.

Creating a quote is free. Credits are only reserved when you accept a quote by creating a batch, and the final charge is settled from actual provider token usage. Quote first, inspect the lanes and the explanation, then submit. See Quotes and pricing.

The SLA and deadlines

Every batch runs on the SLA tier you choose with sla_tier: Priority (4 hours), Standard (24 hours, the default), Relaxed (48), Flex (72) or Economy (7 days). Realtime direct requests are best effort. The window is what the router has to honor, which in turn affects which lanes are eligible (a provider whose processing window can't finish inside the deadline is gated out).

sla_tier accepts priority, standard, relaxed, flex and economy. A slower tier gives the router more room and costs less; only lanes that take that tier are considered.

Batch work goes to lanes that take whole batches. A provider lane that serves chat completions only gets direct requests, not batch work.

A batch carries a 24-hour SLA deadline. Standard built-in lanes (e.g. OpenAI and Anthropic native batch) run on a 24-hour window; most other providers run on a tighter provider-side processing window staged inside your customer SLA, which leaves room for retries and fallback before your deadline. You can read the deadline back from GET /v1/batches/{batchId}.

Multi-lane splitting

Because your batch is decoupled from any single provider, Batchrouter can split execution across lanes while you keep one batch_id and one result set. Splitting happens when:

  • the cheapest lane can't finish the whole batch inside the SLA window,
  • you've allowed splitting and it lowers the total price,
  • splitting reduces execution risk for a large job, or
  • an accepted lane becomes unavailable before dispatch.

Mixed-model submissions split naturally: items targeting different models become model-specific lanes under the one batch. When you poll GET /v1/batches/{batchId}, per-lane statuses are exposed so you can see how each internal execution is progressing.

Rejection receipts

Every lane that was considered but not selected is recorded with a normalized, machine-readable rejection_code, a customer-safe rejection_reason, and a persisted rejection_receipt. This is what makes routing explainable: you can see why a cheaper or closer lane didn't win.

Common rejection codes include:

CodeMeaning
capacity_fullThe lane had no available capacity to reserve for your work.
context_window_exceededYour items don't fit the lane's model context window.
region_unavailableThe lane's provider doesn't match your allowed_regions. A provider that declares the countries it runs in must have every one of them covered by your list. A provider that declares no region (one marked only global) takes work with no region restriction and nothing else. See Region matching.
stale_heartbeatThe lane's live-capacity heartbeat was too stale to treat as routable supply.

If hard gates eliminate every lane — for example, no eligible lane fits under your max_price, or no lane declares a required tool — quote creation fails rather than routing to a lane that doesn't meet your requirements. The rejection receipts on the failed quote tell you which constraint to relax. See the full code list in the API reference.

Region matching

allowed_regions limits which providers can take your work. It accepts global, EU, EEA, and any country by its two-letter ISO 3166-1 alpha-2 code in upper case, such as DE, SA or GB (UK is not a code of the standard: use GB). Leave it out, or include global, and any provider can take the work.

When you restrict regions, the check depends on the provider:

  • Providers that declare countries. A registered provider declares the country or countries it runs inference in (processing_countries). It gets region-restricted work only when your list covers every one of those countries, by name or through a group such as EU. A provider in Germany and France takes ["EU"] work but not ["DE"] work. A provider in Germany and China takes only unrestricted work.
  • Providers without declared countries. Built-in providers, and registered providers that have not declared countries yet, match when their region tags name a region your list names. A provider that lists only global says nothing about where it runs, so it takes work with no region restriction and no work restricted to a region.

Regions are what providers declare. Batchrouter routes by them but does not audit them, so allowed_regions is not an enforced residency guarantee.

A provider that runs in one country, say Saudi Arabia, takes work restricted to ["SA"] and work with no restriction. You can name any country a provider can declare, so a country is never out of reach.

A region nobody runs in yet

You can name a country before any provider runs inference there. Batchrouter doesn't reject the value, but work restricted to a region no provider declares has nowhere to go: a provider that doesn't declare a region takes no region-restricted work. A quote or batch for it is refused with a 400 batch preflight failure, and Batchrouter says why:

  • GET /v1/regions/coverage?allowed_regions=SA answers covered: false with a no_provider_in_region warning, so a form can show it before you submit.
  • The refused request carries the same warning under error.details.preflight.warnings.
{
  "allowed_regions": ["SA"],
  "covered": false,
  "warnings": [
    {
      "category": "routing",
      "code": "no_provider_in_region",
      "message": "No provider runs inference in Saudi Arabia yet, so work restricted to it can't be placed until one does.",
      "action": "Name another region, or use global to let any provider take the work. Work restricted to these regions can be placed as soon as a provider runs inference there.",
      "details": { "uncovered_regions": ["SA"] }
    }
  ]
}

The note goes away as soon as a provider that declares running inference within your regions is live. It covers where providers run, not whether a model is available: model and capacity are still checked by routing, so a region with a provider can still refuse a model that provider doesn't serve.

Fallback stays inside your regions too. Behind the open-weight batch windows Batchrouter normally keeps an instant fallback in reserve. A provider outside your regions can't take that stage, so for region-restricted work it is used only when a provider inside them serves it. Otherwise the work runs on the batch windows alone.

To choose the order in which regions are tried when work falls back, see Choose who comes next.

Fallback

Routing doesn't stop at the first dispatch. If a selected lane fails, Batchrouter applies the configured fallback policy to keep the batch inside its SLA: it can re-contract the same provider within the window, hand the work to the next-best eligible lane, or fall back to a designated fallback provider for the same quoted model set when policy allows. Fallback is bounded by your original requirements — a fallback lane still has to pass the same hard gates (price ceiling, region, tools), so it never quietly violates a constraint you set.

Choose who comes next

By default work falls back to the next-best eligible lane. provider_preferences.fallback lets you rank what comes after the first choice, by region, by provider, or both:

{
  "allowed_regions": ["SA", "AE", "EU"],
  "provider_preferences": {
    "fallback": {
      "regions": ["SA", "AE", "EU"],
      "providers": ["acme"]
    }
  }
}

The first choice is picked exactly as without it. If it fails, the work goes to acme first, then to a provider running inside Saudi Arabia, then the UAE, then the EU, and then to anyone else eligible, ranked as before. Both lists are optional and take up to eight entries. Regions use the same names as allowed_regions: global, EU, EEA, or an ISO 3166-1 alpha-2 country code in upper case such as GB. Providers are slugs.

How it fits with your other settings:

  • It ranks, it never widens. allowed_regions, only and ignore still decide what may take your work, so a fallback never leaves your regions or your only list. To fall back to nothing but a few regions or providers, restrict with allowed_regions or only and use fallback for the order.
  • Order of precedence. order ranks first (as it always did), then fallback.providers in the order you list them, then fallback.regions, then everyone else as before. A provider belongs to the first region in your list that it runs inside, and EU stands for its 27 member countries.
  • The first choice does not move. fallback only orders what follows it. To pin the first choice, use order or only.
  • Fallbacks off wins. With allow_fallbacks: false nothing falls back, so fallback is not applied and the quote says so.
  • The chain keeps its length. Inside the 24-hour SLA a batch has one fallback batch window and the instant-fallback stage, so your lists decide who fills them, and who is next when an entry is not eligible. The instant-fallback stage follows your order too: a provider running in a region you listed comes before one that does not. A first choice on a native batch window (OpenAI, Anthropic) has no fallback stage, so the lists do not apply to it.

An entry that places nobody is skipped, never an error. The quote tells you which, in routing_notices:

{
  "routing_notices": [
    {
      "code": "fallback_entry_skipped",
      "kind": "region",
      "value": "AE",
      "reason": "no_eligible_provider",
      "message": "Fallback region ae (United Arab Emirates) was skipped: no other eligible provider runs inference there."
    }
  ]
}
reasonMeaning
no_eligible_providerNo provider other than the first choice runs in that region.
outside_allowed_regionsThe region shares no country with your allowed_regions, so no provider there can take the work.
not_eligibleA provider you listed cannot take this work (excluded by only or ignore, region or health, or it does not serve the model).

The chain itself is on each work unit of the quote, in route_decision.fallback_ranking, and in the route receipt. It lines up with fallback_order and says for each position what placed it:

{
  "fallback_order": ["de_a", "acme", "sa_c"],
  "fallback_ranking": {
    "chain": [
      { "provider": "de_a", "role": "first_choice", "placed_by": "routing", "matched": null },
      { "provider": "acme", "role": "fallback", "placed_by": "listed_provider", "matched": "acme" },
      { "provider": "sa_c", "role": "fallback", "placed_by": "listed_region", "matched": "SA" }
    ],
    "skipped": [{ "kind": "region", "value": "AE", "reason": "no_eligible_provider" }]
  }
}

A request without fallback routes exactly as before and carries none of this.

Next steps