#[non_exhaustive]pub struct CreateMessageRequest {Show 15 fields
pub model: ModelId,
pub max_tokens: u32,
pub messages: Vec<MessageInput>,
pub system: Option<SystemPrompt>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub top_k: Option<u32>,
pub stop_sequences: Option<Vec<String>>,
pub tools: Vec<Tool>,
pub tool_choice: Option<ToolChoice>,
pub metadata: Option<MessageMetadata>,
pub service_tier: Option<RequestServiceTier>,
pub thinking: Option<ThinkingConfig>,
pub mcp_servers: Vec<McpServerConfig>,
pub container: Option<String>,
/* private fields */
}Expand description
Request payload for POST /v1/messages.
Construct via CreateMessageRequest::builder.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.model: ModelIdModel to query.
max_tokens: u32Maximum number of output tokens to generate.
messages: Vec<MessageInput>Conversation history.
system: Option<SystemPrompt>Optional system prompt.
temperature: Option<f32>Sampling temperature.
top_p: Option<f32>Nucleus sampling cutoff.
top_k: Option<u32>Top-k sampling cutoff.
stop_sequences: Option<Vec<String>>Custom stop sequences.
tools: Vec<Tool>Tools the model may invoke.
tool_choice: Option<ToolChoice>Tool-use policy.
metadata: Option<MessageMetadata>Optional per-request metadata (user_id).
service_tier: Option<RequestServiceTier>Request-side service tier preference.
thinking: Option<ThinkingConfig>Extended-thinking configuration.
mcp_servers: Vec<McpServerConfig>MCP servers exposed to the model on this request.
container: Option<String>Container ID for the code-execution built-in tool.
Implementations§
Source§impl CreateMessageRequest
impl CreateMessageRequest
Sourcepub fn builder() -> CreateMessageRequestBuilder
pub fn builder() -> CreateMessageRequestBuilder
Begin configuring a request.
Trait Implementations§
Source§impl Clone for CreateMessageRequest
impl Clone for CreateMessageRequest
Source§fn clone(&self) -> CreateMessageRequest
fn clone(&self) -> CreateMessageRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CreateMessageRequest
impl Debug for CreateMessageRequest
Source§impl From<&CreateMessageRequest> for CountTokensRequest
impl From<&CreateMessageRequest> for CountTokensRequest
Source§fn from(req: &CreateMessageRequest) -> Self
fn from(req: &CreateMessageRequest) -> Self
Project a CreateMessageRequest onto the subset of fields the
count-tokens endpoint accepts. Sampling parameters (temperature,
top_p, etc.) and max_tokens are dropped because they don’t
affect tokenization.
Auto Trait Implementations§
impl Freeze for CreateMessageRequest
impl RefUnwindSafe for CreateMessageRequest
impl Send for CreateMessageRequest
impl Sync for CreateMessageRequest
impl Unpin for CreateMessageRequest
impl UnsafeUnpin for CreateMessageRequest
impl UnwindSafe for CreateMessageRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more