Home / Function/ create() — anthropic-sdk-python Function Reference

create() — anthropic-sdk-python Function Reference

Architecture documentation for the create() function in messages.py from the anthropic-sdk-python codebase.

Function python AnthropicClient AsyncAPI calls 5 called by 1

Entity Profile

Dependency Diagram

graph TD
  4f341f73_cc7e_3e56_290e_28f6534e2a72["create()"]
  db0dd20b_744d_feba_f585_1c4e91005d64["AsyncMessages"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|defined in| db0dd20b_744d_feba_f585_1c4e91005d64
  34d38135_c378_e9a4_ba05_661bc9121152["create()"]
  34d38135_c378_e9a4_ba05_661bc9121152 -->|calls| 4f341f73_cc7e_3e56_290e_28f6534e2a72
  9ba86632_18ba_3543_8fb0_a2031d2b5335["validate_output_format()"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|calls| 9ba86632_18ba_3543_8fb0_a2031d2b5335
  eedd35ac_a896_dc63_a3fe_c46cf577bffb["_validate_output_config_conflict()"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|calls| eedd35ac_a896_dc63_a3fe_c46cf577bffb
  b3ae1af8_b549_4aef_c8c4_9309fd981a1a["_warn_output_format_deprecated()"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|calls| b3ae1af8_b549_4aef_c8c4_9309fd981a1a
  618c478a_823f_e214_e25b_6e82a7278cf7["_merge_output_configs()"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|calls| 618c478a_823f_e214_e25b_6e82a7278cf7
  34d38135_c378_e9a4_ba05_661bc9121152["create()"]
  4f341f73_cc7e_3e56_290e_28f6534e2a72 -->|calls| 34d38135_c378_e9a4_ba05_661bc9121152
  style 4f341f73_cc7e_3e56_290e_28f6534e2a72 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/resources/beta/messages/messages.py lines 1889–2187

    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
              the next `Message` in the conversation. Consecutive `user` or `assistant` turns
              in your request will be combined into a single turn.

              Each input message must be an object with a `role` and `content`. You can
              specify a single `user`-role message, or you can include multiple `user` and
              `assistant` messages.

              If the final message uses the `assistant` role, the response content will
              continue immediately from the content in that message. This can be used to
              constrain part of the model's response.

              Example with a single `user` message:

              ```json
              [{ "role": "user", "content": "Hello, Claude" }]
              ```

              Example with multiple conversational turns:

              ```json
              [
                { "role": "user", "content": "Hello there." },
                { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
                { "role": "user", "content": "Can you explain LLMs in plain English?" }
              ]

Subdomains

Called By

Frequently Asked Questions

What does create() do?
create() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/resources/beta/messages/messages.py.
Where is create() defined?
create() is defined in src/anthropic/resources/beta/messages/messages.py at line 1889.
What does create() call?
create() calls 5 function(s): _merge_output_configs, _validate_output_config_conflict, _warn_output_format_deprecated, create, validate_output_format.
What calls create()?
create() is called by 1 function(s): create.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free