AsyncBatches Class — anthropic-sdk-python Architecture
Architecture documentation for the AsyncBatches class in batches.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD c731f4b8_455b_5488_a095_755b0070aedd["AsyncBatches"] f98629a5_73f4_23f2_1f7f_c8db837848d1["AsyncAPIResource"] c731f4b8_455b_5488_a095_755b0070aedd -->|extends| f98629a5_73f4_23f2_1f7f_c8db837848d1 98cff8d0_3ebf_8e08_3589_f0757068fb58["batches.py"] c731f4b8_455b_5488_a095_755b0070aedd -->|defined in| 98cff8d0_3ebf_8e08_3589_f0757068fb58 4e0f9f5d_d08b_2976_0c7f_20b41ca3fd9c["with_raw_response()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 4e0f9f5d_d08b_2976_0c7f_20b41ca3fd9c 76663a20_a96c_dec0_b786_c2e30f313ccf["with_streaming_response()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 76663a20_a96c_dec0_b786_c2e30f313ccf b54deab4_98e8_9cde_eb32_5233f50cb95b["create()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| b54deab4_98e8_9cde_eb32_5233f50cb95b 90a3fc39_63ec_f9ad_319d_de27ce6dd962["retrieve()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 90a3fc39_63ec_f9ad_319d_de27ce6dd962 336b3acb_05a1_3333_7a54_bcd38f9ee176["list()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 336b3acb_05a1_3333_7a54_bcd38f9ee176 0f4bceb3_c426_1fe4_64cd_bf2b122ad7eb["delete()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 0f4bceb3_c426_1fe4_64cd_bf2b122ad7eb d15edac0_68bf_d4a3_0a9e_92d2987b73cf["cancel()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| d15edac0_68bf_d4a3_0a9e_92d2987b73cf 93278600_427e_5359_fec5_e7c0f20d5529["results()"] c731f4b8_455b_5488_a095_755b0070aedd -->|method| 93278600_427e_5359_fec5_e7c0f20d5529
Relationship Graph
Source Code
src/anthropic/resources/messages/batches.py lines 330–630
class AsyncBatches(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncBatchesWithRawResponse:
"""
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 AsyncBatchesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncBatchesWithStreamingResponse:
"""
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 AsyncBatchesWithStreamingResponse(self)
async 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 await self._post(
"/v1/messages/batches",
body=await async_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,
)
async 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 AsyncBatches class?
AsyncBatches is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/messages/batches.py.
Where is AsyncBatches defined?
AsyncBatches is defined in src/anthropic/resources/messages/batches.py at line 330.
What does AsyncBatches extend?
AsyncBatches extends AsyncAPIResource.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free