pub struct ChatRequest {
pub messages: Vec<ChatMessage>,
pub tools: Vec<Value>,
pub reasoning: Option<ReasoningConfig>,
pub response_format: Option<ResponseFormat>,
pub model: Option<String>,
}Expand description
Unified chat request format.
Fields§
§messages: Vec<ChatMessage>Message list (supports multimodal content)
tools: Vec<Value>Available tools
reasoning: Option<ReasoningConfig>Reasoning/thinking configuration
response_format: Option<ResponseFormat>Response format configuration
model: Option<String>Optional model override.
None: Use the provider’s default modelSome(name): Use the specified model for this request
This enables multi-model routing: the application can set different models for different scenes (e.g., “lite” for sub-agents, “advanced” for architecture decisions) without creating multiple providers.
Implementations§
Source§impl ChatRequest
impl ChatRequest
Sourcepub fn new(messages: Vec<ChatMessage>) -> Self
pub fn new(messages: Vec<ChatMessage>) -> Self
Create a simple text request.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set model override.
Sourcepub fn with_tools(self, tools: Vec<Value>) -> Self
pub fn with_tools(self, tools: Vec<Value>) -> Self
Add tools.
Sourcepub fn with_reasoning(self, reasoning: ReasoningConfig) -> Self
pub fn with_reasoning(self, reasoning: ReasoningConfig) -> Self
Add reasoning configuration.
Sourcepub fn with_response_format(self, format: ResponseFormat) -> Self
pub fn with_response_format(self, format: ResponseFormat) -> Self
Set response format.
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§fn clone(&self) -> ChatRequest
fn clone(&self) -> ChatRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ChatRequest
impl RefUnwindSafe for ChatRequest
impl Send for ChatRequest
impl Sync for ChatRequest
impl Unpin for ChatRequest
impl UnsafeUnpin for ChatRequest
impl UnwindSafe for ChatRequest
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
Mutably borrows from an owned value. Read more