pub struct CompletionRequest {
pub context: Option<RequestContext>,
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§
§context: Option<RequestContext>Fresh caller identity for resource authorization; never serialized.
model: StringModel identifier as registered in the model registry.
messages: Vec<ChatMessage>Conversation messages in request order.
tools: Option<Vec<Tool>>Tool names referenced by this record.
tool_choice: Option<ToolChoice>How the model may use the advertised tools.
temperature: f32Sampling temperature.
max_tokens: u32Upper bound on prompt plus completion tokens.
reasoning_effort: Option<ReasoningEffort>Reasoning budget, when the provider supports it.
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).
Sourcepub fn temperature(self, t: f32) -> Self
pub fn temperature(self, t: f32) -> Self
Set the sampling temperature.
Sourcepub fn max_tokens(self, n: u32) -> Self
pub fn max_tokens(self, n: u32) -> Self
Set the maximum completion tokens.
Sourcepub fn reasoning_effort(self, effort: ReasoningEffort) -> Self
pub fn reasoning_effort(self, effort: ReasoningEffort) -> Self
Set the reasoning budget.
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.
Sourcepub fn tool_choice(self, choice: ToolChoice) -> Self
pub fn tool_choice(self, choice: ToolChoice) -> Self
Set the tool-choice policy.
Trait Implementations§
Source§impl Clone for CompletionRequest
impl Clone for CompletionRequest
Source§fn clone(&self) -> CompletionRequest
fn clone(&self) -> CompletionRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more