Quickstart
Go from zero to your first completed batch on Batchrouter — create an API key, get a free quote, submit a batch, poll status, and retrieve results.
Not open yet
Batchrouter is an OpenAI-Batch-compatible API that routes batch AI workloads across many providers, picking the cheapest lane that meets your SLA and tool requirements — with a routing receipt for every decision. This page takes you from zero to your first completed batch in five steps.
For a batch, the flow is: quote (free) → create → poll → results. Quotes cost nothing; credits are reserved only when you create a batch and settled from actual token usage. For a single request that needs an answer right away, call POST /v1/chat/completions instead. See Chat completions.
Before you start
You'll need an API key and a small credit balance. You create the account in the app once sign-up opens — see Account and sign-in. The base URL is https://api.batchrouter.com, and every endpoint lives under /v1. Authenticate by sending your key as a bearer token:
export BATCHROUTER_API_KEY="br_live_…"curl https://api.batchrouter.com/v1/auth/account \
-H "Authorization: Bearer $BATCHROUTER_API_KEY"That call returns your account, including credit_balance. If it's zero, you'll get a 402 on create — add credits from the billing dashboard.
Keep keys server-side
API keys are secrets. Send them only from your backend, never from browsers or mobile clients, and store them in a secrets manager or environment variable.
Walkthrough
-
Create an API key.
Once sign-up opens, create a key in the dashboard.
Keys are shown once
A new key's full value is returned only at creation time and is never shown again. Copy it immediately and store it securely; if you lose it, create a new one and revoke the old.
See Authentication for both paths and key rotation.
-
Get a free quote.
Send your items to
POST /v1/quotes/model. Batchrouter prices the work, picks a lane, and returns aquote_id(qlock_…) plus a per-lane breakdown. Quoting is free and reserves nothing.curl https://api.batchrouter.com/v1/quotes/model \ -H "Authorization: Bearer $BATCHROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "items": [ { "customer_item_id": "item-1", "operation": "chat.completions", "model": "gpt-5.4-mini", "input": { "messages": [ { "role": "user", "content": "Summarize: Batchrouter routes batch-AI workloads across providers." } ] } } ] }'The response includes
quote_id, apricing_estimate(provider_subtotal,batchrouter_fee,customer_discount,total), the selectedquote_lanes, and a plain-languagecustomer_explanation. Unselected lanes come back with rejection reasons such ascapacity_fullorcontext_window_exceeded.Use a model from the live catalog
gpt-5.4-miniis a live catalog model id. Models change, so list the currently-available ones withGET /v1/catalog/models, which also returns per-provider pricing, capacity, and regions. -
Submit your first batch.
Pass the
quote_idtoPOST /v1/batchesand include anIdempotency-Keyheader (8–128 chars) so retries never create a duplicate. A202means it's accepted and queued.curl https://api.batchrouter.com/v1/batches \ -H "Authorization: Bearer $BATCHROUTER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: quickstart-batch-001" \ -d '{ "quote_id": "qlock_…", "sla_tier": "standard", "items": [ { "customer_item_id": "item-1", "operation": "chat.completions", "model": "gpt-5.4-mini", "input": { "messages": [ { "role": "user", "content": "Summarize: Batchrouter routes batch-AI workloads across providers." } ] } } ] }'The response is
{ "batch": { "id": "batch_…", "state": "priced", "counts": { "total": 1, … } } }.Free quote, credits reserved at create
Quotes are free. Credits are reserved when this
POST /v1/batchescall succeeds (using the quote snapshot) and settled afterward from actual provider token usage. A zero balance returns402— add credits from the billing dashboard. -
Poll for status.
Fetch the batch until it reaches a terminal state. Add
?include_billing_receipt=trueonce it's done to see the final cost.curl "https://api.batchrouter.com/v1/batches/batch_…" \ -H "Authorization: Bearer $BATCHROUTER_API_KEY"statemoves through this lifecycle:received→validated→priced→queued→dispatching→running→finalizing→completedTerminal states are
completed,failed,canceled, andexpired. Poll on an interval (e.g. every 30–60s); to avoid polling entirely, attach a webhook at create time. -
Retrieve your results.
Once
stateiscompleted, read the output.GET /v1/batches/{batchId}/resultsreturns one entry per item, paginated.curl "https://api.batchrouter.com/v1/batches/batch_…/results?limit=100" \ -H "Authorization: Bearer $BATCHROUTER_API_KEY"Each result has
customer_item_id,status(completedorfailed),output, anderror. Page with?cursor=<next_cursor>(limit 1–1000, default 100). For large batches, preferGET /v1/batches/{batchId}/artifact-url, which returns a short-lived signedurlto the full JSONL artifact instead of paginating.Choose your output shape
Results are
normalized(Batchrouter's unified schema) by default. Requestbody_format=rawto get each provider's native output instead.
That's a complete batch, end to end. From here, scale up with file uploads, point an existing OpenAI Batch client at Batchrouter, or switch from polling to webhooks.
Where to next
Submit a batch
Inline vs. file inputs and idempotency in depth.
OpenAI compatibility
Point your existing OpenAI Batch client's base URL at Batchrouter and keep your code.
Webhooks & delivery
Get signed completion events instead of polling, and verify the X-BatchRouter-Signature.
API reference
Every endpoint, parameter, and schema for the public /v1 surface.