For the complete documentation index, see llms.txt. This page is also available as Markdown.

Batch Processing

Batch processing (batching) allows you to send multiple message requests in a single batch and retrieve the results later (within up to 1 hour). The main goals are to reduce costs by up to 50% and increase throughput for analytical or offline workloads.

To use batch processing, several endpoints are available:

Create a message batch

https://api.aimlapi.com/batches

Get status or results of a batch

https://api.aimlapi.com/batches?batch_id={batch_id}

Cancel a batch

https://api.aimlapi.com/batches/cancel/{batch_id}


Create a batch

post
Body
Responses
200Success
application/json
idstringRequired

Unique identifier of the batch.

Example: kgTRCVoAz4GwrHWIOFZjg
typestringRequired

Object type.

Example: message_batch
processing_statusstringRequired

Current processing status of the batch.

Example: in_progress
ended_atstring · date-time · nullableOptional

Timestamp when the batch finished processing, if completed.

created_atstring · date-timeRequired

Timestamp when the batch was created.

Example: 2026-05-04T17:27:37.468424+00:00
expires_atstring · date-timeRequired

Timestamp when the batch will expire if not completed.

Example: 2026-05-05T17:27:37.468424+00:00
archived_atstring · date-time · nullableOptional

Timestamp when the batch was archived, if applicable.

cancel_initiated_atstring · date-time · nullableOptional

Timestamp when cancellation was initiated, if applicable.

results_urlstring · nullableOptional

URL to download batch results once processing is complete.

200Success
{
  "id": "kgTRCVoAz4GwrHWIOFZjg",
  "type": "message_batch",
  "processing_status": "in_progress",
  "request_counts": {
    "processing": 3,
    "succeeded": 0,
    "errored": 0,
    "canceled": 0,
    "expired": 0
  },
  "ended_at": "2026-01-01T00:00:00.000Z",
  "created_at": "2026-05-04T17:27:37.468424+00:00",
  "expires_at": "2026-05-05T17:27:37.468424+00:00",
  "archived_at": "2026-01-01T00:00:00.000Z",
  "cancel_initiated_at": "2026-01-01T00:00:00.000Z",
  "results_url": "text"
}
Code Example (Python)
Response

Get status or results of a batch

get
Query parameters
batch_idstringRequired

The ID of the batch to retrieve its status and results.

Example: <REPLACE_WITH_YOUR_BATCH_ID>
Responses
200Success
application/json
idstringRequired

Unique identifier of the batch.

Example: msgbatch_01McVJYhQd3Wiuqrac6y9PrX
typestringRequired

Object type.

Example: message_batch
processing_statusstringRequired

Current processing status of the batch.

Example: in_progress
ended_atstring · date-time · nullableOptional

Timestamp when the batch finished processing, if completed.

created_atstring · date-timeRequired

Timestamp when the batch was created.

Example: 2025-10-24T13:49:11.902215+00:00
expires_atstring · date-timeRequired

Timestamp when the batch will expire if not completed.

Example: 2025-10-25T13:49:11.902215+00:00
cancel_initiated_atstring · date-time · nullableOptional

Timestamp when cancellation was initiated, if applicable.

results_urlstring · nullableOptional

URL to download batch results once processing is complete.

200Success
{
  "id": "msgbatch_01McVJYhQd3Wiuqrac6y9PrX",
  "type": "message_batch",
  "processing_status": "in_progress",
  "request_counts": {
    "processing": 3,
    "succeeded": 0,
    "errored": 0,
    "canceled": 0,
    "expired": 0
  },
  "ended_at": "2026-01-01T00:00:00.000Z",
  "created_at": "2025-10-24T13:49:11.902215+00:00",
  "expires_at": "2025-10-25T13:49:11.902215+00:00",
  "cancel_initiated_at": "2026-01-01T00:00:00.000Z",
  "results_url": "text"
}
Code Example (Python)
Response #1 (status: generating)
Response #2 (status: if already cancelled)
Response #3 (if already finished)

Cancel a batch

post
Path parameters
batch_idstringRequired

The ID of the batch to cancel.

Example: <REPLACE_WITH_YOUR_BATCH_ID>
Responses
200Success
application/json
idstringRequired

Unique identifier of the batch.

Example: fe91QH0tkQwaJSXo0q77O
statusstringRequired

Final status of the batch after cancellation.

Example: cancelled
outputany · nullableRequired

Batch output, if available.

usageobject[]Required

Usage details for the batch.

200Success
{
  "id": "fe91QH0tkQwaJSXo0q77O",
  "status": "cancelled",
  "output": null,
  "usage": []
}
Code Example (Python)
Response #1 (successfully cancelled)
Response #2 (if already finished)

Last updated

Was this helpful?