create() — anthropic-sdk-python Function Reference
Architecture documentation for the create() function in messages.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD e0f7bea1_12cd_3cb9_ee1b_0529b0f9b174["create()"] bafd0838_b212_5f78_7082_11123724d722["AsyncMessages"] e0f7bea1_12cd_3cb9_ee1b_0529b0f9b174 -->|defined in| bafd0838_b212_5f78_7082_11123724d722 ea2fe77e_073d_25a0_5ca4_f2772ef51e21["create()"] ea2fe77e_073d_25a0_5ca4_f2772ef51e21 -->|calls| e0f7bea1_12cd_3cb9_ee1b_0529b0f9b174 ea2fe77e_073d_25a0_5ca4_f2772ef51e21["create()"] e0f7bea1_12cd_3cb9_ee1b_0529b0f9b174 -->|calls| ea2fe77e_073d_25a0_5ca4_f2772ef51e21 style e0f7bea1_12cd_3cb9_ee1b_0529b0f9b174 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/resources/messages/messages.py lines 1520–1792
async def create(
self,
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: ModelParam,
inference_geo: Optional[str] | Omit = omit,
metadata: MetadataParam | Omit = omit,
output_config: OutputConfigParam | Omit = omit,
service_tier: Literal["auto", "standard_only"] | Omit = omit,
stop_sequences: SequenceNotStr[str] | Omit = omit,
stream: Literal[False] | Omit = omit,
system: Union[str, Iterable[TextBlockParam]] | Omit = omit,
temperature: float | Omit = omit,
thinking: ThinkingConfigParam | Omit = omit,
tool_choice: ToolChoiceParam | Omit = omit,
tools: Iterable[ToolUnionParam] | Omit = omit,
top_k: int | Omit = omit,
top_p: float | 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,
) -> Message:
"""
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?" }
]
```
Example with a partially-filled response from Claude:
```json
[
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does create() do?
create() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/resources/messages/messages.py.
Where is create() defined?
create() is defined in src/anthropic/resources/messages/messages.py at line 1520.
What does create() call?
create() calls 1 function(s): create.
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