Cancel batch

POSThttps:/api.openai.com/v1/batches/{batch_id}/cancel

Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will have partial results (if any) available in the output file.

Path parameters

  • batch_id
    string
    Required
    The ID of the batch to cancel.

Response

The Batch object matching the specified ID.

Example request
1
curl https://api.openai.com/v1/batches/batch_abc123/cancel \
2
-H "Authorization: Bearer $OPENAI_API_KEY" \
3
-H "Content-Type: application/json" \
4
-X POST
Example response
1
{
2
"id": "batch_abc123",
3
"object": "batch",
4
"endpoint": "/v1/chat/completions",
5
"errors": null,
6
"input_file_id": "file-abc123",
7
"completion_window": "24h",
8
"status": "cancelling",
9
"output_file_id": null,
10
"error_file_id": null,
11
"created_at": 1711471533,
12
"in_progress_at": 1711471538,
13
"expires_at": 1711557933,
14
"finalizing_at": null,
15
"completed_at": null,
16
"failed_at": null,
17
"expired_at": null,
18
"cancelling_at": 1711475133,
19
"cancelled_at": null,
20
"request_counts": {
21
"total": 100,
22
"completed": 23,
23
"failed": 1
24
},
25
"metadata": {
26
"customer_id": "user_123456789",
27
"batch_description": "Nightly eval job",
28
}
29
}
Built with