pub struct Request {
pub model: String,
pub messages: Vec<Message>,
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub top_p: Option<f32>,
pub frequency_penalty: Option<f32>,
pub presence_penalty: Option<f32>,
pub stop: Option<Vec<String>>,
pub stream: Option<bool>,
pub response_format: Option<ResponseFormat>,
pub extra: HashMap<String, Value>,
}Expand description
A completion request sent to a provider.
Fields§
§model: StringThe model identifier, e.g. "gpt-4o" or "claude-3-5-sonnet-20241022".
messages: Vec<Message>The conversation history, including any system prompt.
temperature: Option<f32>Sampling temperature in [0.0, 2.0].
max_tokens: Option<u32>Maximum tokens to generate.
top_p: Option<f32>Nucleus sampling parameter.
frequency_penalty: Option<f32>Frequency penalty in [-2.0, 2.0] (OpenAI only).
presence_penalty: Option<f32>Presence penalty in [-2.0, 2.0] (OpenAI only).
stop: Option<Vec<String>>Stop sequences.
stream: Option<bool>Whether to stream the response. Providers handle this internally.
response_format: Option<ResponseFormat>Structured output format (json_object etc.).
extra: HashMap<String, Value>Provider-specific extra parameters (e.g. tools, tool_choice).
Implementations§
Source§impl Request
impl Request
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set the model identifier.
Sourcepub fn with_messages(self, messages: Vec<Message>) -> Self
pub fn with_messages(self, messages: Vec<Message>) -> Self
Set the full message list.
Sourcepub fn with_message(self, message: Message) -> Self
pub fn with_message(self, message: Message) -> Self
Append a single message.
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set the sampling temperature.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum number of tokens to generate.
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Set the top_p nucleus sampling parameter.
Sourcepub fn with_json_mode(self) -> Self
pub fn with_json_mode(self) -> Self
Enable JSON mode (structured output).