Skip to main content

AnthropicCreateMessageRequest

Struct AnthropicCreateMessageRequest 

Source
pub struct AnthropicCreateMessageRequest {
Show 18 fields pub model: String, pub max_tokens: u32, pub messages: Vec<AnthropicMessage>, pub nvext: Option<Value>, pub system: Option<SystemContent>, pub temperature: Option<f32>, pub top_p: Option<f32>, pub top_k: Option<u32>, pub stop_sequences: Option<Vec<String>>, pub stream: bool, pub metadata: Option<Value>, pub tools: Option<Vec<AnthropicTool>>, pub tool_choice: Option<AnthropicToolChoice>, pub cache_control: Option<CacheControl>, pub thinking: Option<ThinkingConfig>, pub service_tier: Option<String>, pub container: Option<String>, pub output_config: Option<Value>,
}
Expand description

Top-level request body for POST /v1/messages.

Fields§

§model: String

The model to use (e.g. “claude-sonnet-4-20250514”).

§max_tokens: u32

The maximum number of tokens to generate.

§messages: Vec<AnthropicMessage>

The conversation messages.

§nvext: Option<Value>

Dynamo protocol extension envelope. Protocol parsing keeps this opaque; LLM request handling owns extension validation and normalization.

§system: Option<SystemContent>

Optional system prompt (string or array of {"type":"text","text":"..."} blocks).

§temperature: Option<f32>

Sampling temperature (0.0 - 1.0).

§top_p: Option<f32>

Nucleus sampling parameter.

§top_k: Option<u32>

Top-K sampling parameter.

§stop_sequences: Option<Vec<String>>

Custom stop sequences.

§stream: bool

Whether to stream the response.

§metadata: Option<Value>

Optional metadata (e.g. user_id).

§tools: Option<Vec<AnthropicTool>>

Tools the model may call.

§tool_choice: Option<AnthropicToolChoice>

How the model should choose which tool to call.

§cache_control: Option<CacheControl>

Top-level cache control for automatic prompt prefix caching. When present, the system caches all content up to the last cacheable block. Matches the Anthropic Messages API automatic caching mode. See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#automatic-caching

§thinking: Option<ThinkingConfig>

Extended thinking configuration. When enabled, the model produces thinking content blocks containing its internal reasoning before the final response. The budget_tokens field controls how many tokens the model may use for thinking (must be >= 1024 and < max_tokens).

§service_tier: Option<String>

Service tier selection: "auto" or "standard_only".

§container: Option<String>

Container identifier for stateful sandbox sessions.

§output_config: Option<Value>

Output configuration: effort level and optional JSON schema format. effort can be "low", "medium", "high", or "max". format specifies structured JSON output constraints.

Implementations§

Source§

impl AnthropicCreateMessageRequest

Source

pub fn estimate_tokens(&self) -> u32

Estimate input token count using the same len/3 heuristic as /count_tokens.

Trait Implementations§

Source§

impl Clone for AnthropicCreateMessageRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnthropicCreateMessageRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AnthropicCreateMessageRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AnthropicCreateMessageRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more