pub struct ChatRequest {
pub messages: Vec<Message>,
pub tools: Vec<ToolSpec>,
pub tool_declarations: Vec<ToolDeclaration>,
pub server_tools: Vec<ServerTool>,
pub tool_choice: Option<ToolChoice>,
pub response_format: Option<ResponseFormat>,
pub stop: Vec<String>,
pub seed: Option<u64>,
pub temperature: Option<f32>,
pub max_output_tokens: Option<u32>,
pub reasoning: Option<ReasoningConfig>,
pub extra_body: Map<String, Value>,
}Expand description
A request sent to a model adapter.
extra_body is an escape hatch for provider-specific wire fields. The SDK
merges it into the final JSON object but refuses to let it overwrite
canonical fields such as model, messages, input, or stream.
Fields§
§messages: Vec<Message>The conversation so far.
tools: Vec<ToolSpec>Client-side tools the model may call.
tool_declarations: Vec<ToolDeclaration>Native client declarations. Currently rejected by all wire adapters; this gate prevents exposing tools before call/result replay is complete.
server_tools: Vec<ServerTool>Provider-hosted tools such as web search.
tool_choice: Option<ToolChoice>How the model should choose among tools.
response_format: Option<ResponseFormat>Requested output format.
stop: Vec<String>Sequences that stop generation.
seed: Option<u64>Sampling seed for reproducibility.
temperature: Option<f32>Sampling temperature.
max_output_tokens: Option<u32>Upper bound on generated tokens.
reasoning: Option<ReasoningConfig>Reasoning behavior, for providers that support it.
extra_body: Map<String, Value>Escape hatch for provider-specific wire fields. Reserved canonical fields cannot be overwritten.
Implementations§
Source§impl ChatRequest
impl ChatRequest
Sourcepub fn new(messages: impl IntoIterator<Item = Message>) -> Self
pub fn new(messages: impl IntoIterator<Item = Message>) -> Self
Creates a request from the given messages; all other fields default.
Sourcepub fn user(text: impl Into<String>) -> Self
pub fn user(text: impl Into<String>) -> Self
Creates a request with a single user text message.
Sourcepub fn tools(self, tools: impl IntoIterator<Item = ToolSpec>) -> Self
pub fn tools(self, tools: impl IntoIterator<Item = ToolSpec>) -> Self
Replaces the client-side tool list.
Sourcepub fn tool_declarations(
self,
tools: impl IntoIterator<Item = ToolDeclaration>,
) -> Self
pub fn tool_declarations( self, tools: impl IntoIterator<Item = ToolDeclaration>, ) -> Self
Replaces the native client declarations; the legacy function list is retained separately and participates in top-level conflict validation.
Sourcepub fn server_tools(self, tools: impl IntoIterator<Item = ServerTool>) -> Self
pub fn server_tools(self, tools: impl IntoIterator<Item = ServerTool>) -> Self
Replaces the provider-hosted tool list.
Sourcepub fn tool_choice(self, tool_choice: ToolChoice) -> Self
pub fn tool_choice(self, tool_choice: ToolChoice) -> Self
Sets how the model should choose among tools.
Sourcepub fn response_format(self, response_format: ResponseFormat) -> Self
pub fn response_format(self, response_format: ResponseFormat) -> Self
Sets the requested output format.
Sourcepub fn temperature(self, temperature: f32) -> Self
pub fn temperature(self, temperature: f32) -> Self
Sets the sampling temperature.
Sourcepub fn max_output_tokens(self, max_output_tokens: u32) -> Self
pub fn max_output_tokens(self, max_output_tokens: u32) -> Self
Sets the output token limit.
Sourcepub fn reasoning(self, reasoning: ReasoningConfig) -> Self
pub fn reasoning(self, reasoning: ReasoningConfig) -> Self
Sets the reasoning configuration.