AsyncMessages Class — anthropic-sdk-python Architecture
Architecture documentation for the AsyncMessages class in messages.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD db0dd20b_744d_feba_f585_1c4e91005d64["AsyncMessages"] f98629a5_73f4_23f2_1f7f_c8db837848d1["AsyncAPIResource"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|extends| f98629a5_73f4_23f2_1f7f_c8db837848d1 0da6889b_9352_8c02_9f21_a1deb1bdab0f["BetaMessage"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|extends| 0da6889b_9352_8c02_9f21_a1deb1bdab0f 18faea44_da45_8ccd_f3b1_057ca68b7fd4["BetaJSONOutputFormatParam"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|extends| 18faea44_da45_8ccd_f3b1_057ca68b7fd4 16f9761f_052b_9813_1b8d_d40d64684eff["messages.py"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|defined in| 16f9761f_052b_9813_1b8d_d40d64684eff 90fc0c7c_798a_0c8d_c4b7_fbace246989b["batches()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 90fc0c7c_798a_0c8d_c4b7_fbace246989b c14f94ad_a248_67a3_78cf_596e98c6e803["with_raw_response()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| c14f94ad_a248_67a3_78cf_596e98c6e803 97f47b5a_d6af_18ab_7467_3c7f528597e1["with_streaming_response()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 97f47b5a_d6af_18ab_7467_3c7f528597e1 4f341f73_cc7e_3e56_290e_28f6534e2a72["create()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 4f341f73_cc7e_3e56_290e_28f6534e2a72 875f19aa_d89c_b439_dca0_bf289f16dce2["parse()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 875f19aa_d89c_b439_dca0_bf289f16dce2 451c7d68_d5dc_be88_3b0d_c8e239fe9aae["tool_runner()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 451c7d68_d5dc_be88_3b0d_c8e239fe9aae e626c920_4ef0_f218_ed25_ad7210b4668b["stream()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| e626c920_4ef0_f218_ed25_ad7210b4668b 03c0ff6f_1277_a16b_a3c8_419f98e2dec3["count_tokens()"] db0dd20b_744d_feba_f585_1c4e91005d64 -->|method| 03c0ff6f_1277_a16b_a3c8_419f98e2dec3
Relationship Graph
Source Code
src/anthropic/resources/beta/messages/messages.py lines 1864–3634
class AsyncMessages(AsyncAPIResource):
@cached_property
def batches(self) -> AsyncBatches:
return AsyncBatches(self._client)
@cached_property
def with_raw_response(self) -> AsyncMessagesWithRawResponse:
"""
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 AsyncMessagesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
"""
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 AsyncMessagesWithStreamingResponse(self)
@overload
async def create(
self,
*,
max_tokens: int,
messages: Iterable[BetaMessageParam],
model: ModelParam,
container: Optional[message_create_params.Container] | Omit = omit,
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
inference_geo: Optional[str] | Omit = omit,
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
metadata: BetaMetadataParam | Omit = omit,
output_config: BetaOutputConfigParam | Omit = omit,
output_format: Optional[BetaJSONOutputFormatParam] | Omit = omit,
service_tier: Literal["auto", "standard_only"] | Omit = omit,
speed: Optional[Literal["standard", "fast"]] | Omit = omit,
stop_sequences: SequenceNotStr[str] | Omit = omit,
stream: Literal[False] | Omit = omit,
system: Union[str, Iterable[BetaTextBlockParam]] | Omit = omit,
temperature: float | Omit = omit,
thinking: BetaThinkingConfigParam | Omit = omit,
tool_choice: BetaToolChoiceParam | Omit = omit,
tools: Iterable[BetaToolUnionParam] | Omit = omit,
top_k: int | Omit = omit,
top_p: float | Omit = omit,
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,
) -> BetaMessage:
"""
Send a structured list of input messages with text and/or image content, and the
model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn
conversations.
Learn more about the Messages API in our
[user guide](https://docs.claude.com/en/docs/initial-setup)
Args:
max_tokens: The maximum number of tokens to generate before stopping.
Note that our models may stop _before_ reaching this maximum. This parameter
only specifies the absolute maximum number of tokens to generate.
Different models have different maximum values for this parameter. See
[models](https://docs.claude.com/en/docs/models-overview) for details.
messages: Input messages.
Our models are trained to operate on alternating `user` and `assistant`
conversational turns. When creating a new `Message`, you specify the prior
conversational turns with the `messages` parameter, and the model then generates
Domain
Source
Frequently Asked Questions
What is the AsyncMessages class?
AsyncMessages is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/beta/messages/messages.py.
Where is AsyncMessages defined?
AsyncMessages is defined in src/anthropic/resources/beta/messages/messages.py at line 1864.
What does AsyncMessages extend?
AsyncMessages extends AsyncAPIResource, BetaMessage, BetaJSONOutputFormatParam.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free