Send large volumes of requests asynchronously using the Batch API. Process chat completions, embeddings, and image generations in bulk with a 24-hour completion window.
Use this file to discover all available pages before exploring further.
The Batch API lets you send groups of requests as a single job that processes asynchronously.
This is useful when you need to run many requests and do not need immediate results — for example, running evaluations, generating embeddings for a large dataset, or classifying content in bulk.Batch requests run within a 24-hour completion window and have separate, higher rate limits than synchronous API calls.
Poll the batch until it reaches a terminal status.
mka1 llm batches get --batch-id batch_abc123
Here is a polling helper that waits for the batch to finish:
# Poll a batch until it reaches a terminal status using --jq and a shell loop.BATCH_ID=batch_abc123while :; do STATUS=$(mka1 llm batches get --batch-id "$BATCH_ID" --jq '.status' --output-format json) echo "status: $STATUS" case "$STATUS" in completed|failed|cancelled|expired) break ;; esac sleep 2done
Once the batch is completed, download the output file. It is a JSONL file where each line contains the custom_id you provided, the response, and any error.
# Download the JSONL output filemka1 llm files content \ --file-id file_xyz789 \ --output-file ./batch_output.jsonl# Inspect the results inline with jqmka1 llm files content --file-id file_xyz789 \ --jq '"\(.custom_id): status=\(.response.status_code)"'
If a request failed, response is null and error contains the details:
{ "id": "response_def456", "custom_id": "request-2", "response": null, "error": { "code": "processing_error", "message": "The request could not be processed." }}
If any requests failed, the batch also provides an error_file_id containing only the failed entries.