claude-opus-4-1-20250805
)claude-opus-4-20250514
)claude-sonnet-4-20250514
)claude-3-7-sonnet-20250219
)claude-3-5-sonnet-20240620
and claude-3-5-sonnet-20241022
)claude-3-5-haiku-20241022
)claude-3-haiku-20240307
)claude-3-opus-20240229
)Model | Batch input | Batch output |
---|---|---|
Claude Opus 4.1 | $7.50 / MTok | $37.50 / MTok |
Claude Opus 4 | $7.50 / MTok | $37.50 / MTok |
Claude Sonnet 4 | $1.50 / MTok | $7.50 / MTok |
Claude Sonnet 3.7 | $1.50 / MTok | $7.50 / MTok |
Claude Sonnet 3.5 | $1.50 / MTok | $7.50 / MTok |
Claude Haiku 3.5 | $0.40 / MTok | $2 / MTok |
Claude Opus 3 | $7.50 / MTok | $37.50 / MTok |
Claude Haiku 3 | $0.125 / MTok | $0.625 / MTok |
custom_id
for identifying the Messages requestparams
object with the standard Messages API parametersrequests
parameter:
custom_id
and contains the standard parameters you’d use for a Messages API call.
params
object for each message request is performed asynchronously, and validation errors are returned when processing of the entire batch has ended. You can ensure that you are building your input correctly by verifying your request shape with the Messages API first.in_progress
.
processing_status
field indicates the stage of processing the batch is in. It starts as in_progress
, then updates to ended
once all the requests in the batch have finished processing, and results are ready. You can monitor the state of your batch by visiting the Console, or using the retrieval endpoint:
Result Type | Description |
---|---|
succeeded | Request was successful. Includes the message result. |
errored | Request encountered an error and a message was not created. Possible errors include invalid requests and internal server errors. You will not be billed for these requests. |
canceled | User canceled the batch before this request could be sent to the model. You will not be billed for these requests. |
expired | Batch reached its 24 hour expiration before this request could be sent to the model. You will not be billed for these requests. |
request_counts
, which shows how many requests reached each of these four states.
Results of the batch are available for download at the results_url
property on the Message Batch, and if the organization permission allows, in the Console. Because of the potentially large size of the results, it’s recommended to stream results back rather than download them all at once.
.jsonl
format, where each line is a valid JSON object representing the result of a single request in the Message Batch. For each streamed result, you can do something different depending on its custom_id
and result type. Here is an example set of results:
result.error
will be set to our standard error shape.
custom_id
field.cache_control
blocks in every Message request within your batchcache_control
to increase the likelihood of cache hits.
custom_id
values to easily match results with requests, since order is not guaranteed.request_too_large
error.custom_id
.created_at
(not processing ended_at
) time. If over 29 days have passed, results will no longer be viewable.How long does it take for a batch to process?
Is the Batches API available for all models?
Can I use the Message Batches API with other API features?
How does the Message Batches API affect pricing?
Can I update a batch after it's been submitted?
Are there Message Batches API rate limits and do they interact with the Messages API rate limits?
How do I handle errors in my batch requests?
result
field indicating whether it succeeded
, errored
, was canceled
, or expired
. For errored
results, additional error information will be provided. View the error response object in the API reference.How does the Message Batches API handle privacy and data separation?
Can I use prompt caching in the Message Batches API?