Batch processing is provider-dependent. Check your provider’s documentation for supported endpoints and file formats.
Create a batch
POST /v1/batches
Creates a new batch job from a previously uploaded .jsonl file.
Request
string
required
The provider to route the request to (e.g.
openai).string
required
Your Portkey API key or provider API key.
string
required
The ID of the uploaded file containing the batch requests. Use
POST /v1/files to upload this file with purpose=batch.string
required
The API endpoint to run the batch against. For example,
/v1/chat/completions.string
required
The time window for completion. Currently
24h is the most commonly supported value.object
Optional key-value metadata to attach to the batch object.
Response
string
Unique identifier for the batch.
string
Always
batch.string
The API endpoint the batch runs against.
string
Current status of the batch. Values:
validating, in_progress, completed, failed, cancelled.string
The ID of the input file.
string
The ID of the output file once the batch has completed.
number
Unix timestamp when the batch was created.
number
Unix timestamp when the batch completed, or
null if still in progress.object
List batches
GET /v1/batches
Returns a list of batch jobs for the configured provider.
Request
string
required
The provider to route the request to.
string
required
Your Portkey API key or provider API key.
number
default:"20"
Maximum number of batches to return.
string
Cursor for pagination. Pass the
id of the last batch from the previous page.Response
string
Always
list.array
Array of batch objects.
boolean
Whether additional batches are available beyond this page.
Retrieve a batch
GET /v1/batches/:id
Retrieves a single batch job by its ID. Use this to poll the status of an in-progress batch.
Request
string
required
The ID of the batch to retrieve.
string
required
The provider to route the request to.
string
required
Your Portkey API key or provider API key.
Response
Returns a single batch object. See Create a batch for the full field list.Get batch output
GET /v1/batches/*/output
Retrieves the output file content for a completed batch. The wildcard path segment accepts the batch ID.
The batch must have
status: completed before output is available. Retrieve the batch first to check its output_file_id, then use GET /v1/files/:id/content to download the output directly.Request
string
required
The batch ID. For example,
/v1/batches/batch-xyz789/output.string
required
The provider to route the request to.
string
required
Your Portkey API key or provider API key.
Response
Returns the raw.jsonl output content. Each line corresponds to a response for a single request in the batch.
Cancel a batch
POST /v1/batches/:id/cancel
Cancels an in-progress batch. Requests that have already been processed are not reversed.
Request
string
required
The ID of the batch to cancel.
string
required
The provider to route the request to.
string
required
Your Portkey API key or provider API key.
Response
Returns the updated batch object withstatus: cancelling.