Files & Batches
Create Batch
Create a batch from an uploaded JSONL file.
Overview
Upload a JSONL file with purpose=batch, then use its ID as input_file_id. Completed batches return output and error file IDs.
Notes
- Batch input files must use
purpose=batch. completion_windowis currently24h.- Output order may differ from input order. Match each result by
custom_id. - Streaming is not supported inside batch items.
- Supported item endpoints are
/v1/chat/completionsand/v1/embeddings./v1/responsesis not supported.
Example
Request
curl -X POST "https://api.tokenlab.sh/v1/batches" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file_abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'Batch prices may differ from synchronous requests. Use the price shown when creating the batch and the final bill.
Response
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file_abc123",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1706000000
}Important fields
idstring
Batch ID.
statusstring
Batch status.
output_file_idstring|null
Output file ID after completion.
Authorization
BearerAuth AuthorizationBearer <token>
API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Headers
X-TokenLab-Delivery-Policy?string
Per-request Delivery policy. Overrides the API key and Workspace defaults. Auto tries TokenLab Verified first and may switch once to Official only before output, request acceptance, or persistent resource creation.
Value in
- "auto"
- "verified"
- "official"
Request Body
application/json
Response
application/json
application/json
application/json
application/json
application/json