pub struct ChatRequest { /* private fields */ }Expand description
Generates a chat completion. Build with Client::chat.
Implementations§
Source§impl ChatRequest
impl ChatRequest
Sourcepub fn gpu(self, gpu: impl Into<String>) -> Self
pub fn gpu(self, gpu: impl Into<String>) -> Self
Route to a machine profile, optionally pool-qualified as "pool/profile".
Sourcepub fn wait_for_capacity(self, wait: bool) -> Self
pub fn wait_for_capacity(self, wait: bool) -> Self
Whether to wait out provisioning and model loading, or fail fast.
Sourcepub fn provision_timeout(self, timeout: Duration) -> Self
pub fn provision_timeout(self, timeout: Duration) -> Self
Total wall-clock budget for this call, retries included.
Sourcepub fn max_oom_retries(self, retries: u32) -> Self
pub fn max_oom_retries(self, retries: u32) -> Self
Cap on RESOURCE_EXHAUSTED retries. Zero fails fast.
Sourcepub fn max_completion_tokens(self, value: u32) -> Self
pub fn max_completion_tokens(self, value: u32) -> Self
Cap on generated tokens. Prefer this over max_tokens.
Sourcepub fn max_tokens(self, value: u32) -> Self
pub fn max_tokens(self, value: u32) -> Self
Legacy cap on generated tokens.
Sourcepub fn temperature(self, value: f64) -> Self
pub fn temperature(self, value: f64) -> Self
Sampling temperature.
Sourcepub fn repetition_penalty(self, value: f64) -> Self
pub fn repetition_penalty(self, value: f64) -> Self
Penalty applied to repeated tokens.
Sourcepub fn tool_choice(self, value: Value) -> Self
pub fn tool_choice(self, value: Value) -> Self
Which tool the model must call, if any.
Sourcepub fn parallel_tool_calls(self, value: bool) -> Self
pub fn parallel_tool_calls(self, value: bool) -> Self
Whether several tool calls may be issued at once.
Sourcepub fn response_format(self, value: Value) -> Self
pub fn response_format(self, value: Value) -> Self
Structured output format.
Sourcepub fn frequency_penalty(self, value: f64) -> Self
pub fn frequency_penalty(self, value: f64) -> Self
Penalty applied per prior occurrence of a token.
Sourcepub fn presence_penalty(self, value: f64) -> Self
pub fn presence_penalty(self, value: f64) -> Self
Penalty applied once a token has appeared at all.
Sourcepub fn best_of(self, value: u32) -> Self
pub fn best_of(self, value: u32) -> Self
Number of candidates to generate before picking. Incompatible with streaming.
Sourcepub fn top_logprobs(self, value: u32) -> Self
pub fn top_logprobs(self, value: u32) -> Self
How many alternatives to report per token, from 0 to 20.
Sourcepub fn logit_bias(self, value: Value) -> Self
pub fn logit_bias(self, value: Value) -> Self
Per-token logit adjustments, each from -100 to 100.
Sourcepub fn stream_options(self, value: Value) -> Self
pub fn stream_options(self, value: Value) -> Self
Stream tuning, such as {"include_usage": true}.
Sourcepub fn safety_identifier(self, value: impl Into<String>) -> Self
pub fn safety_identifier(self, value: impl Into<String>) -> Self
End-user identifier forwarded to safety tooling.
Sourcepub fn lora_adapter(self, value: impl Into<String>) -> Self
pub fn lora_adapter(self, value: impl Into<String>) -> Self
LoRA adapter to apply.
Sourcepub fn stop(self, stop: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn stop(self, stop: impl IntoIterator<Item = impl Into<String>>) -> Self
Sequences that end the generation.
Sourcepub fn extra_body(self, extra: Value) -> Self
pub fn extra_body(self, extra: Value) -> Self
Merge extra fields into the request body, overriding anything the builder set.
The gateway rejects unknown fields, so this is for options newer than the SDK.
Sourcepub async fn send(self) -> Result<ChatCompletion>
pub async fn send(self) -> Result<ChatCompletion>
Send the request and wait for the whole completion.
Sourcepub async fn estimate(self) -> Result<CostEstimate>
pub async fn estimate(self) -> Result<CostEstimate>
Estimate what this request would cost.
Source§impl ChatRequest
impl ChatRequest
Sourcepub fn stream(self) -> Result<ChunkStream<ChatCompletionChunk>>
pub fn stream(self) -> Result<ChunkStream<ChatCompletionChunk>>
Stream the completion token by token.