Skip to content

Files and batches

A batch runs a file of requests in the background and writes the answers to another file within 24 hours. Both endpoints follow OpenAI’s Files and Batch APIs.

Upload a file as multipart/form-data:

Terminal window
curl https://api.indorouter.ai/v1/files \
-H "Authorization: Bearer $INDOROUTER_API_KEY" \
-F purpose=batch \
-F file=@requests.jsonl
Field Notes
file Required. Up to 50 MB.
purpose batch for a batch input file, or user_data.
expires_after[seconds] How long to keep the file, from 3,600 (one hour) to 2,592,000 (30 days). Without it, the file is kept 30 days.

The response is the file object: id (it starts with file-), object, bytes, created_at, expires_at, filename, purpose and status.

Request What it does
GET /v1/files Lists your files, newest first. Takes purpose, limit (1 to 10,000, default 20) and after (a file ID, for the next page).
GET /v1/files/{id} One file object.
GET /v1/files/{id}/content Returns the file contents.
DELETE /v1/files/{id} Deletes the file’s contents immediately.

Files are stored encrypted, and are visible only to the person whose key uploaded them. When a file expires its contents are deleted. File storage is free.

Each line of the input file is one request, in this form:

{"custom_id": "req-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "hello"}]}}

custom_id must be unique within the file, and url must be the batch’s endpoint. A file may have up to 50,000 lines. Upload it with purpose=batch, then start the batch:

Terminal window
curl https://api.indorouter.ai/v1/batches \
-H "Authorization: Bearer $INDOROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input_file_id": "file-...",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"}'
Field Notes
input_file_id Required. A file uploaded with purpose=batch.
endpoint /v1/chat/completions, /v1/embeddings, /v1/completions or /v1/responses. Images, audio and video cannot be batched.
completion_window 24h, the only window.
metadata Optional, returned as you sent it.

We check the whole file when you create the batch. An invalid file produces a batch with status: "failed" and an errors list naming the line and what is wrong with it (up to 100 entries).

The batch object has id (it starts with batch_), status, request_counts (total, completed, failed), output_file_id, error_file_id and a timestamp for each stage. status is one of validating, in_progress, finalizing, completed, failed, expired, cancelling or cancelled. A batch that has not finished 24 hours after it was created becomes expired, and the lines that did run keep their answers.

Request What it does
GET /v1/batches Lists your batches. Takes limit (1 to 100, default 20) and after.
GET /v1/batches/{id} One batch.
POST /v1/batches/{id}/cancel Stops a batch that is still validating or in_progress. Lines already run keep their answers.

When a batch ends, successful answers go to the file in output_file_id and failed lines to the file in error_file_id. Download them from GET /v1/files/{id}/content. They are kept for 30 days.

Each line is charged like the same request sent on its own, at the current price, and counts toward the key’s spending limits. A line refused for lack of balance goes to the error file. Some OpenAI chat models have a lower batch price: a chat batch whose every line uses such a model runs through OpenAI’s own Batch API and is charged that price. These models list an entry with "kind": "batch" under overrides in GET /v1/models.

Creating a batch takes an API key. Listing, reading and cancelling batches, and every files request, also work with an admin key. The Idempotency-Key header works on POST /v1/batches. See Error codes for errors and how to handle them.