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 ed73efe2_f340_c24f_2bf4_933c18889495["AsyncBatches"] f98629a5_73f4_23f2_1f7f_c8db837848d1["AsyncAPIResource"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|extends| f98629a5_73f4_23f2_1f7f_c8db837848d1 b2b2bd85_e598_f0e9_64e6_661945bb42ac["batches.py"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|defined in| b2b2bd85_e598_f0e9_64e6_661945bb42ac 2c89f89b_e2c5_4bc5_a71b_be4e3e3fc821["with_raw_response()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| 2c89f89b_e2c5_4bc5_a71b_be4e3e3fc821 a013ef3d_9b42_48b2_6079_ba1d2e7c8be7["with_streaming_response()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| a013ef3d_9b42_48b2_6079_ba1d2e7c8be7 eb402747_3f4c_1529_7731_07000b62d2de["create()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| eb402747_3f4c_1529_7731_07000b62d2de 71222aa7_f413_7f74_6de7_f1b11ab10d35["retrieve()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| 71222aa7_f413_7f74_6de7_f1b11ab10d35 8c77c911_8979_0571_1cd4_d288bc31b0db["list()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| 8c77c911_8979_0571_1cd4_d288bc31b0db af7e432d_a605_da02_e7ca_c9441ffa3360["delete()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| af7e432d_a605_da02_e7ca_c9441ffa3360 ecbd3b45_eca8_c03d_05f0_6940ca6cc72a["cancel()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| ecbd3b45_eca8_c03d_05f0_6940ca6cc72a 152e22b1_8e3c_0832_4a29_9c2ada3d5f79["results()"] ed73efe2_f340_c24f_2bf4_933c18889495 -->|method| 152e22b1_8e3c_0832_4a29_9c2ada3d5f79
Relationship Graph
Source Code
src/anthropic/resources/beta/messages/batches.py lines 416–800
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],
betas: List[AnthropicBetaParam] | Omit = omit,
# 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,
) -> BetaMessageBatch:
"""
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.
betas: Optional header to specify the beta version(s) you want to use.
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
"""
extra_headers = {
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else not_given
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
return await self._post(
"/v1/messages/batches?beta=true",
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=BetaMessageBatch,
)
async def retrieve(
self,
message_batch_id: str,
*,
betas: List[AnthropicBetaParam] | Omit = omit,
Domain
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/beta/messages/batches.py.
Where is AsyncBatches defined?
AsyncBatches is defined in src/anthropic/resources/beta/messages/batches.py at line 416.
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