Self-hosted deployments require Enterprise Gateway v2.6.1+.
/v1/batches endpoints. All five batch operations — create, retrieve, cancel, list, and get output — are supported, enabling large asynchronous Claude jobs at 50% lower cost.
Use batches for offline workloads like nightly evals, bulk summarization, or dataset grading.
Supported Endpoints
Request Format
Unlike OpenAI’s file-based batches, Anthropic batch creation uses an inline
requests[] array — there is no input_file_id. Each item carries a custom_id and a params object containing the standard Messages API payload.Create a Batch
- Python
- NodeJS
- REST
- OpenAI Python
- OpenAI NodeJS
Retrieve a Batch
Returns the OpenAI-compatible Batch object. Once processing completes, the response includesresults_url from Anthropic.
- Python
- NodeJS
- REST
- OpenAI Python
- OpenAI NodeJS
List Batches
- Python
- NodeJS
- REST
- OpenAI Python
- OpenAI NodeJS
Cancel a Batch
- Python
- NodeJS
- REST
- OpenAI Python
- OpenAI NodeJS
Get Batch Output
Before streaming results, Portkey retrieves the batch metadata and verifies that
processing_status === 'ended'. It then fetches from Anthropic’s results_url, generating fresh SigV4-signed headers for the output URL. The response body is streamed back as JSONL in Anthropic’s native format.- REST
Response Format
createBatch, retrieveBatch, cancelBatch, and listBatches return the OpenAI Batch shape so existing OpenAI tooling works unchanged:
object: "batch"andendpoint: "/v1/batches"on every batch recordstatusvalues normalized to OpenAI-compatible strings (validating,in_progress,finalizing,completed,failed,cancelling,cancelled,expired)- Timestamps converted from Anthropic’s ISO 8601 to Unix epoch seconds
- Request counts mapped:
succeeded → completed,errored → failed retrieveBatchsurfacesresults_urlfrom the Anthropic response when the batch has finished processing
getBatchOutput streams the raw Anthropic-native JSONL for full Claude response fidelity (content blocks, tool use, stop reasons, usage).

