Skip to content

Documentation

Quote jobs, create batches, fetch artifacts, and manage credits.

What the platform isBatchRouter is a batch AI routing marketplace. It validates manifests, quotes model or workflow routes, reserves credits, dispatches work through provider adapters, and returns finished artifacts.
Batches
The top-level customer object after quote acceptance: manifest input, workflow contract when present, routed work units, route receipts, artifacts, and billing receipt.
Routing advantage
Jobs that can wait minutes or hours can be quoted, split into work units, routed through eligible provider lanes, retried, verified, and delivered through cheaper acceptable supply.
Provider offerings
The model catalog, provider directory, and settled-demand rankings show coverage, price, privacy posture, and real traffic.
Funding
Customer orgs hold prepaid USD credits. Quote and submit both check balance before new work is accepted.
Execution
Submitted batches are decomposed into work units, evaluated against eligible lanes, assigned provider executions, and finalized into result rows and files.
Learning loop
Routing data, quality feedback, trust signals, and provider performance make recurring workflows smarter over time.
Workflow productsWorkflow products are curated batch job types. Customers buy the outcome while BatchRouter chooses the provider and model mix behind the accepted quote.
GET
/v1/catalog/workflow-products

List packaged workflow products with their preset manifests, default route products, artifact expectations, webhook contract, and success SLA.

GET
/v1/catalog/workflow-products/:slug

Fetch one workflow product when you want to render or automate a specific packaged job.

Preset manifest
The starting job shape a team can quote and run immediately, then customize later.
Routing posture
A named policy that captures cost, privacy, SLA, fallback, and quality defaults for the workflow.
Artifact contract
Documented result and exception file shapes so downstream teams know what the platform will return.
Webhook contract
A stable callback that tells downstream systems when to fetch the signed artifact URLs.
Acceptance checks
A documented acceptance posture for when the batch is considered done and ready for handoff.
Start in the browserUse the browser console for account setup and manual testing before you integrate the API.
1. Create an account
Use the signup flow
2. Verify email
Email verification is required before password login is allowed.
Agent quickstartRegister, verify, and submit your first batch job via curl. No browser required.
1. Register
POST /v1/auth/agent-register with agent_name, email, and password. No browser or CAPTCHA needed.
2. Verify email
Click the verification link or POST /v1/auth/verify-email with the token from the email.
3. Create API key
POST /v1/api-keys with your session token to get a long-lived ob_live_ key.
4. Submit a batch
POST /v1/batches with Authorization: Bearer ob_live_… and your manifest. Add a webhook_url to receive results push-delivered to your endpoint.
5. Receive results
BatchRouter POSTs the completed event and signed artifact URLs to your webhook. Alternatively, poll GET /v1/batches/:id until state is completed.
API quickstartGenerate an API key in the console, then use the same manifest to quote, submit, poll a batch, and read its optimization report. This is the safe migration path from existing async AI jobs into managed batch routing.
3. Quote and submit
Send Authorization: Bearer <your key> to quote the manifest and then create the batch.
5. Read migration report
Fetch the optimization_report to compare baseline trend, optimized trend, savings realized, quality drift, fallbacks, and verification failures.
6. Poll results
Read batch state until completion, then fetch result rows, route receipts, or signed artifact files.
export BASE_URL="https://api.batchrouter.com"
export OB_API_KEY="ob_live_your_api_key"
export MANIFEST='{"sla_tier":"standard","routing_mode":"sla_aware","privacy_tier":"standard","allowed_regions":["global"],"items":[{"customer_item_id":"support_rollup_001","operation":"responses","model":"gpt-5.4-mini","model_options":["gpt-5.4-mini","gpt-5.4"],"input":{"input":[{"role":"user","content":"Summarize yesterday'\''s support queue into five bullets."}]}}]}'
export CREATE_PAYLOAD='{"quote_id":"qlock_replace_with_quote_id","sla_tier":"standard","routing_mode":"sla_aware","privacy_tier":"standard","allowed_regions":["global"],"items":[{"customer_item_id":"support_rollup_001","operation":"responses","model":"gpt-5.4-mini","model_options":["gpt-5.4-mini","gpt-5.4"],"input":{"input":[{"role":"user","content":"Summarize yesterday'\''s support queue into five bullets."}]}}]}'

# Lock the price first. Copy quote_id from the response into CREATE_PAYLOAD.
curl -sS "$BASE_URL/v1/quotes/model" \
  -X POST \
  -H "Authorization: Bearer $OB_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$MANIFEST"

# Replace qlock_replace_with_quote_id before creating the paid batch.
curl -sS "$BASE_URL/v1/batches" \
  -X POST \
  -H "Authorization: Bearer $OB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-batch-001" \
  -d "$CREATE_PAYLOAD"

curl -sS "$BASE_URL/v1/batches/{batch_id}" \
  -H "Authorization: Bearer $OB_API_KEY"

curl -sS "$BASE_URL/v1/batches/{batch_id}/results" \
  -H "Authorization: Bearer $OB_API_KEY"

curl -sS "$BASE_URL/v1/batches/{batch_id}/artifact-url?kind=output" \
  -H "Authorization: Bearer $OB_API_KEY"

curl -sS "$BASE_URL/v1/batches/optimization-report?import_provider=openai" \
  -H "Authorization: Bearer $OB_API_KEY"
Automate workflows with the APIUse the API when a workflow should run from your own scheduler, queue, integration platform, or data pipeline instead of the browser UI.
Quote before create
Call /v1/quotes/model or /v1/quotes/workflow with the exact manifest your job runner will submit, then pass the accepted quote_id to /v1/batches.
Choose workflow shape
Start from a curated workflow product, or submit a custom manifest with one model or a model_options set. The platform resolves custom model sets to the cheapest compliant route inside the accepted quote window.
Submit idempotently
Send /v1/batches with a stable Idempotency-Key per scheduled run so retries do not create duplicate batches.
Use webhooks or polling
Add a delivery webhook for event-driven systems, or poll /v1/batches/:id until the batch reaches completed, failed, or canceled.
Fetch durable output
Read /v1/batches/:id/results for normalized rows, or use signed artifact URLs when your downstream system expects files.
Keep the UI as fallback
The console remains useful for account setup, API key rotation, billing, manual reruns, and inspecting failed batches.
const BASE_URL = "https://api.batchrouter.com";
const API_KEY = process.env.BATCHROUTER_API_KEY ?? "ob_live_your_api_key";

const manifest = {
  sla_tier: "standard",
  routing_mode: "sla_aware",
  privacy_tier: "standard",
  allowed_regions: ["global"],
  webhook: {
    url: "https://example.com/batchrouter/webhook",
    secret: "whsec_replace_with_real_secret"
  },
  items: [
    {
      customer_item_id: "ticket_digest_001",
      operation: "responses",
      model: "gpt-5.4-mini",
      model_options: ["gpt-5.4-mini", "gpt-5.4"],
      input: {
        input: [
          {
            role: "user",
            content: "Summarize today's open support tickets into priorities."
          }
        ]
      }
    }
  ]
};

async function batchrouter(path, options = {}) {
  const response = await fetch(`${BASE_URL}${path}`, {
    ...options,
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
      ...options.headers
    }
  });
  const body = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(body));
  return body;
}

const quote = await batchrouter("/v1/quotes/model", {
  method: "POST",
  body: JSON.stringify(manifest)
});

console.log("quoted", quote.pricing_estimate?.total ?? quote.pricingEstimate?.total);

const created = await batchrouter("/v1/batches", {
  method: "POST",
  headers: { "Idempotency-Key": "support-digest-" + new Date().toISOString().slice(0, 10) },
  body: JSON.stringify({ ...manifest, quote_id: quote.quote_id })
});

let batch = created.batch ?? created;
while (!["completed", "failed", "canceled", "expired"].includes(batch.state)) {
  await new Promise((resolve) => setTimeout(resolve, 30_000));
  const status = await batchrouter(`/v1/batches/${batch.id}`, { method: "GET" });
  batch = status.batch ?? status;
}

if (batch.state !== "completed") {
  throw new Error(`Batch ended as ${batch.state}`);
}

const results = await batchrouter(`/v1/batches/${batch.id}/results`, { method: "GET" });
console.log(results);
Submit your first batchThe core API flow turns async demand into a settled artifact: validate and quote the manifest, create the batch, poll status, then fetch rows, route receipts, or files after completion.
POST
/v1/quotes/model

Validate the manifest, resolve custom model_options, select provider lanes, and return a locked quote_id with pricing totals.

POST
/v1/batches

Submit the batch with the accepted quote_id. The route reserves the quote immediately and returns 402 insufficient_credits when available balance is too low.

Example manifest
{
  "sla_tier": "standard",
  "routing_mode": "public_only",
  "privacy_tier": "standard",
  "allowed_regions": [
    "global"
  ],
  "items": [
    {
      "customer_item_id": "support_rollup_001",
      "operation": "responses",
      "model": "gpt-5.4-mini",
      "model_options": [
        "gpt-5.4-mini",
        "gpt-5.4"
      ],
      "input": {
        "input": [
          {
            "role": "user",
            "content": "Summarize yesterday's support queue into five bullets."
          }
        ]
      }
    }
  ]
}
Example funding preview
{
  "available": {
    "amount": "14.60",
    "currency": "usd"
  },
  "reserved": {
    "amount": "4.25",
    "currency": "usd"
  },
  "quote_total": {
    "amount": "0.42",
    "currency": "usd"
  },
  "shortfall": {
    "amount": "0.00",
    "currency": "usd"
  },
  "can_fund": true
}
Example route decision preview
{
  "selected_provider": "openai",
  "quality_score": 0.92,
  "reliability_prior_score": 0.985,
  "observed_confidence_score": 0.971,
  "observed_confidence_basis": "routing_outcomes",
  "trust_score": 0.971,
  "fallback_order": [
    "openai"
  ],
  "rejected_providers": []
}
reliability_prior_score
Static 0 to 1 provider prior used for cold-start routing before enough real execution telemetry exists.
observed_confidence_score
Telemetry-adjusted 0 to 1 confidence score once the provider has enough matching execution or market samples. It is null when there is no usable observed data yet.
observed_confidence_basis
Explains which telemetry informed observed_confidence_score: none, routing_outcomes, market_performance, or routing_outcomes_and_market_performance.
trust_score
Backward-compatible effective confidence field. It equals observed_confidence_score when telemetry exists, otherwise reliability_prior_score.
GET
/v1/batches/:id

Return batch state, work units, pricing estimate, route version, deadline, route receipt link, and provider execution summary.

GET
/v1/batches/:id/results

Return normalized per-item output rows after completion. Use file endpoints when you want bulk output or error artifacts.

GET
/v1/batches/:id/feedback

Read the current customer-quality signal and the provider attribution slice that similar workloads will learn from.

PUT
/v1/batches/:id/feedback

Record business-quality feedback after review so routing can learn which providers actually create value for this workload.

GET
/v1/batches/optimization-report

Generate the imported OpenAI or Anthropic optimization_report: baseline cost trend, optimized cost trend, savings realized, provider quality drift, fallback frequency, verification failures, and recommended next route change.

GET
/v1/files/:id

Download a signed artifact generated from finalized batch output, route receipt, review, or error files.

Credits and billingCustomer spend is prepaid. Quote checks available balance, submission reserves estimated spend, and finalization settles against actual usage.
GET
/v1/billing/credits

Return billing profile, available credit packs, balance summary, recent ledger entries, reservations, and top-ups for the current org.

PUT
/v1/billing/profile

Update the billing email reused for hosted checkout sessions.

POST
/v1/billing/checkout-sessions

Create a hosted Stripe Checkout Session for a fixed credit pack for the authenticated org.

GET
/v1/billing/checkout-sessions/:id

Read checkout status on the return path so the UI can confirm when credits were posted by the webhook.

Hosted checkout request
{
  "pack_code": "credit_25"
}
Auth and sessionsCustomer auth is email-and-password with verification and reset flows. Browser usage relies on session cookies. Direct API usage relies on customer API keys.
POST
/v1/auth/register

Create a new customer user and org, then send a verification email through Resend.

POST
/v1/auth/login

Authenticate a verified customer email and issue a browser session cookie.

POST
/v1/auth/password/forgot

Request a password reset email. The reset flow invalidates older user sessions after completion.

GET
/v1/sessions/current

Return the current browser session, actor type, auth method, org, and capabilities, or null when no session is active.

Catalog surfaces and public APIsWorkflow products are the main discovery path. The model catalog and provider directory expose available models, and settled-demand rankings show where real batch work is flowing.
GET
/v1/catalog/workflow-products

List workflow-level packages when you want to start from a finished job shape instead of a model profile.

GET
/v1/catalog/models

List public model profiles when you need coverage, price, privacy, and routing detail after the workflow shape is already clear.

GET
/v1/catalog/workflow-products/:slug

Fetch one workflow product by slug, including its preset manifest and delivery contract.

GET
/v1/catalog/models/:slug

Fetch one model profile when you need a deeper provider, routing, or example-manifest reference.

GET
/v1/catalog/rankings

Return public settled-demand signals for workflow products and models, filtered by time window, provider, and operation. Most useful once live production traffic exists.

GET
/v1/runtime

Return runtime capability flags so the frontend can expose when email, checkout, or other optional features are unavailable.