Skip to main content
The Batch API lets you submit large collections of inference requests as a single asynchronous job, making it the best choice for workloads like bulk document classification, multilingual translation pipelines, and large-scale data extraction. Instead of sending thousands of individual requests in real time, you upload a JSONL input file, create a batch job, and retrieve the results once processing is complete — all at reduced cost compared to synchronous inference.

Endpoints


Create a Batch

Submit a new asynchronous batch job by referencing a previously uploaded input file and specifying which inference endpoint should process each request in that file. POST /v1/batches
string
required
The file ID returned by POST /v1/files when you uploaded your JSONL request file. Example: file-abc123.
string
required
The inference endpoint to invoke for every request in the batch. Use "/v1/chat/completions" for chat models.
string
The maximum time window Meliai is allowed to take to complete the batch. Accepts durations such as "24h". Defaults to "24h" when omitted.

Batch Status Values

Poll GET /v1/batches/{id} to track progress. The status field in the response will be one of the following values.

Input File Format

Your input file must be a JSONL file (one JSON object per line). Each line represents a single inference request and must include a custom_id you define, the HTTP method, the target url, and a body matching the schema of the chosen endpoint.
The custom_id is echoed back in every output line, so you can match results to the original requests after the batch completes.

Retrieve and Download Results

Once you have a batch ID, poll its status and then fetch the output file when processing finishes. Check batch status — GET /v1/batches/{id}
Download results — GET /v1/files/{output_file_id}/content Once status is "completed", retrieve the output JSONL file using the output_file_id from the batch object.
Each line in the output JSONL includes the original custom_id, the HTTP status_code, and a response body in the same shape as a synchronous inference response.

List Batches

Retrieve all batch jobs associated with your account.

Cancel a Batch

Send a cancellation request to stop an in-progress batch. Requests that have already been processed will still appear in the output file.
Add the :batch routing suffix to the model ID in each request body (e.g. "model": "mistral-7b:batch") to unlock maximum cost savings. The :batch flavor routes your requests to the lowest-cost available provider for non-latency-sensitive workloads.