Skip to main content

ChatCompletionsRequest

Struct ChatCompletionsRequest 

Source
pub struct ChatCompletionsRequest {
Show 28 fields pub model: String, pub messages: Vec<ChatMessage>, pub max_tokens: Option<u32>, pub max_completion_tokens: Option<u32>, pub temperature: Option<f32>, pub top_p: Option<f32>, pub top_k: Option<i64>, pub min_p: Option<f32>, pub repetition_penalty: Option<f32>, pub n: Option<u32>, pub stream: Option<bool>, pub ignore_eos: Option<bool>, pub stop: Option<Vec<String>>, pub presence_penalty: Option<f32>, pub frequency_penalty: Option<f32>, pub logit_bias: Option<HashMap<String, f32>>, pub logprobs: Option<bool>, pub top_logprobs: Option<u32>, pub user: Option<String>, pub seed: Option<u64>, pub response_format: Option<OpenAiResponseFormat>, pub tools: Option<Vec<ChatTool>>, pub tool_choice: Option<ToolChoice>, pub stream_options: Option<StreamOptions>, pub functions: Option<Vec<ChatFunction>>, pub function_call: Option<FunctionCallChoice>, pub metadata: Option<HashMap<String, Value>>, pub chat_template_kwargs: Option<HashMap<String, Value>>,
}
Expand description

Chat completions request (OpenAI compatible)

Fields§

§model: String

Model to use for completion

§messages: Vec<ChatMessage>

List of messages

§max_tokens: Option<u32>

Maximum number of tokens to generate

§max_completion_tokens: Option<u32>

Newer OpenAI chat field replacing max_tokens for completion budget. When both are supplied, Ferrum uses this value.

§temperature: Option<f32>

Temperature for sampling

§top_p: Option<f32>

Top-p for nucleus sampling

§top_k: Option<i64>

vLLM-compatible top-k sampling extension. Values -1 and 0 disable top-k filtering.

§min_p: Option<f32>

vLLM-compatible minimum probability sampling extension. A value of 0 disables minimum-probability filtering.

§repetition_penalty: Option<f32>

vLLM-compatible repetition penalty extension.

§n: Option<u32>

Number of completions to generate

§stream: Option<bool>

Whether to stream responses

§ignore_eos: Option<bool>

vLLM-compatible extension for benchmark/throughput workloads. When true, Ferrum ignores model EOS tokens and stops only on the requested token budget or explicit user stop sequences.

§stop: Option<Vec<String>>

Stop sequences

§presence_penalty: Option<f32>

Presence penalty

§frequency_penalty: Option<f32>

Frequency penalty

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

Logit bias

§logprobs: Option<bool>

Return log probabilities. Ferrum rejects this until implemented so clients get an explicit OpenAI-style error instead of silent ignore.

§top_logprobs: Option<u32>

Number of top log probabilities to return.

§user: Option<String>

User identifier

§seed: Option<u64>

Random seed

§response_format: Option<OpenAiResponseFormat>

Response format constraint (e.g., {"type": "json_object"})

§tools: Option<Vec<ChatTool>>

OpenAI tool definitions. Function tools are parsed, carried through structured request data, and can shape model-emitted tool-call JSON. Tool execution itself stays caller-owned.

§tool_choice: Option<ToolChoice>

OpenAI tool selection policy.

§stream_options: Option<StreamOptions>

Streaming response options.

§functions: Option<Vec<ChatFunction>>

Legacy OpenAI functions compatibility.

§function_call: Option<FunctionCallChoice>

Legacy OpenAI function-call selector.

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

Ferrum extension metadata. Used for opt-in product features such as metadata.ferrum_session_id when callers prefer body metadata over the X-Ferrum-Session header.

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

vLLM-compatible chat-template variables. Ferrum forwards supported values to the model-provided chat template; templates that do not read a variable are unaffected.

Trait Implementations§

Source§

impl Clone for ChatCompletionsRequest

Source§

fn clone(&self) -> ChatCompletionsRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ChatCompletionsRequest

Source§

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

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

impl<'de> Deserialize<'de> for ChatCompletionsRequest

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 Serialize for ChatCompletionsRequest

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

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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