pub struct AnthropicRequest {
pub model: String,
pub messages: Vec<AnthropicMessage>,
pub system: Option<String>,
pub stream: bool,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub tools: Option<Vec<Value>>,
}Expand description
Request payload for POST {base_url}/messages.
Optional fields are omitted when None so the server applies its own defaults, matching
OpenAIRequest’s treatment of max_tokens and temperature.
Fields§
§model: StringModel identifier (e.g. "claude-opus-5", "k3", "MiniMax-M3").
messages: Vec<AnthropicMessage>Conversation turns, alternating user and assistant. Never carries the system prompt.
system: Option<String>The system prompt, as a top-level field rather than a message.
stream: boolWhether to stream the response. The SDK always sets this.
max_tokens: Option<u32>Maximum tokens to generate.
Optional in the current Anthropic API, and omitted when unset so a long-context model is not truncated by a client-invented ceiling. Some Anthropic-compatible third-party endpoints still require it; that is the caller’s to set, not this layer’s to invent.
temperature: Option<f32>Sampling temperature. Anthropic’s accepted range is 0.0 to 1.0, narrower than OpenAI’s 0.0 to 2.0, and several compatible endpoints reject any value at all.
tools: Option<Vec<Value>>Tool definitions in Anthropic’s flat shape.
Implementations§
Source§impl AnthropicRequest
impl AnthropicRequest
Sourcepub fn from_openai(request: &OpenAIRequest) -> Self
pub fn from_openai(request: &OpenAIRequest) -> Self
Translates the SDK’s canonical request into Anthropic’s shape.
Field-for-field except where the module documentation says otherwise.
Trait Implementations§
Source§impl Clone for AnthropicRequest
impl Clone for AnthropicRequest
Source§fn clone(&self) -> AnthropicRequest
fn clone(&self) -> AnthropicRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more