API reference
Batches
Create a batch
POST https://antarya.ai/v1/batches
Send a list of chat requests, each with a custom_id you choose. Antarya runs them in the background, billed at the batch rate. The guide walks through the whole cycle.
Headers
| Header | Value |
|---|---|
Authorization |
Bearer $ANTARYA_API_KEY |
Content-Type |
application/json |
curl https://antarya.ai/v1/batches \
-H "Authorization: Bearer $ANTARYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{
"custom_id": "contract-001",
"params": {"messages": [{"role": "user", "content": "Summarise this contract'"'"'s termination clause."}]}
}
]
}'{
"id": "batch_01",
"status": "in_progress",
"request_counts": {"total": 1, "done": 0}
}| Name | Type | Required | Description |
|---|---|---|---|
requests | array | YesRequired | The requests to run. |
custom_id | text | YesRequired | Your own label for the request. Each one in a batch must be different. |
params | object | YesRequired | The body of a chat request, with the same fields as POST /v1/chat except `stream` and `session_id`, which a batch request cannot use. |
The batch object
| Name | Type | Required | Description |
|---|---|---|---|
id | text | YesRequired | The id of the batch, such as batch_01. |
status | text | YesRequired | "in_progress" while requests are running, "ended" when all have finished or the batch was cancelled. |
request_counts | object | YesRequired | How many requests the batch holds and how many have finished. |
total | number | YesRequired | Requests in the batch. |
done | number | YesRequired | Requests that have a reply or an error. |
Read, collect and cancel
| Request | Does |
|---|---|
GET /v1/batches/{id} |
Returns the batch object. |
GET /v1/batches/{id}/results |
Once the status is ended, returns one line of JSON per request, each with its custom_id and either a reply or an error. Read error first. The lines may come in any order. |
POST /v1/batches/{id}/cancel |
Stops the requests that have not run. Finished requests keep their replies. |
curl https://antarya.ai/v1/batches/batch_01/results \
-H "Authorization: Bearer $ANTARYA_API_KEY"{"custom_id": "contract-001", "reply": {"id": "req_09", "model": "antarya", "content": [{"type": "text", "text": "Either side can end the agreement with 30 days of written notice."}], "stop_reason": "end_turn", "usage": {"input_tokens": 24, "output_tokens": 17}}}
{"custom_id": "contract-002", "error": {"type": "overloaded", "message": "This request did not run within 24 hours."}}Limits
A batch holds up to 1,000 requests and its results arrive within 24 hours. A request still unrun after 24 hours comes back as a result line with an error of type overloaded and the message "This request did not run within 24 hours." A request cancelled before it ran comes back as an error of type invalid_request. The batch object has only the statuses in_progress and ended. Results are kept for 30 days after the batch ends. An account can have 5 batches in progress and 10,000 queued requests. Calls to the batch endpoints count against the management limit in rate limits; the requests inside a batch do not count against the chat limits.
| Limit | Value |
|---|---|
| Requests in one batch | 1,000 requests |
| Time to finish | Within 24 hours |
| Batches in progress | 5 an account |
| Queued requests | 10,000 an account |
| Batch price | To be announced |