pub struct ChatRequest {
pub model: String,
pub messages: Vec<ChatMessage>,
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub stream: Option<bool>,
pub tools: Option<Vec<Value>>,
pub top_p: Option<f32>,
pub frequency_penalty: Option<f32>,
pub presence_penalty: Option<f32>,
pub reasoning_effort: Option<String>,
}Expand description
A chat completion request
Fields§
§model: StringThe model to use for completion
messages: Vec<ChatMessage>The conversation messages
temperature: Option<f32>Sampling temperature (0.0 to 2.0)
max_tokens: Option<u32>Maximum number of tokens to generate
stream: Option<bool>Whether to stream the response
tools: Option<Vec<Value>>Tools available for the model to call
top_p: Option<f32>Top-p sampling parameter
frequency_penalty: Option<f32>Frequency penalty (-2.0 to 2.0).
⚠ Not supported by reasoning models (Grok 4, Grok 4.20 variants). Sending this field to a reasoning model will result in an API error.
presence_penalty: Option<f32>Presence penalty (-2.0 to 2.0).
⚠ Not supported by reasoning models (Grok 4, Grok 4.20 variants). Sending this field to a reasoning model will result in an API error.
reasoning_effort: Option<String>Reasoning effort level for models that support extended thinking.
Valid values: "low", "medium", "high".
Only send this for models that support it (e.g. grok-4.3, grok-3-mini).
Sending it to unsupported models returns an API error.
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§fn clone(&self) -> ChatRequest
fn clone(&self) -> ChatRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more