BATCHES
Cancel a Batch
Cancel an in-progress batch. The batch status will transition to "cancelling" and eventually "cancelled".
Authorization
AuthorizationstringheaderrequiredBearer token — your API key. Example: Bearer sk-...
Response
idstringrequiredThe batch ID (e.g. "batch_abc123").
object"batch"requiredObject type — always "batch".
endpointstringrequiredThe API endpoint used for requests in this batch.
errorsanyrequiredValidation or processing errors, if any.
input_file_idstringrequiredThe ID of the input file for this batch.
completion_windowstringrequiredThe time window for batch completion.
status"validating" | "failed" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled"requiredThe current status of the batch.
validatingfailedin_progressfinalizingcompletedexpiredcancellingcancelledoutput_file_idstringrequiredThe ID of the output file with successful results.
error_file_idstringrequiredThe ID of the file containing error results.
created_atintegerrequiredUnix timestamp of when the batch was created.
in_progress_atintegerrequiredUnix timestamp of when processing started.
expires_atintegerrequiredUnix timestamp of when the batch expires.
finalizing_atintegerrequiredUnix timestamp of when finalization started.
completed_atintegerrequiredUnix timestamp of when the batch completed.
failed_atintegerrequiredUnix timestamp of when the batch failed.
expired_atintegerrequiredUnix timestamp of when the batch expired.
cancelling_atintegerrequiredUnix timestamp of when cancellation started.
cancelled_atintegerrequiredUnix timestamp of when the batch was cancelled.
request_countsobjectrequiredRequest processing counts.
metadataobjectrequiredUser-provided metadata key-value pairs.
Request
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-scx-api-key",
baseURL: "https://api.scx.ai/v1",
});
const batch = await client.batches.cancel("batch_abc123def456");
console.log(batch.status); // "cancelling"import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-scx-api-key",
baseURL: "https://api.scx.ai/v1",
});
const batch = await client.batches.cancel("batch_abc123def456");
console.log(batch.status); // "cancelling"Response
{
"id": "batch_abc123def456",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"completion_window": "24h",
"status": "cancelling",
"output_file_id": null,
"error_file_id": null,
"created_at": 1711756800,
"in_progress_at": 1711756810,
"expires_at": 1711843200,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": 1711758600,
"cancelled_at": null,
"request_counts": {
"total": 100,
"completed": 45,
"failed": 0
},
"metadata": {}
}{
"id": "batch_abc123def456",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"completion_window": "24h",
"status": "cancelling",
"output_file_id": null,
"error_file_id": null,
"created_at": 1711756800,
"in_progress_at": 1711756810,
"expires_at": 1711843200,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": 1711758600,
"cancelled_at": null,
"request_counts": {
"total": 100,
"completed": 45,
"failed": 0
},
"metadata": {}
}