Docs
Create an API key in the console, point an OpenAI SDK at https://api.batchrate.ai/v1, and submit a JSONL batch. Jobs run inside a 24h completion window, and results typically come back within hours.
Already using OpenAI? Change base_url
Point the official OpenAI SDK at https://api.batchrate.ai/v1. Python takes base_url. JavaScript takes baseURL. Use a Batchrate key (br_live_...). The calls below are files.create and batches.create.
from openai import OpenAI
client = OpenAI(
api_key="br_live_...",
base_url="https://api.batchrate.ai/v1",
)
batch_file = client.files.create(
file=open("batch.jsonl", "rb"),
purpose="batch",
)
batch = client.batches.create(
input_file_id=batch_file.id,
endpoint="/v1/chat/completions",
completion_window="24h",
)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "br_live_...",
baseURL: "https://api.batchrate.ai/v1",
});
const batchFile = await client.files.create({
file: fs.createReadStream("batch.jsonl"),
purpose: "batch",
});
const batch = await client.batches.create({
input_file_id: batchFile.id,
endpoint: "/v1/chat/completions",
completion_window: "24h",
});
POST /v1/files accepts multipart file and purpose batch. POST /v1/batches accepts input_file_id, endpoint /v1/chat/completions, and completion_window 24h. A direct chat completion returns unknown_route. Put those requests in the JSONL file. Walkthroughs: Run an OpenAI batch on open models and Classify a million rows.
Quickstart
Install the official SDK. No Batchrate package is required.
pip install openai
import time
from openai import OpenAI
client = OpenAI(api_key="br_live_...", base_url="https://api.batchrate.ai/v1")
f = client.files.create(file=open("batch.jsonl", "rb"), purpose="batch")
b = client.batches.create(input_file_id=f.id, endpoint="/v1/chat/completions", completion_window="24h")
while b.status not in ("completed", "failed", "expired", "cancelled"):
time.sleep(30); b = client.batches.retrieve(b.id)
if b.output_file_id: print(client.files.content(b.output_file_id).text)
JavaScript is the same idea: new OpenAI({ apiKey, baseURL: "https://api.batchrate.ai/v1" }). Complete scripts for Python, JavaScript, and curl are under Examples.
Use with LiteLLM
Batchrate works with LiteLLM's batch API using the openai provider, no plugin needed.
import os, litellm
kw = dict(custom_llm_provider="openai", api_base="https://api.batchrate.ai/v1",
api_key=os.environ["BATCHRATE_API_KEY"])
f = litellm.create_file(file=open("in.jsonl","rb"), purpose="batch", **kw)
b = litellm.create_batch(completion_window="24h", endpoint="/v1/chat/completions",
input_file_id=f.id, metadata={"job":"demo"}, **kw)
b = litellm.retrieve_batch(batch_id=b.id, **kw)
if b.status == "completed":
out = litellm.file_content(file_id=b.output_file_id, **kw).content
model_list:
- model_name: qwen3.6-35b-a3b
litellm_params: {model: openai/qwen3.6-35b-a3b, api_base: https://api.batchrate.ai/v1, api_key: os.environ/BATCHRATE_API_KEY}
files_settings:
- {custom_llm_provider: openai, api_base: https://api.batchrate.ai/v1, api_key: os.environ/BATCHRATE_API_KEY}
Clients use the OpenAI SDK with base_url=http://localhost:4000/v1 and the header custom-llm-provider: openai on files and batches calls. files_settings routes /v1/files; a model_list entry alone does not. That model_list entry is only there for the proxy, so don't route chat.completions to Batchrate through LiteLLM.
{"custom_id":"req-0","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.6-35b-a3b","messages":[{"role":"user","content":"hi"}],"max_tokens":64,"chat_template_kwargs":{"enable_thinking":false}}}
Authentication
Send Authorization: Bearer br_live_.... Keys are shown once at creation and are not shown again. Revoked keys stop working immediately. The console can also call these routes while you are signed in.
Files
POST /v1/files
Multipart form with purpose=batch and file. The body must be valid batch JSONL. A batch input file can have up to 5,000 lines and 10 MB (up to 50 MB when lines carry base64 images; see image limits), and each line becomes one request. Optional expires_after[anchor]=created_at and expires_after[seconds] (3600 to 2592000) delete the file that many seconds after upload. Response:
{
"id": "file-...",
"object": "file",
"bytes": 120,
"created_at": 1710000000,
"filename": "batch.jsonl",
"purpose": "batch",
"status": "processed",
"status_details": null,
"expires_at": null
}
expires_at is the time the file is scheduled for deletion, or null when deletion depends on batch activity (see File retention). Output and error files have purpose: "batch_output". Documents (PDF, DOCX, and others) are uploaded with purpose=user_data; see Documents.
GET /v1/files
Lists files you own, newest first. Optional query parameters: purpose (batch, batch_output, or user_data), limit (1 to 10000, default 100), order (asc or desc), and after (a file id from the previous page). The response uses object: "list", data, first_id, last_id, and has_more. Deleted files are not listed.
GET /v1/files/{id}
Returns the same file object if you own it.
GET /v1/files/{id}/content
Returns the raw bytes. Use this for input, output, and error files.
DELETE /v1/files/{id}
Deletes a file you own and removes the object from storage immediately.
{
"id": "file-...",
"object": "file",
"deleted": true
}
If the input file is still used by a batch in validating, in_progress, finalizing, or cancelling, the API returns file_in_use and names that batch. Cancel the batch first. A batch that is still cancelling stays blocked until it reaches a terminal status. Output and error files can be deleted at any time. Deleting a file does not remove the batch or its billing record. Reading a deleted file returns file_not_found.
File retention
Input files are deleted 7 days after every batch that used them reaches a terminal state (completed, cancelled, failed, or expired). An input file that is never used is deleted 7 days after upload. Output and error files are deleted 30 days after they are created. An upload with expires_after, or a batch with output_expires_after, is deleted at its own expires_at if that comes first. You can delete sooner with DELETE /v1/files/{id} or the console. Automatic deletion removes the file. Credit records stay for accounting.
Batches
POST /v1/batches
{
"input_file_id": "file-...",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": { "dataset": "support-queue" },
"output_expires_after": { "anchor": "created_at", "seconds": 604800 }
}
endpoint is /v1/chat/completions for chat models or /v1/audio/transcriptions for Whisper, and must match the url on every line of the file. completion_window is 24h when omitted, or 1h for Rush. Any other value returns invalid_completion_window. The batch moves to in_progress after validation. If the available credit balance is below the estimate, the API returns insufficient_quota. output_expires_after is optional and sets how long output and error files are kept after they are created, from 3600 seconds up to the standard output retention.
GET /v1/files/{id}/estimate
Returns a cost estimate for an uploaded file. Output tokens are always an estimate. They come from each line's max_tokens or max_completion_tokens. A line that omits both uses the default output length, up to the maximum used for estimates. warning is set when free tokens plus the available balance will not cover the estimated price. The same object is included as estimate on the file. A created batch stores the quote used for its hold. Output tokens on that quote are still an estimate.
GET /v1/batches and GET /v1/batches/{id}
List responses use object: "list", data, first_id, last_id, and has_more. Pass limit and after to page. A batch includes model, request_counts, output_file_id, error_file_id, usage, output_expires_after, and estimate.
POST /v1/batches/{id}/cancel
Queued lines are cancelled. Lines already running can still finish. When nothing is left in flight, the batch becomes cancelled and any completed lines are still billed and downloadable.
Statuses: validating, in_progress, finalizing, completed, failed, cancelling, cancelled, expired.
Completion window: 24 hours
Every batch has a 24h completion window that starts when you create it. The deadline is the batch's expires_at, and the console shows it on each running job. Results typically come back within hours.
- You are charged only for requests that complete. Failed requests are not charged.
- When the window ends, every request that has not finished is cancelled and not charged, and the hold on your balance for it is released. The batch status becomes
expired. - An expired batch still has an output file with every completed result. Its error file lists the unfinished requests with code
batch_expired, so you can submit them again in a new batch. - The
batch.expiredwebhook and the batch email tell you when this happens.
Rush (1 hour): batch fields and billing
Pass "completion_window": "1h" to ask for results within an hour. Rush is 1.5× the model's standard input and output price. The batch object includes price_tier (rush), rush_deadline_at (the hour), and expires_at (still 24 hours). Whisper and Decisions are 24h only. A job that cannot finish in the hour returns capacity_unavailable_for_window. Resubmit it as 24h.
If a Rush batch misses the hour, you pay the standard price. Completed requests are billed at the 24h rate, and the batch keeps running until the 24 hour window. Anything still unfinished then is released with no charge. The batch sets rush_missed and finished_at when it settles. Free tokens still cover one token per token.
Rush
Set "completion_window": "1h" when you create a batch (chat models: Qwen3.6, gpt-oss-120b, gpt-oss-20b, Gemma 4 26B). Rush batches complete within 1 hour of submission and bill at 1.5x the standard rate. If one finishes late, it bills at the standard rate. Your batch.completed webhook fires as usual.
POST /v1/batches {"input_file_id": "file-abc123", "endpoint": "/v1/chat/completions", "completion_window": "1h"}
Models
GET /v1/models
Lists enabled models.
- Chat model:
qwen3.6-35b-a3b(Qwen3.6 35B, text and images, $0.05 / $0.40 per 1M input/output tokens). It has a 32,768-token context, including the reply, and it supports JSON output. - Chat model:
gpt-oss-120b(gpt-oss 120B, text only, $0.06 / $0.225 per 1M input/output tokens). It has a 32,768-token context, including the reply, and it supports JSON output. It does not accept images. Setreasoning_efforttolow,medium, orhigh. Reasoning tokens are billed as output tokens. For bulk jobs, use"reasoning_effort": "low". - Chat model:
gpt-oss-20b(gpt-oss 20B, text only, $0.015 / $0.0525 per 1M input/output tokens). It has a 32,768-token context, including the reply, and it supports JSON output. It does not accept images.reasoning_effortuses the same values asgpt-oss-120b, and reasoning tokens are billed as output tokens. For bulk jobs, use"reasoning_effort": "low". - Chat model:
gemma-4-26b-a4b(Gemma 4 26B A4B, text only, $0.0375 / $0.1275 per 1M input/output tokens). It has a 32,768-token context, including the reply, and it supports JSON output. It does not accept images. Draft for review. Marketing will replace this copy. - Chat model:
qwen3-vl-30b-a3b(Qwen3 VL 30B A3B, text and images, $0.06 / $0.225 per 1M input/output tokens). It has a 32,768-token context, including the reply, and it supports JSON output. Up to 8 images per request, billed likeqwen3.6-35b-a3bimages. - Document OCR:
olmocr-2-7b-1025(olmOCR 2 7B by Ai2, page images to Markdown, $0.075 / $0.075 per 1M input/output tokens). One image per request, a 16,384-token context including the reply, no JSON mode. See Document OCR. - Transcription:
whisper-large-v3-turbo(Whisper Large v3 Turbo), at $0.0006 / audio minute ($0.036 / audio hour); free tokens don't apply. See Audio. - Decisions:
batchrate-decide, at $0.02 / M input tokens. The reply is one token and is not billed. See Decisions.
Prices are not on this route. Read /api/pricing or the pricing page for current prices. This route and upload accept a model id only while that model is enabled. Ids match exactly: openai/gpt-oss-120b is not an alias for gpt-oss-120b, and openai/gpt-oss-20b is not an alias for gpt-oss-20b. google/gemma-4-26b-a4b is not an alias for gemma-4-26b-a4b.
GET /v1/models/{id}
Returns one model object, or model_not_found if that id is not available.
Thinking
qwen3.6-35b-a3b runs with thinking off by default. To turn it on for a request, set "chat_template_kwargs": {"enable_thinking": true} in the body.
Thinking tokens count toward max_tokens and are billed as output tokens. With thinking on, allow a much larger max_tokens (for example 2,000 or more), or the answer can come back empty.
gpt-oss-120b and gpt-oss-20b take reasoning_effort on the chat request body: low, medium, or high. The value is passed through unchanged. Reasoning tokens are billed as output tokens. For bulk jobs, set "reasoning_effort": "low".
JSONL format
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.6-35b-a3b","messages":[{"role":"user","content":"Summarize this ticket."}]}}
Every line in a file uses the same model and the same url, as with OpenAI's Batch API. To run several models, upload one file per model and create one batch for each.
Output lines follow the OpenAI batch result shape:
{"id":"batch_req_...","custom_id":"req-1","response":{"status_code":200,"request_id":"req_...","body":{"id":"chatcmpl-...","object":"chat.completion","choices":[{"message":{"role":"assistant","content":"..."}}],"usage":{"prompt_tokens":10,"completion_tokens":20,"total_tokens":30}}},"error":null}
Failed lines go to the error file with response: null and an error object of code and message.
Structured JSON output
Add OpenAI's response_format to a line's body to get JSON back. The model is constrained while it writes, so message.content is valid JSON that matches your schema. The only exception is an answer cut off by max_tokens (finish_reason: "length"), so leave enough room.
{"custom_id":"inv-1","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.6-35b-a3b","max_tokens":500,"messages":[{"role":"user","content":"Extract the invoice fields from: ..."}],"response_format":{"type":"json_schema","json_schema":{"name":"invoice","strict":true,"schema":{"type":"object","properties":{"vendor":{"type":"string"},"total":{"type":"number"},"currency":{"type":"string","enum":["USD","EUR"]}},"required":["vendor","total","currency"],"additionalProperties":false}}}}}
{"type":"json_schema","json_schema":{"name":...,"schema":{...}}}returns JSON matching the schema.nameis 1 to 64 letters, digits, underscores, or dashes.strictis accepted.{"type":"json_object"}returns any valid JSON object. As with OpenAI, a message must mention JSON (for example "Reply in JSON").{"type":"text"}is the default.
Supported schema keywords
type, properties, required, additionalProperties, items, prefixItems, enum, const, anyOf, $ref with $defs or definitions, minItems, maxItems, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minProperties, maxProperties, pattern, and format (date-time, date, time, duration, email, hostname, ipv4, ipv6, uuid, uri, uri-reference, uri-template, json-pointer, relative-json-pointer). title, description, default, examples, and $comment are allowed as notes.
Any other keyword, such as oneOf, allOf, or uniqueItems, is rejected at upload with invalid_file and the line number, so a schema is never partly ignored. Rewrite oneOf as anyOf. Schemas can be up to 64 KB, 10 levels deep, and 5,000 properties.
Thinking
json_object and json_schema lines follow the same thinking rules. Thinking is off unless the body sets "chat_template_kwargs": {"enable_thinking": true}. Thinking tokens count toward max_tokens and are billed as output tokens. With thinking on, allow a much larger max_tokens (for example 2,000 or more), or the answer can come back empty. The JSON answer still follows your schema.
Documents
Batches can read PDF, DOCX, HTML, Markdown, and plain-text documents. Batchrate extracts the text once, when the document is uploaded, and the model reads it as part of the prompt. Extraction and splitting are free; document text is billed as input tokens at the model's normal rate, and the estimate includes it before you create the batch.
Upload a document
curl https://api.batchrate.ai/v1/files \ -H "Authorization: Bearer $BATCHRATE_API_KEY" \ -F purpose=user_data \ -F file=@contract.pdf
The response is a normal file object with purpose: "user_data", plus document: its format, pages (PDFs only), and estimated_tokens. With the OpenAI SDK: client.files.create(file=open("contract.pdf", "rb"), purpose="user_data").
Use a document in a request
Add an OpenAI file content part to a line. Use file_id for an uploaded document, or file_data with a base64 data URL and a filename:
{"custom_id":"contract-1","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.6-35b-a3b","max_tokens":800,"messages":[{"role":"user","content":[{"type":"text","text":"List the termination clauses."},{"type":"file","file":{"file_id":"file-..."}}]}]}}
{"type":"file","file":{"filename":"memo.pdf","file_data":"data:application/pdf;base64,JVBERi0x..."}}
When the batch file is uploaded, each file part is replaced with the document's text inside <document name="..."> tags, with [Page N] markers for PDFs. The whole request, document included, must fit the model's context window (32,768 tokens including the reply). If it doesn't, the upload names the line; split the document with POST /v1/documents/prepare.
POST /v1/documents/prepare
Splits documents into chunks and writes a batch input file with one request per chunk. Create the batch from it as usual.
{
"file_ids": ["file-...", "file-..."],
"model": "qwen3.6-35b-a3b",
"instructions": "Extract every invoice number and amount. Reply in JSON.",
"chunk_tokens": 6000,
"overlap_tokens": 200,
"max_tokens": 600,
"response_format": {"type": "json_object"}
}
instructionsbecomes the system message of every request. Each chunk is the user message, headed with the document name, page range, and part number.chunk_tokens: 500 to 24,000, default 6,000. Chunks break between paragraphs and pages where possible.overlap_tokens(default 200, up to half a chunk) repeats the end of each chunk at the start of the next, so nothing is lost at a boundary.- Optional:
max_tokens,temperature,response_format(see JSON output), andfilenamefor the generated file. - Each
custom_idis{file_id}:{part}, so results map back to their document.
Scanned PDFs: page images
PDFs without selectable text, such as scans, faxes, and photographed forms, are read as page images: the model sees each page as a picture. This also suits text PDFs whose meaning is in their layout, charts, or handwriting. Send "mode": "pages" to POST /v1/documents/prepare:
{
"file_ids": ["file-..."],
"model": "qwen3.6-35b-a3b",
"instructions": "Transcribe the handwritten notes on these pages.",
"mode": "pages",
"pages_per_request": 1,
"detail": "high"
}
- Scanned PDFs upload like any other document. Their
documentobject has"scanned": true, and they work with"mode": "pages"only. pages_per_request: 1 to 8, default 1. Consecutive pages go in one request, headed with the document name and page range. Eachcustom_idis{file_id}:p{first}-{last}, or{file_id}:p{page}for one page.detail:low,high, orauto, as for image input.- Pages are rendered at 150 DPI and billed as image tokens at the model's input rate, about 2,000 tokens for a Letter or A4 page, or at most 258 with
"detail": "low". The estimate includes them before you create the batch. - A page that cannot be rendered goes to the error file and is not billed.
Response:
{
"object": "documents.prepared",
"file": {"id": "file-...", "object": "file", "purpose": "batch", ...},
"requests": 14,
"documents": [
{"file_id": "file-...", "filename": "contract.pdf", "pages": 42,
"chunks": [{"custom_id": "file-...:1", "first_page": 1, "last_page": 4, "estimated_tokens": 5980}, ...]}
],
"estimate": {...}
}
prepared = client.post("/documents/prepare", cast_to=object, body={
"file_ids": [doc.id], "model": "qwen3.6-35b-a3b", "instructions": "Summarize each section.",
})
batch = client.batches.create(input_file_id=prepared["file"]["id"],
endpoint="/v1/chat/completions", completion_window="24h")
In the console, choose New Batch, then Documents. Drop files, write the instruction, check the estimate, and start the batch.
Limits
- Up to 50 MB and 2,000 pages per document; inline
file_dataup to 10 MB per document. - Up to 10 file parts per request, 200 different documents per batch file, and 500 documents per prepare call. The generated file follows the normal batch limits on lines and size.
- Scanned PDFs upload normally and work with
"mode": "pages"only. Inlinefile_dataparts need a text layer. - Text and Markdown files must be UTF-8.
Documents follow input retention: they are deleted 7 days after upload, together with their extracted text, or sooner with DELETE /v1/files/{id}. Batches already created from them keep running, because their requests hold the text.
Document OCR (olmOCR)
olmocr-2-7b-1025 is Ai2's olmOCR 2 7B (Apache-2.0). It reads one page image and returns the page as Markdown, with equations in LaTeX and tables in HTML, under a short front matter block (primary_language, is_rotation_valid, rotation_correction, is_table, is_diagram). It is an OCR model, not a general chat model: it expects Ai2's fixed prompt and one page per request.
The simplest way is POST /v1/documents/prepare with the model and your PDF file ids. With this model, mode defaults to pages, instructions defaults to Ai2's prompt, each page becomes one request, and pages are rendered with the longest side at 1288 px, the size the model was trained on:
POST /v1/documents/prepare
{"file_ids": ["file-..."], "model": "olmocr-2-7b-1025", "max_tokens": 4000}
You can also write the lines yourself: one user message with the prompt as a text part and one image_url part per line, as in image input. Render pages so the longest side is 1288 px.
- Billing: page images are input tokens at one token per 28×28 pixels, about 1,700 input tokens for a Letter or A4 page including the prompt. A typical text page writes about 1,000 output tokens.
- One image per request. More than one fails the upload.
- Set
max_tokens(for example 4000) so a page that repeats itself stops early. - Rush (
"completion_window": "1h") works at 1.5× input and output. - Ai2 publishes olmOCR for research and educational use under its Responsible Use Guidelines. Please follow them.
Image input
Lines can include images, using the same image_url content parts as the OpenAI Chat Completions API. Put text and images in one user message:
{"custom_id":"img-1","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.6-35b-a3b","max_tokens":300,"messages":[{"role":"user","content":[{"type":"text","text":"List the line items on this receipt as JSON."},{"type":"image_url","image_url":{"url":"https://example.com/receipt.jpg","detail":"high"}}]}]}}
image_url.url is either a public https:// link or a base64 data URL such as data:image/png;base64,iVBORw0.... Supported formats are PNG, JPEG, WEBP, and non-animated GIF. A sample file is at /sample-image-batch.jsonl.
Limits
- Images work with
qwen3.6-35b-a3bandqwen3-vl-30b-a3b, and witholmocr-2-7b-1025for document OCR (one image per request).gpt-oss-120bandgpt-oss-20bare text only.gemma-4-26b-a4bis text only. - Up to 8 images per request.
- Up to 10 MB per image.
- An upload can be up to 50 MB including base64 images. Prompt text and other non-image content must stay under 10 MB. For large image sets, use
https://links. - Links must use a public host name over
https://. Links that redirect to private addresses, return something other than an image, or are larger than the image limit fail for that line.
Image tokens and price
Images are billed as input tokens at the model's normal input rate. There is no separate image fee. An image costs about 1,024 tokens per megapixel (one token per 32 × 32 pixel block). Each image uses at least 66 tokens. Larger images are scaled down to at most 4,098 tokens. With "detail": "low", an image uses at most 258 tokens. "high" and "auto" use the full limit. The usage.prompt_tokens on each result line includes image tokens.
Estimates read base64 image sizes exactly. A linked image is estimated at the per-image maximum until it runs, so the hold for a batch with links can be higher than the final charge. Unused holds are released when the batch finishes.
Thinking
Image requests follow the same thinking rules. Thinking is off unless the body sets "chat_template_kwargs": {"enable_thinking": true}. Thinking tokens count toward max_tokens and are billed as output tokens. With thinking on, allow a much larger max_tokens (for example 2,000 or more), or the answer can come back empty.
Failed images
If an image link cannot be fetched or an image cannot be read, that line goes to the error file with code image_fetch_failed or invalid_image. It is not billed. Other lines in the batch still run.
Uploaded images are stored with the input file and follow the same retention: they are deleted with the input file.
Image batches
To run one instruction over many images, choose New Batch, then Images. Drop in JPEG, PNG, WEBP, or GIF files, a .zip of images, or paste https:// links, one per line. Write the instruction, optionally pick the image detail and a JSON schema for structured answers, and the page shows the estimate as you go. Start batch creates a normal batch with one request per image.
When the batch finishes, the Images page links its results as the usual JSONL and as a CSV with one row per image: the image name and the answer, or one column per field when you gave a JSON schema. Nested fields are named with dots, such as address.city. Images that could not be read appear in the CSV with an error value and are not billed.
Each request's custom_id is a running number and the image name, for example 0001-receipt.jpg, so results map back to images in the order they were added.
From the API
The same flow is available with your API key:
POST /v1/images/uploadswith multipartfilefields, one per image. The reply has anupload_idand each image'ssha,width, andheight. For large sets, send the images over several requests, each up to 50 MB, with the sameupload_id.POST /v1/images/preparewithmodel,instructions, optionaldetail(loworhigh),max_tokens,temperature, andresponse_format, plusupload_idandimages: a list of{"name": ..., "sha": ...}for uploaded images or{"url": "https://..."}for links. The reply has the batch inputfileand its estimate.- Create the batch from
file.idwithPOST /v1/batches, as with any other file.
curl https://api.batchrate.ai/v1/images/uploads \
-H "Authorization: Bearer $BATCHRATE_API_KEY" \
-F file=@receipt-0001.jpg -F file=@receipt-0002.jpg
curl https://api.batchrate.ai/v1/images/prepare \
-H "Authorization: Bearer $BATCHRATE_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"qwen3.6-35b-a3b","instructions":"Read the total on this receipt. Reply in JSON.","response_format":{"type":"json_object"},"upload_id":"file-...","images":[{"name":"receipt-0001.jpg","sha":"..."},{"url":"https://example.com/receipt-0003.jpg"}]}'
POST /v1/images/estimate takes the same body with each image given as {"width": ..., "height": ...} or {"url": ...}, and returns the estimate without uploading anything.
Limits
- One image per request, up to 10 MB per image, and up to the normal batch limit of requests per batch.
- Up to 1 GB of uploaded images per image batch. Use
https://links for larger sets. - Uploaded images that are not used in a batch within a day are deleted. Images in a batch follow input retention and are deleted with its input file.
Decisions
Decisions is a batch endpoint for classification. Each line gives a prompt and a list of choices. You get back the chosen label and a probability for every choice. The probabilities sum to 1 and are calibrated on labeled test sets, so you can threshold on them and send low-confidence rows to review.
Good for: ticket routing, content moderation, dataset labeling, lead scoring, and yes/no checks over documents.
How to run it
This is the same OpenAI-compatible Files and Batches flow you already use.
- Upload a JSONL file to
POST /v1/fileswithpurpose="batch". - Create a batch with
POST /v1/batches, usingendpoint="/v1/decisions"andcompletion_window="24h". - Download the output file when the batch completes. Signed webhooks fire as usual (webhooks).
Request line
{"custom_id":"ticket-001","method":"POST","url":"/v1/decisions","body":{
"model":"batchrate-decide",
"prompt":"Which team should handle this ticket? Ticket: I was charged twice for my October invoice. Please refund one.",
"choices":["billing","technical","sales","other"]}}
| Field | Notes |
|---|---|
model | batchrate-decide |
prompt | The text and question being decided. |
choices | The allowed labels. The answer is always one of these. 2 to 256 single-line labels, up to 128 characters each. Multi-word choices are supported. |
temperature (optional) | Defaults to 2.0. |
Output line
{"custom_id":"ticket-001","response":{"status_code":200,"body":{
"choice":"billing",
"probabilities":{"billing":0.70,"technical":0.10,"sales":0.10,"other":0.10}}},
"error":null}
Probabilities above are illustrative only. choice is the highest-probability choice. probabilities covers every choice and sums to 1.
Pricing
$0.02 per million input tokens. Output is free.
Limits
- 24h completion window only. Rush is not available for Decisions.
- Results arrive when the batch completes, not in real time.
Translate
Translate is a preset that runs translation as a normal chat batch on gemma-4-26b-a4b. Send a CSV (with a header row) or a JSONL file and name the column or field to translate. You get the same file back with a translated column added. In the console, choose New Batch, then Translate.
Target languages: Spanish (es), French (fr), German (de), Brazilian Portuguese (pt-BR), Simplified Chinese (zh-Hans), Japanese (ja), and English (en, from Spanish). GET /v1/translate lists the codes your account can use.
Placeholders such as {name} and %s, HTML tags, Markdown, numbers, and URLs are kept as written. Empty cells stay empty and are not billed. Review anything customer-facing before you publish it.
How to run it
POST /v1/translate/preparewith the file as a string. Add"dry_run": trueto get the column list (leave outfield) or an estimate without creating anything.- Create a batch from the returned
file.idwithPOST /v1/batches,endpoint="/v1/chat/completions", andcompletion_window"24h"or"1h"for Rush. - When the batch completes,
GET /v1/translate/{batch_id}/resultreturns the file with the new column.
curl https://batchrate.ai/v1/translate/prepare \
-H "Authorization: Bearer $BATCHRATE_API_KEY" -H "Content-Type: application/json" \
-d '{"content":"sku,title\nA1,Hello {name}!\n","filename":"catalog.csv","field":"title","target_language":"es"}'
| Field | Notes |
|---|---|
content | The CSV or JSONL file as a string, up to the batch file size limit. |
filename (optional) | Used for the format (.csv or .jsonl) and the result file name. |
format (optional) | csv or jsonl. Detected when left out. |
field | The column (CSV) or top-level key (JSONL) to translate. |
target_language | One of the codes above. |
source_language (optional) | Defaults to auto. |
output_field (optional) | Name of the new column. Defaults to {field}_{target_language}. |
dry_run (optional) | true returns columns, request count, and an estimate only. |
Cells that fail are left empty, with the reason in a {output_field}_error column.
Audio
Translate audio too: we transcribe it and translate it into text or subtitles. Run an Audio transcription batch first, using "response_format":"verbose_json" so each line keeps its timing. Then, in the console's Translate page, choose the finished audio batch and a language, or call the API:
POST /v1/translate/audiowith{"batch_id":"batch_...","target_language":"es"}. Add"dry_run": truefor an estimate.- Create a batch from the returned
file.idwithendpoint="/v1/chat/completions"andcompletion_window="24h". GET /v1/translate/{batch_id}/result?format=srt,vtt,txt, orjson. For a batch with several audio files, add&file=<custom_id>to get subtitles for one file. Each transcript line is translated on its own, so subtitles keep the original start and end times.
Audio is billed as the transcription's per-minute price plus normal gemma-4-26b-a4b tokens for the translation step.
Pricing
Normal gemma-4-26b-a4b token prices on the pricing page. There is no separate translation price. Estimates count the most output each cell could use; you are billed for the tokens actually written.
Audio transcription
To transcribe recordings, choose New Batch, then Audio. Drop MP3, WAV, FLAC, OGG, M4A, or WEBM files, up to 100 MB and 6 hours each, or paste public https:// links, one per line. The page prices the batch from each file's length at the per-minute rate on the pricing page. Linked files are estimated at 1 hour of audio until they finish. Free tokens do not apply. Start batch creates a transcription batch.
When the batch finishes, the Audio page offers the transcript as text, as a CSV with one row per file, and as JSONL. The Batch Jobs list labels the job Audio.
From the API, upload audio with POST /v1/files and purpose user_data, then put one line per recording in a batch file. Create the batch with "endpoint": "/v1/audio/transcriptions".
{"custom_id":"call-1042","method":"POST","url":"/v1/audio/transcriptions","body":{"model":"whisper-large-v3-turbo","file":"file-...","language":"en"}}
file is an uploaded audio file id or a public https:// link. language is optional. You are charged for the audio that completes, per second, at the per-minute price. A line that does not finish is not charged.
Webhooks
Add an HTTPS endpoint in Settings to get an event when a batch finishes, instead of polling. Each account has one endpoint. Events use the same names and shape as OpenAI's batch webhooks:
batch.completedbatch.failedbatch.cancelledbatch.expired
POST https://example.com/batchrate-webhook
webhook-id: evt_...
webhook-timestamp: 1760000000
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
{"object":"event","id":"evt_...","type":"batch.completed","created_at":1760000000,"data":{"id":"batch_..."}}
The event carries the batch id only. Call GET /v1/batches/{id} for counts and file ids. The Send test event button sends a webhook.test event.
Verifying signatures
Signatures follow the Standard Webhooks spec, the same scheme OpenAI uses, so the OpenAI SDK can verify them. Pass the raw request body and headers, and your whsec_... signing secret from Settings:
from openai import OpenAI
client = OpenAI(api_key="br_live_...", base_url="https://api.batchrate.ai/v1")
# In your web handler:
event = client.webhooks.unwrap(raw_body, headers, secret="whsec_...")
if event.type == "batch.completed":
batch = client.batches.retrieve(event.data.id)
// JavaScript const event = await client.webhooks.unwrap(rawBody, headers, "whsec_...");
unwrap rejects bad signatures and timestamps more than 5 minutes old. To verify by hand: base64-decode the part of the secret after whsec_, compute HMAC-SHA256 over {webhook-id}.{webhook-timestamp}.{raw body}, base64-encode it, and compare with the value after v1,.
Delivery and retries
Return any 2xx status within 10 seconds. Redirects are not followed. Failed deliveries are retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours, and 24 hours. If every retry fails, delivery is turned off and we email you; turn it back on in Settings after fixing the endpoint. An event can arrive more than once, so use webhook-id to skip duplicates. Settings shows the last 50 deliveries.
Email alerts and spend limits
Change these in Settings.
- Finished batches. An email when a batch completes, fails, or expires, with counts and the amount charged. On by default.
- Low balance. An email when your available balance (credit not held by running batches, plus remaining free tokens) drops below an amount you choose. The default is $5. It sends once, then resets after you add credit.
- Monthly spend limit. Optional. When this month's charges, plus credit held for running batches, plus the new batch's estimate would pass the limit,
POST /v1/batchesreturns HTTP 429 with codespend_limit_reached. Running batches finish. We email you at 80% and 100% of the limit. The month resets on the 1st (UTC).
Delete your account
Settings has Delete my account. You confirm with your password and by typing your email. The account is closed immediately:
- API keys stop working, and you are logged out.
- Queued and running batches are cancelled. Requests that already finished are charged. Requests that had not finished are not.
- Uploaded files, prompts, and results are deleted. Onboarding and other account emails stop.
- Remaining prepaid credits are forfeited and are not refunded. Purchased credit is non-refundable except where the law requires a refund. Payment and invoice records are kept without your email.
The same email can sign up again. That is a new account, and it does not include the signup token grant. See the privacy policy and the terms.
Account limits
These limits apply when you create a batch. Accounts that have not added credit yet have lower limits, which rise automatically with the first credit purchase.
| Limit | Before adding credit | After adding credit |
|---|---|---|
| Batches running at a time | 3 | 100 |
| Requests per batch | 5,000 | 5,000 |
| Tokens submitted per 24 hours (estimate, rolling) | 10,000,000 | 1,000,000,000 |
A batch is created from one input file, so requests per batch follow the file limit under Files: up to 5,000 lines and 10 MB. For more requests, split them across several batches. Tokens submitted counts the estimate of every batch created in the last 24 hours. Over a limit, POST /v1/batches returns active_batch_limit or daily_token_limit (HTTP 429), or batch_too_large (HTTP 400), with a message that says which limit applies. Need more? Write to contact.
Errors
{"error":{"message":"...","type":"invalid_request_error","param":null,"code":"invalid_file"}}
Common codes: invalid_api_key, invalid_file, insufficient_quota, rate_limit_exceeded, file_not_found, file_in_use, batch_not_found, model_not_found, endpoint_mismatch, spend_limit_reached, active_batch_limit, batch_too_large, daily_token_limit, invalid_completion_window, rush_not_offered, capacity_unavailable_for_window, unknown_route. Batchrate runs batch jobs only, so direct calls such as POST /v1/chat/completions return unknown_route. Put those requests in a JSONL file and create a batch.
Examples
Each script uploads a two-line file, creates a batch, waits for it to finish, and prints the results. Set BATCHRATE_API_KEY before running.
- Python: batch.py (
pip install openai) - JavaScript: batch.mjs (
npm install openai, Node 18 or later) - curl: batch.sh (needs
curlandjq) - Input file: batch.jsonl
Jobs run inside a 24h completion window, and results typically come back within hours. Poll every 30 to 60 seconds, or add a webhook; there is no need to poll faster.
Billing
Credits are prepaid. Checkout is Stripe-hosted. Credits appear in your balance after Stripe confirms the payment. If a Rush batch misses the hour, you pay the standard price. Qwen3.6 35B (qwen3.6-35b-a3b) is $0.05 / M input and $0.40 / M output. Rush on that model is $0.075 / M input and $0.60 / M output. gpt-oss 120B (gpt-oss-120b) is $0.06 / M input and $0.225 / M output. gpt-oss 20B (gpt-oss-20b) is $0.015 / M input and $0.0525 / M output. On gpt-oss-120b and gpt-oss-20b, reasoning tokens are billed as output tokens. Gemma 4 26B A4B (gemma-4-26b-a4b) is $0.0375 / M input and $0.1275 / M output. Draft for review. Marketing will replace this copy. Qwen3 VL 30B A3B (qwen3-vl-30b-a3b) is $0.06 / M input and $0.225 / M output. olmOCR 2 7B (olmocr-2-7b-1025) is $0.075 / M input and $0.075 / M output. Whisper Large v3 Turbo (whisper-large-v3-turbo) is $0.0006 / audio minute ($0.036 / audio hour), billed in whole seconds, and free tokens do not apply to it. The minimum top-up is $10 and the billing page starts at $25. Verified accounts also receive a one-time token credit, spent before the dollar balance on token-priced models. Purchased credit does not expire and is non-refundable; free and promotional credit has no cash value. See the terms. The calculator at /pricing#estimator posts to POST /api/estimate and shows reference prices, each marked with its as-of date (2026-10-11). Different models; prices shown for cost comparison only.