Batches Class — anthropic-sdk-python Architecture
Architecture documentation for the Batches class in batches.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 2a025d5d_3057_7bf3_fea3_d693a30b85ec["Batches"] 32bd9d9e_8b62_b229_7718_45771b424c40["SyncAPIResource"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|extends| 32bd9d9e_8b62_b229_7718_45771b424c40 98cff8d0_3ebf_8e08_3589_f0757068fb58["batches.py"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|defined in| 98cff8d0_3ebf_8e08_3589_f0757068fb58 5fc08c95_6111_b509_a2d5_a1696176fb2b["with_raw_response()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 5fc08c95_6111_b509_a2d5_a1696176fb2b ac890a05_1e22_c64c_451f_8852c6fafb51["with_streaming_response()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| ac890a05_1e22_c64c_451f_8852c6fafb51 67bbe556_2c2b_af81_4b28_d25dd002fec9["create()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 67bbe556_2c2b_af81_4b28_d25dd002fec9 8215ec2b_8430_7898_ef69_d6b26e8479e1["retrieve()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 8215ec2b_8430_7898_ef69_d6b26e8479e1 4c022c9e_d487_75fa_327c_44ce5e30d464["list()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 4c022c9e_d487_75fa_327c_44ce5e30d464 4c9f043c_b20d_4634_768f_7a53117fd149["delete()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 4c9f043c_b20d_4634_768f_7a53117fd149 7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6["cancel()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| 7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6 d5e9ac6c_f683_9e1a_0642_8431b65dab96["results()"] 2a025d5d_3057_7bf3_fea3_d693a30b85ec -->|method| d5e9ac6c_f683_9e1a_0642_8431b65dab96
Relationship Graph
Source Code
src/anthropic/resources/messages/batches.py lines 27–327
class Batches(SyncAPIResource):
@cached_property
def with_raw_response(self) -> BatchesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return BatchesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> BatchesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return BatchesWithStreamingResponse(self)
def create(
self,
*,
requests: Iterable[batch_create_params.Request],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> MessageBatch:
"""
Send a batch of Message creation requests.
The Message Batches API can be used to process multiple Messages API requests at
once. Once a Message Batch is created, it begins processing immediately. Batches
can take up to 24 hours to complete.
Learn more about the Message Batches API in our
[user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
Args:
requests: List of requests for prompt completion. Each is an individual request to create
a Message.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/v1/messages/batches",
body=maybe_transform({"requests": requests}, batch_create_params.BatchCreateParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=MessageBatch,
)
def retrieve(
self,
message_batch_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> MessageBatch:
"""This endpoint is idempotent and can be used to poll for Message Batch
completion.
To access the results of a Message Batch, make a request to the
`results_url` field in the response.
Learn more about the Message Batches API in our
[user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the Batches class?
Batches is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/messages/batches.py.
Where is Batches defined?
Batches is defined in src/anthropic/resources/messages/batches.py at line 27.
What does Batches extend?
Batches extends SyncAPIResource.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free