pub struct CreateMessagesRequest {Show 14 fields
pub max_tokens: i64,
pub messages: Vec<MessagesMessage>,
pub metadata: Option<MessagesMetadata>,
pub model: String,
pub output_config: Option<MessagesOutputConfig>,
pub stop_sequences: Vec<String>,
pub stream: bool,
pub system: Option<CreateMessagesRequestSystem>,
pub temperature: Option<f32>,
pub thinking: Option<CreateMessagesRequestThinking>,
pub tool_choice: Option<MessagesToolChoice>,
pub tools: Vec<MessagesTool>,
pub top_k: Option<i64>,
pub top_p: Option<f32>,
}Expand description
Request body for creating a message via the Anthropic-compatible Messages API.
JSON schema
{
"description": "Request body for creating a message via the Anthropic-compatible\nMessages API.\n",
"type": "object",
"required": [
"max_tokens",
"messages",
"model"
],
"properties": {
"max_tokens": {
"description": "The maximum number of tokens to generate before stopping.\n",
"type": "integer"
},
"messages": {
"description": "The messages to generate a response for. Each message has a\n`role` (user or assistant) and `content`.\n",
"type": "array",
"items": {
"$ref": "#/definitions/MessagesMessage"
}
},
"metadata": {
"$ref": "#/definitions/MessagesMetadata"
},
"model": {
"description": "The model to use for generating the message.",
"type": "string"
},
"output_config": {
"$ref": "#/definitions/MessagesOutputConfig"
},
"stop_sequences": {
"description": "Custom text sequences that will cause the model to stop\ngenerating.\n",
"type": "array",
"items": {
"type": "string"
}
},
"stream": {
"description": "Whether to stream the response using server-sent events.\n",
"default": false,
"type": "boolean"
},
"system": {
"description": "The system prompt. Can be a string or an array of system content\nblocks (for prompt caching).\n",
"oneOf": [
{
"description": "System prompt as a string.",
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/MessagesTextBlock"
}
}
]
},
"temperature": {
"description": "Amount of randomness injected into the response. Ranges from\n0.0 to 1.0. Use closer to 0 for analytical / multiple choice,\ncloser to 1 for creative and generative tasks.\n",
"type": "number",
"format": "float"
},
"thinking": {
"description": "Configuration for extended thinking.\n",
"type": "object",
"required": [
"budget_tokens",
"type"
],
"properties": {
"budget_tokens": {
"description": "The maximum number of tokens the model is allowed to use\nfor thinking.\n",
"type": "integer"
},
"type": {
"description": "Always `enabled`.",
"type": "string",
"enum": [
"enabled"
]
}
}
},
"tool_choice": {
"$ref": "#/definitions/MessagesToolChoice"
},
"tools": {
"description": "Definitions of tools the model may call. Each tool can include\n`cache_control` for prompt caching.\n",
"type": "array",
"items": {
"$ref": "#/definitions/MessagesTool"
}
},
"top_k": {
"description": "Only sample from the top K options for each subsequent token.\n",
"type": "integer"
},
"top_p": {
"description": "Use nucleus sampling. Only consider the tokens with top_p\nprobability mass.\n",
"type": "number",
"format": "float"
}
}
}Fields§
§max_tokens: i64The maximum number of tokens to generate before stopping.
messages: Vec<MessagesMessage>The messages to generate a response for. Each message has a
role (user or assistant) and content.
metadata: Option<MessagesMetadata>§model: StringThe model to use for generating the message.
output_config: Option<MessagesOutputConfig>§stop_sequences: Vec<String>Custom text sequences that will cause the model to stop generating.
stream: boolWhether to stream the response using server-sent events.
system: Option<CreateMessagesRequestSystem>The system prompt. Can be a string or an array of system content blocks (for prompt caching).
temperature: Option<f32>Amount of randomness injected into the response. Ranges from 0.0 to 1.0. Use closer to 0 for analytical / multiple choice, closer to 1 for creative and generative tasks.
thinking: Option<CreateMessagesRequestThinking>§tool_choice: Option<MessagesToolChoice>§tools: Vec<MessagesTool>Definitions of tools the model may call. Each tool can include
cache_control for prompt caching.
top_k: Option<i64>Only sample from the top K options for each subsequent token.
top_p: Option<f32>Use nucleus sampling. Only consider the tokens with top_p probability mass.
Trait Implementations§
Source§impl Clone for CreateMessagesRequest
impl Clone for CreateMessagesRequest
Source§fn clone(&self) -> CreateMessagesRequest
fn clone(&self) -> CreateMessagesRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more