Skip to main content
Self-hosted deployments require Enterprise Gateway v2.6.1+.
Portkey exposes Anthropic’s Message Batches API through the unified OpenAI-compatible /v1/batches endpoints. All five batch operations — create, retrieve, cancel, list, and get output — are supported, so you can run large, asynchronous Claude jobs at 50% lower cost without leaving the Portkey gateway. Use batches when you need to run large jobs offline — e.g. 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

Retrieve a Batch

Retrieving a batch returns the OpenAI-compatible Batch object. Once processing completes, the response additionally includes results_url pulled from Anthropic so you can stream outputs.

List Batches

Cancel a Batch

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, falling back to /messages/batches/{batch_id}/results if the URL is unavailable. The response body is streamed back as JSONL in Anthropic’s native format by default.
A typical output line looks like:

Response Format

createBatch, retrieveBatch, cancelBatch, and listBatches always return the OpenAI Batch shape so existing OpenAI tooling works unchanged:
  • object: "batch" and endpoint: "/v1/batches" on every batch record.
  • status values normalized to OpenAI-compatible strings (validating, in_progress, finalizing, completed, failed, cancelling, cancelled, expired).
  • Timestamps converted from Anthropic’s ISO 8601 format to Unix epoch seconds.
  • Request counts mapped: succeeded → completed, errored → failed.
  • retrieveBatch additionally surfaces results_url from the Anthropic response when the batch has finished processing.
getBatchOutput is the exception — it streams the raw Anthropic-native JSONL so you get per-request message objects with full Claude response fidelity (content blocks, tool use, stop reasons, usage).

See Also

Last modified on April 23, 2026