Batch API
Send thousands of requests at once and collect the results within 24 hours, at half the usual price. Batches run on the provider's own batch service, and you get the provider's full discount.
| Field | Type | Description |
|---|---|---|
| OpenAI format | /v1/files + /v1/batches | OpenAI, Google (Gemini), Mistral and Qwen models, each on that provider's own batch service. Up to 50,000 requests or 200 MB per batch. |
| Anthropic format | /v1/messages/batches | Claude models, on Anthropic's Message Batches API. Up to 100,000 requests or 256 MB per batch. Results kept 29 days. |
Every provider bills batch tokens at 50% of the standard price, and the full discount is passed on. Requests that fail, expire or are cancelled are free.
Providers
| Field | Type | Description |
|---|---|---|
| OpenAI | chat, embeddings | Results kept 30 days. Several models can share a batch. |
| Anthropic | messages | Anthropic format only. Results kept 29 days. |
| chat | Requests are translated to Gemini and results back to OpenAI's shape. One model per batch. Batches expire after 48 hours. | |
| Mistral | chat, embeddings | One model per batch. |
| Qwen | chat, embeddings | Only models Alibaba enables for batch in its international region. |
OpenAI format
Works with the OpenAI SDKs unchanged: point them at https://boldrouter.com/v1. Each line of the file is one request. Use the provider's model ids or boldrouter ids such as openai/gpt-4.1 or google/gemini-2.5-flash. All requests in a batch must be for the same provider, which runs the batch.
from openai import OpenAI
client = OpenAI(base_url="https://boldrouter.com/v1", api_key="sk-bold-...")
# requests.jsonl - one request per line:
# {"custom_id": "q1", "method": "POST", "url": "/v1/chat/completions",
# "body": {"model": "openai/gpt-4.1", "messages": [{"role": "user", "content": "Hi"}], "max_tokens": 200}}
file = client.files.create(file=open("requests.jsonl", "rb"), purpose="batch")
batch = client.batches.create(input_file_id=file.id, endpoint="/v1/chat/completions", completion_window="24h")
batch = client.batches.retrieve(batch.id) # poll until status is "completed"
results = client.files.content(batch.output_file_id).textSupported endpoints: /v1/chat/completions and /v1/embeddings. GET /v1/batches, GET /v1/files, GET /v1/files/{id} and DELETE /v1/files/{id} work as on OpenAI. A finished batch also reports its cost in USD and the provider that ran it.
Anthropic format
Works with the Anthropic SDKs: set the base URL to https://boldrouter.com. Each request's params are a normal Messages request and reach Anthropic unchanged, cache_control and anthropic-beta headers included. Only model is rewritten, and only when you use a boldrouter id.
import anthropic
client = anthropic.Anthropic(base_url="https://boldrouter.com", api_key="sk-bold-...")
batch = client.messages.batches.create(requests=[
{"custom_id": "q1", "params": {"model": "claude-sonnet-4-6", "max_tokens": 200,
"messages": [{"role": "user", "content": "Hi"}]}},
])
batch = client.messages.batches.retrieve(batch.id) # poll until processing_status is "ended"
for result in client.messages.batches.results(batch.id):
print(result.custom_id, result.result.type)GET /v1/messages/batches lists your batches, and DELETE /v1/messages/batches/{id} deletes one that has ended.
Billing
- When you submit a batch, its worst-case cost at the batch price is held against your balance and budgets. That uses each request's
max_tokens, or 4,096 output tokens when a request sets none. If the hold doesn't fit, the batch is refused with402and nothing is sent. - When the batch ends, each successful request is billed at its real usage and the hold is released. Usage appears in your dashboard under each model, marked as batch.
- With your own provider key, the batch runs in your provider account and boldrouter charges its platform fee on the batch price.
- Anthropic web searches are billed at $0.01 each. The batch discount doesn't apply to them.
Checked before anything runs
Every request in a batch is checked against your workspace's model rules and blocked countries. Any problem rejects the whole batch with a 400 that lists the line numbers (OpenAI format) or requests[i] indexes (Anthropic format).
Limits and data
- Claude models use the Anthropic format; OpenAI, Google, Mistral and Qwen models use the OpenAI format. Other providers don't offer batches.
- Routing, failover and prompt anonymization don't apply to batches: each request runs on the one provider you chose. Workspace keys with data protection on can't submit batches.
- An uploaded file is stored encrypted only until its batch is submitted. Unused uploads are deleted after 7 days. boldrouter stores no results: downloads come straight from the provider for as long as it keeps them.
