pub struct CompletionRequest {
pub model: String,
pub messages: Vec<ChatMessage>,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
pub temperature: f32,
pub max_tokens: u32,
pub reasoning_effort: Option<ReasoningEffort>,
pub provider_attempt_id: Option<String>,
pub stream: bool,
pub stream_options: Option<StreamOptions>,
}Expand description
A chat-completion request.
Fields§
§model: String§messages: Vec<ChatMessage>§tools: Option<Vec<Tool>>§tool_choice: Option<ToolChoice>§temperature: f32§max_tokens: u32§reasoning_effort: Option<ReasoningEffort>§provider_attempt_id: Option<String>Durable runtime identity used for provider idempotency and reconciliation.
stream: boolOpenAI-compatible streaming flag. Defaults to false and is omitted on the wire in that case.
stream_options: Option<StreamOptions>OpenAI-compatible streaming options. Providers only include the final
usage frame when include_usage is requested explicitly.
Implementations§
Source§impl CompletionRequest
impl CompletionRequest
Sourcepub fn new(model: impl Into<String>, messages: Vec<ChatMessage>) -> Self
pub fn new(model: impl Into<String>, messages: Vec<ChatMessage>) -> Self
New request with the same defaults as the Python wrapper
(temperature = 0.3, max_tokens = 4096).
pub fn stream(self, enabled: bool) -> Self
pub fn temperature(self, t: f32) -> Self
pub fn max_tokens(self, n: u32) -> Self
pub fn reasoning_effort(self, effort: ReasoningEffort) -> Self
Sourcepub fn tools(self, tools: Vec<Tool>) -> Self
pub fn tools(self, tools: Vec<Tool>) -> Self
Attach tools. Mirrors the Python default: if a caller adds tools without
an explicit choice, we set tool_choice = auto.
pub fn tool_choice(self, choice: ToolChoice) -> Self
Trait Implementations§
Source§impl Clone for CompletionRequest
impl Clone for CompletionRequest
Source§fn clone(&self) -> CompletionRequest
fn clone(&self) -> CompletionRequest
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 moreSource§impl Debug for CompletionRequest
impl Debug for CompletionRequest
Source§impl<'de> Deserialize<'de> for CompletionRequest
impl<'de> Deserialize<'de> for CompletionRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CompletionRequest
impl RefUnwindSafe for CompletionRequest
impl Send for CompletionRequest
impl Sync for CompletionRequest
impl Unpin for CompletionRequest
impl UnsafeUnpin for CompletionRequest
impl UnwindSafe for CompletionRequest
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