Skip to main content
DELETE
https://api.cerebras.ai
/
v1
/
batches
/
{batch_id}
from cerebras.cloud.sdk import Cerebras
import os

client = Cerebras(
    api_key=os.environ.get("CEREBRAS_API_KEY"),
)

batch = client.batches.cancel("batch_123")

print(batch)
{
    "id": "batch_xxxx",
    "object": "batch",
    "endpoint": "/v1/chat/completions",
    "errors": null,
    "input_file_id": "file-xxxx",
    "completion_window": "24h",
    "status": "calling",
    "output_file_id": null,
    "error_file_id": null,
    "created_at": 1765492780,
    "in_progress_at": null,
    "expires_at": null,
    "finalizing_at": null,
    "completed_at": 1765493188,
    "failed_at": null,
    "expired_at": null,
    "cancelling_at": 1765492797,
    "cancelled_at":null,
    "request_counts": null,
    "metadata": null
}
Cancels a batch job that is currently queued or running. Completed requests remain saved in the results and can be retrieved through the retrieve batch endpoint.

Path Parameters

batch_id
string
required
The ID of the batch job to cancel.

Response

id
string
A unique identifier for the batch job.
object
string
The object type, which is always batch.
endpoint
string
The API endpoint used for batch processing.
errors
object | null
Information about any errors that occurred during batch processing.
input_file_id
string
The ID of the input file containing batch requests.
completion_window
string
The time window for batch completion. Always 24h.
status
string
The status of the batch job. Will be cancelling immediately after calling cancel. Once cancellation is complete (up to 10 minutes), the status changes to cancelled.
output_file_id
string | null
The ID of the file containing batch results with any completed requests.
error_file_id
string | null
The ID of the file containing errors (if any errors occurred).
created_at
integer
The Unix timestamp (in seconds) of when the batch job was created.
in_progress_at
integer | null
The Unix timestamp (in seconds) of when the batch job started processing.
expires_at
integer | null
The Unix timestamp (in seconds) of when the batch job will expire.
finalizing_at
integer | null
The Unix timestamp (in seconds) of when the batch job started finalizing.
completed_at
integer | null
The Unix timestamp (in seconds) of when the batch job completed.
failed_at
integer | null
The Unix timestamp (in seconds) of when the batch job failed.
expired_at
integer | null
The Unix timestamp (in seconds) of when the batch job expired.
cancelling_at
integer | null
The Unix timestamp (in seconds) of when the batch job started cancelling.
cancelled_at
integer | null
The Unix timestamp (in seconds) of when the batch job was cancelled.
request_counts
object | null
Statistics about the requests in the batch (if available).
metadata
object | null
Custom metadata associated with the batch job.
When you cancel an in-progress batch, it will be in cancelling status for up to 10 minutes before changing to cancelled, where it will have partial results (if any) available in the output file.
from cerebras.cloud.sdk import Cerebras
import os

client = Cerebras(
    api_key=os.environ.get("CEREBRAS_API_KEY"),
)

batch = client.batches.cancel("batch_123")

print(batch)
{
    "id": "batch_xxxx",
    "object": "batch",
    "endpoint": "/v1/chat/completions",
    "errors": null,
    "input_file_id": "file-xxxx",
    "completion_window": "24h",
    "status": "calling",
    "output_file_id": null,
    "error_file_id": null,
    "created_at": 1765492780,
    "in_progress_at": null,
    "expires_at": null,
    "finalizing_at": null,
    "completed_at": 1765493188,
    "failed_at": null,
    "expired_at": null,
    "cancelling_at": 1765492797,
    "cancelled_at":null,
    "request_counts": null,
    "metadata": null
}