pub struct CreateChatCompletionRequest {Show 14 fields
pub model: String,
pub messages: Vec<Message>,
pub max_tokens: Option<usize>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub stop: Option<Vec<String>>,
pub tools: Option<Vec<Tool>>,
pub stream: Option<bool>,
pub n: Option<usize>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub provider: Option<ProviderPreferences>,
pub models: Option<Vec<String>>,
pub route: Option<String>,
}Expand description
Request to create a chat completion.
Fields§
§model: StringModel to use (e.g., “openai/gpt-4o”, “anthropic/claude-3.5-sonnet”).
messages: Vec<Message>Messages in the conversation.
max_tokens: Option<usize>Maximum tokens to generate.
temperature: Option<f32>Temperature for sampling.
top_p: Option<f32>Top-p sampling.
stop: Option<Vec<String>>Stop sequences.
tools: Option<Vec<Tool>>Available tools.
stream: Option<bool>Whether to stream the response.
n: Option<usize>Number of completions to generate.
presence_penalty: Option<f32>Presence penalty.
frequency_penalty: Option<f32>Frequency penalty.
provider: Option<ProviderPreferences>Provider routing preferences (OpenRouter-specific).
models: Option<Vec<String>>Model fallback list (OpenRouter-specific).
route: Option<String>Route to select model based on prompt (OpenRouter-specific).
Implementations§
Source§impl CreateChatCompletionRequest
impl CreateChatCompletionRequest
Sourcepub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
pub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
Create a new chat completion request.
Sourcepub fn with_max_tokens(self, max_tokens: usize) -> Self
pub fn with_max_tokens(self, max_tokens: usize) -> Self
Set max tokens.
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set temperature.
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Set top-p sampling.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> Self
pub fn with_tools(self, tools: Vec<Tool>) -> Self
Set available tools.
Sourcepub fn with_provider(self, provider: ProviderPreferences) -> Self
pub fn with_provider(self, provider: ProviderPreferences) -> Self
Set provider preferences.
Sourcepub fn with_fallback_models(self, models: Vec<String>) -> Self
pub fn with_fallback_models(self, models: Vec<String>) -> Self
Set fallback models.
Sourcepub fn with_route(self, route: impl Into<String>) -> Self
pub fn with_route(self, route: impl Into<String>) -> Self
Set route (e.g., “fallback” for auto-routing).
Trait Implementations§
Source§impl Clone for CreateChatCompletionRequest
impl Clone for CreateChatCompletionRequest
Source§fn clone(&self) -> CreateChatCompletionRequest
fn clone(&self) -> CreateChatCompletionRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CreateChatCompletionRequest
impl Debug for CreateChatCompletionRequest
Auto Trait Implementations§
impl Freeze for CreateChatCompletionRequest
impl RefUnwindSafe for CreateChatCompletionRequest
impl Send for CreateChatCompletionRequest
impl Sync for CreateChatCompletionRequest
impl Unpin for CreateChatCompletionRequest
impl UnwindSafe for CreateChatCompletionRequest
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