Skip to Content
API ReferenceAnthropic MessagesCreate Messages

Create messages

Creates a message using the Anthropic Messages API format. Supports text, images, PDFs, tools, and extended thinking.

Request

This endpoint expects an object.

字段类型必填说明
modelstring-
messageslist of objects or null-
max_tokensdouble-
systemstring or list of objects-
metadataobject-
stop_sequenceslist of strings-
temperaturedouble-
top_pdouble-
top_kdouble-
toolslist of objects-
tool_choiceobject-
thinkingobject-
service_tierenum-
output_configobjectConfiguration for controlling output behavior. Supports the effort parameter and structured output format.
cache_controlobject-
streamboolean-
context_managementobject or null-
providerobject or nullWhen multiple model providers are available, optionally indicate your routing preference.
pluginslist of objectsPlugins you want to enable for this request, including their settings.
userstring<=128 characters A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
session_idstring<=128 characters A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
traceobjectMetadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
modelslist of strings-

Response

Successful response

字段类型必填说明
containerobject or null--
contentlist of objects--
idstring--
modelstring--
roleenum--
stop_reasonenum or null--
stop_sequencestring or null--
typeenum--
usageobject--
providerenum--