ChatCompletionRequest

Struct ChatCompletionRequest 

Source
pub struct ChatCompletionRequest {
Show 47 fields pub messages: Vec<ChatMessage>, pub model: String, pub frequency_penalty: Option<f32>, pub function_call: Option<FunctionCall>, pub functions: Option<Vec<Function>>, pub logit_bias: Option<HashMap<String, f32>>, pub logprobs: bool, pub max_tokens: Option<u32>, pub max_completion_tokens: Option<u32>, pub metadata: Option<HashMap<String, String>>, pub modalities: Option<Vec<String>>, pub n: Option<u32>, pub parallel_tool_calls: Option<bool>, pub presence_penalty: Option<f32>, pub prompt_cache_key: Option<String>, pub reasoning_effort: Option<String>, pub response_format: Option<ResponseFormat>, pub safety_identifier: Option<String>, pub seed: Option<i64>, pub service_tier: Option<String>, pub stop: Option<StringOrArray>, pub stream: bool, pub stream_options: Option<StreamOptions>, pub temperature: Option<f32>, pub tool_choice: Option<ToolChoice>, pub tools: Option<Vec<Tool>>, pub top_logprobs: Option<u32>, pub top_p: Option<f32>, pub verbosity: Option<i32>, pub top_k: Option<i32>, pub min_p: Option<f32>, pub min_tokens: Option<u32>, pub repetition_penalty: Option<f32>, pub regex: Option<String>, pub ebnf: Option<String>, pub stop_token_ids: Option<Vec<u32>>, pub no_stop_trim: bool, pub ignore_eos: bool, pub continue_final_message: bool, pub skip_special_tokens: bool, pub lora_path: Option<String>, pub session_params: Option<HashMap<String, Value>>, pub separate_reasoning: bool, pub stream_reasoning: bool, pub chat_template_kwargs: Option<HashMap<String, Value>>, pub return_hidden_states: bool, pub sampling_seed: Option<u64>,
}

Fields§

§messages: Vec<ChatMessage>

A list of messages comprising the conversation so far

§model: String

ID of the model to use

§frequency_penalty: Option<f32>

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far

§function_call: Option<FunctionCall>
👎Deprecated: Use tool_choice instead

Deprecated: Replaced by tool_choice

§functions: Option<Vec<Function>>
👎Deprecated: Use tools instead

Deprecated: Replaced by tools

§logit_bias: Option<HashMap<String, f32>>

Modify the likelihood of specified tokens appearing in the completion

§logprobs: bool

Whether to return log probabilities of the output tokens

§max_tokens: Option<u32>
👎Deprecated: Use max_completion_tokens instead

Deprecated: Replaced by max_completion_tokens

§max_completion_tokens: Option<u32>

An upper bound for the number of tokens that can be generated for a completion

§metadata: Option<HashMap<String, String>>

Developer-defined tags and values used for filtering completions in the dashboard

§modalities: Option<Vec<String>>

Output types that you would like the model to generate for this request

§n: Option<u32>

How many chat completion choices to generate for each input message

§parallel_tool_calls: Option<bool>

Whether to enable parallel function calling during tool use

§presence_penalty: Option<f32>

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far

§prompt_cache_key: Option<String>

Cache key for prompts (beta feature)

§reasoning_effort: Option<String>

Effort level for reasoning models (low, medium, high)

§response_format: Option<ResponseFormat>

An object specifying the format that the model must output

§safety_identifier: Option<String>

Safety identifier for content moderation

§seed: Option<i64>
👎Deprecated: This feature is in Legacy mode

Deprecated: This feature is in Legacy mode

§service_tier: Option<String>

The service tier to use for this request

§stop: Option<StringOrArray>

Up to 4 sequences where the API will stop generating further tokens

§stream: bool

If set, partial message deltas will be sent

§stream_options: Option<StreamOptions>

Options for streaming response

§temperature: Option<f32>

What sampling temperature to use, between 0 and 2

§tool_choice: Option<ToolChoice>

Controls which (if any) tool is called by the model

§tools: Option<Vec<Tool>>

A list of tools the model may call

§top_logprobs: Option<u32>

An integer between 0 and 20 specifying the number of most likely tokens to return

§top_p: Option<f32>

An alternative to sampling with temperature

§verbosity: Option<i32>

Verbosity level for debugging

§top_k: Option<i32>

Top-k sampling parameter (-1 to disable)

§min_p: Option<f32>

Min-p nucleus sampling parameter

§min_tokens: Option<u32>

Minimum number of tokens to generate

§repetition_penalty: Option<f32>

Repetition penalty for reducing repetitive text

§regex: Option<String>

Regex constraint for output generation

§ebnf: Option<String>

EBNF grammar constraint for structured output

§stop_token_ids: Option<Vec<u32>>

Specific token IDs to use as stop conditions

§no_stop_trim: bool

Skip trimming stop tokens from output

§ignore_eos: bool

Ignore end-of-sequence tokens during generation

§continue_final_message: bool

Continue generating from final assistant message

§skip_special_tokens: bool

Skip special tokens during detokenization

§lora_path: Option<String>

Path to LoRA adapter(s) for model customization

§session_params: Option<HashMap<String, Value>>

Session parameters for continual prompting

§separate_reasoning: bool

Separate reasoning content from final answer (O1-style models)

§stream_reasoning: bool

Stream reasoning tokens during generation

§chat_template_kwargs: Option<HashMap<String, Value>>

Chat template kwargs

§return_hidden_states: bool

Return model hidden states

§sampling_seed: Option<u64>

Random seed for sampling for deterministic outputs

Trait Implementations§

Source§

impl Clone for ChatCompletionRequest

Source§

fn clone(&self) -> ChatCompletionRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChatCompletionRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChatCompletionRequest

Source§

fn default() -> ChatCompletionRequest

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ChatCompletionRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl GenerationRequest for ChatCompletionRequest

Source§

fn is_stream(&self) -> bool

Check if the request is for streaming
Source§

fn get_model(&self) -> Option<&str>

Get the model name if specified
Source§

fn extract_text_for_routing(&self) -> String

Extract text content for routing decisions
Source§

impl Normalizable for ChatCompletionRequest

Source§

fn normalize(&mut self)

Normalize the request by applying migrations and defaults:

  1. Migrate deprecated fields to their replacements
  2. Clear deprecated fields and log warnings
  3. Apply OpenAI defaults for tool_choice
Source§

impl Serialize for ChatCompletionRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Validate for ChatCompletionRequest

Source§

impl<'v_a> ValidateArgs<'v_a> for ChatCompletionRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,