Anthropic::Messages::BatchAPI
Constants
Constructors
Instance methods
Cancel a batch that is in progress.
Create a new message batch for asynchronous processing.
Create a batch from an array of batch requests.
Delete a message batch.
Sends DELETE /v1/messages/batches/{batch_id} and returns a
typed MessageBatchDeleted response.
List all message batches with pagination.
Auto-paginating iterator for listing all message batches. Returns an AutoPaginator that fetches pages lazily as you iterate.
Example:
client.batches.list_all(limit: 20).each do |batch|
puts batch.id
end
Get results for a completed batch. Streams NDJSON results line-by-line for memory efficiency.
The actual API returns a streaming NDJSON response at
GET /v1/messages/batches/{batch_id}/results.
This method first retrieves the batch to find the results_url,
then streams the NDJSON response and parses it line-by-line.
Results are yielded one at a time, allowing processing of very large batches without loading the entire response into memory.
Raises:
BatchResultsNotReadyErrorif the batch has not completed (results_url is nil)URLAuthorityMismatchErrorif the results_url authority differs from the client's base_url