Batchrouter Docs
Get started

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

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

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

  1. 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.

  2. Get a free quote.

    Send your items to POST /v1/quotes/model. Batchrouter prices the work, picks a lane, and returns a quote_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, a pricing_estimate (provider_subtotal, batchrouter_fee, customer_discount, total), the selected quote_lanes, and a plain-language customer_explanation. Unselected lanes come back with rejection reasons such as capacity_full or context_window_exceeded.

    Use a model from the live catalog

    gpt-5.4-mini is a live catalog model id. Models change, so list the currently-available ones with GET /v1/catalog/models, which also returns per-provider pricing, capacity, and regions.

  3. Submit your first batch.

    Pass the quote_id to POST /v1/batches and include an Idempotency-Key header (8–128 chars) so retries never create a duplicate. A 202 means 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/batches call succeeds (using the quote snapshot) and settled afterward from actual provider token usage. A zero balance returns 402 — add credits from the billing dashboard.

  4. Poll for status.

    Fetch the batch until it reaches a terminal state. Add ?include_billing_receipt=true once it's done to see the final cost.

    curl "https://api.batchrouter.com/v1/batches/batch_…" \
      -H "Authorization: Bearer $BATCHROUTER_API_KEY"

    state moves through this lifecycle:

    received → validated → priced → queued → dispatching → running → finalizing → completed

    Terminal states are completed, failed, canceled, and expired. Poll on an interval (e.g. every 30–60s); to avoid polling entirely, attach a webhook at create time.

  5. Retrieve your results.

    Once state is completed, read the output. GET /v1/batches/{batchId}/results returns 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 (completed or failed), output, and error. Page with ?cursor=<next_cursor> (limit 1–1000, default 100). For large batches, prefer GET /v1/batches/{batchId}/artifact-url, which returns a short-lived signed url to the full JSONL artifact instead of paginating.

    Choose your output shape

    Results are normalized (Batchrouter's unified schema) by default. Request body_format=raw to 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