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.
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | - |
| messages | list of objects or null | 是 | - |
| max_tokens | double | 否 | - |
| system | string or list of objects | 否 | - |
| metadata | object | 否 | - |
| stop_sequences | list of strings | 否 | - |
| temperature | double | 否 | - |
| top_p | double | 否 | - |
| top_k | double | 否 | - |
| tools | list of objects | 否 | - |
| tool_choice | object | 否 | - |
| thinking | object | 否 | - |
| service_tier | enum | 否 | - |
| output_config | object | 否 | Configuration for controlling output behavior. Supports the effort parameter and structured output format. |
| cache_control | object | 否 | - |
| stream | boolean | 否 | - |
| context_management | object or null | 否 | - |
| provider | object or null | 否 | When multiple model providers are available, optionally indicate your routing preference. |
| plugins | list of objects | 否 | Plugins you want to enable for this request, including their settings. |
| user | string | 否 | <=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_id | string | 否 | <=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. |
| trace | object | 否 | Metadata 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. |
| models | list of strings | 否 | - |
Response
Successful response
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| container | object or null | - | - |
| content | list of objects | - | - |
| id | string | - | - |
| model | string | - | - |
| role | enum | - | - |
| stop_reason | enum or null | - | - |
| stop_sequence | string or null | - | - |
| type | enum | - | - |
| usage | object | - | - |
| provider | enum | - | - |