layer-groupBatch Processing

Upload Batch File

post

Uploads a JSONL file containing multiple batch requests. Each line must include custom_id, provider, method, url, and body. Returns file_id for use in /batches endpoint.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
filestring · binaryRequired

JSONL file containing batch requests. Each line must be a valid JSON object with custom_id, provider, method, url, and body fields.

purposestring · enumOptional

File purpose (always 'batch' for batch processing)

Default: batchPossible values:
Responses
chevron-right
200

File uploaded successfully - use file_id in next step

application/json
file_idstringOptional

Unique file identifier - use this in batch creation

Example: file-abcdef12345
idstringOptional

Same as file_id

filenamestringOptional

Original filename

Example: sample.jsonl
num_rowsintegerOptional

Number of requests in the file

Example: 4
urlstring · uriOptional

Storage URL for the uploaded file

objectstringOptionalExample: file
bytesintegerOptional

File size in bytes

created_atintegerOptional

Unix timestamp

purposestringOptionalExample: batch
post
/v1/files

Create Batch

post

Creates a batch processing job with uploaded file_id. Provides 50% cost savings for asynchronous processing. Supports /v1/chat/completions and /v1/embeddings endpoints. Completion window: 24h.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Body
input_file_idstringRequired

The file_id returned from the file upload step. Must be a valid JSONL file with batch requests.

Example: file-abcdef12345
endpointstring · enumRequired

API endpoint to process. Must match the request types in your JSONL file.

Example: /v1/chat/completionsPossible values:
completion_windowstring · enumRequired

Time window for batch completion. Currently only '24h' is supported.

Default: 24hPossible values:
metadataobjectOptional

Optional metadata object for tracking or organization purposes

Responses
chevron-right
200

Batch created successfully - save batch_id for status checks

application/json
batch_idstringOptional

Unique batch identifier - use this to check status

Example: fr_batch-abc123
idstringOptional

Same as batch_id

Example: fr_batch-abc123
objectstringOptionalExample: batch
endpointstringOptionalExample: /v1/chat/completions
statusstring · enumOptional

Current batch status

Possible values:
created_atintegerOptional

Unix timestamp

input_file_idstringOptional

Input file ID

completion_windowstringOptionalExample: 24h
post
/v1/batches

Get Batch Status

get

Retrieves batch processing status. Poll until status is completed, then use output_file_id to download results. Status values: validating, in_progress, finalizing, completed, failed, cancelled, expired.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Path parameters
batch_idstringRequired

Batch ID returned from batch creation

Example: fr_batch-abc123
Responses
chevron-right
200

Batch status and details

application/json
idstringOptional

Batch ID

Example: fr_batch-abc123
objectstringOptionalExample: batch
endpointstringOptionalExample: /v1/chat/completions
modelstringOptional

Model used (if applicable)

errorsobject · nullableOptional

Error information if batch failed

input_file_idstringOptional

Input file ID

completion_windowstringOptionalExample: 24h
statusstring · enumOptional

Current batch status

Possible values:
output_file_idstring · nullableOptional

Output file ID - use this with /files/{file_id}/content to download results (available when completed)

error_file_idstring · nullableOptional

Error file ID if some requests failed

created_atintegerOptional

Batch creation timestamp

in_progress_atintegerOptional

When batch started processing

expires_atintegerOptional

Expiration timestamp

finalizing_atintegerOptional

When batch entered finalizing state

completed_atinteger · nullableOptional

Completion timestamp (null if not completed)

failed_atinteger · nullableOptional

Failure timestamp (null if not failed)

expired_atinteger · nullableOptional
cancelling_atinteger · nullableOptional
cancelled_atinteger · nullableOptional
usageobjectOptional

Token usage and cost information

metadataobject · nullableOptional

Custom metadata if provided

get
/v1/batches/{batch_id}

Download Batch Results

get

Downloads the output JSONL file once batch processing is completed. Use the output_file_id from the batch status response. Each line contains the custom_id, error (if any), and response with body and status_code.

Authorizations
AuthorizationstringRequired

FastRouter API Key. Get yours at https://fastrouter.ai

Format: Authorization: Bearer YOUR_API_KEY

Path parameters
file_idstringRequired

Output file ID from batch status response (e.g., batch-output-fr_batch-abc123abc123.jsonl)

Example: batch-output-fr_batch-abc123abc123.jsonl
Responses
chevron-right
200

Batch results file in JSONL format. Each line contains a response for one request.

application/x-ndjson
stringOptional

JSONL content with one result per line. Each line is a JSON object with custom_id, error (null if successful), and response object containing body and status_code.

get
/v1/files/{file_id}/content

Last updated