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 e2cc954c_b743_44af_8834_77533ae996fd["Batches"] 32bd9d9e_8b62_b229_7718_45771b424c40["SyncAPIResource"] e2cc954c_b743_44af_8834_77533ae996fd -->|extends| 32bd9d9e_8b62_b229_7718_45771b424c40 b2b2bd85_e598_f0e9_64e6_661945bb42ac["batches.py"] e2cc954c_b743_44af_8834_77533ae996fd -->|defined in| b2b2bd85_e598_f0e9_64e6_661945bb42ac 6bb3d9b9_9e89_c7af_9e6d_aa0cf31cdac6["with_raw_response()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| 6bb3d9b9_9e89_c7af_9e6d_aa0cf31cdac6 bd47a5c7_4453_298a_1d50_c809fd8fef5a["with_streaming_response()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| bd47a5c7_4453_298a_1d50_c809fd8fef5a 6c043e0f_9673_5341_e44b_834959537834["create()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| 6c043e0f_9673_5341_e44b_834959537834 0751e31f_8bae_63a0_44b9_22ed73da9d12["retrieve()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| 0751e31f_8bae_63a0_44b9_22ed73da9d12 c9e18b54_bc32_42f2_9ffa_e0a7960e82ef["list()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| c9e18b54_bc32_42f2_9ffa_e0a7960e82ef e1dfbd65_54f0_bd0b_0ccc_1a8b30617c4a["delete()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| e1dfbd65_54f0_bd0b_0ccc_1a8b30617c4a 031a03ad_95a0_8ae5_8948_03c66e0b92c7["cancel()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| 031a03ad_95a0_8ae5_8948_03c66e0b92c7 67be316c_9863_b4bd_9bbc_d8e337c703db["results()"] e2cc954c_b743_44af_8834_77533ae996fd -->|method| 67be316c_9863_b4bd_9bbc_d8e337c703db
Relationship Graph
Source Code
src/anthropic/resources/beta/messages/batches.py lines 29–413
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],
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 self._post(
"/v1/messages/batches?beta=true",
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=BetaMessageBatch,
)
def retrieve(
self,
message_batch_id: str,
*,
betas: List[AnthropicBetaParam] | Omit = omit,
Domain
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/beta/messages/batches.py.
Where is Batches defined?
Batches is defined in src/anthropic/resources/beta/messages/batches.py at line 29.
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