Skip to main content

ChatOptions

Struct ChatOptions 

Source
pub struct ChatOptions {
Show 16 fields pub temperature: Option<f64>, pub max_tokens: Option<u32>, pub top_p: Option<f64>, pub stop_sequences: Vec<String>, pub capture_usage: Option<bool>, pub capture_content: Option<bool>, pub capture_reasoning_content: Option<bool>, pub capture_tool_calls: Option<bool>, pub capture_raw_body: Option<bool>, pub response_format: Option<ChatResponseFormat>, pub normalize_reasoning_content: Option<bool>, pub reasoning_effort: Option<ReasoningEffort>, pub verbosity: Option<Verbosity>, pub seed: Option<u64>, pub service_tier: Option<ServiceTier>, pub extra_headers: Option<Headers>,
}
Expand description

Options considered by all Client::exec_* chat calls.

A default can be set on the Client during builder configuration. Per-call options take precedence over client defaults.

Fields§

§temperature: Option<f64>

Sampling temperature (if supported by the provider).

§max_tokens: Option<u32>

Maximum tokens to generate (if supported).

§top_p: Option<f64>

Nucleus sampling (top-p), if supported.

§stop_sequences: Vec<String>

Sequences that halt generation when encountered.

§capture_usage: Option<bool>

(streaming) Capture usage metadata; available in StreamEnd.captured_usage.

§capture_content: Option<bool>

(streaming) Concatenate content chunks; available in StreamEnd.captured_content.

§capture_reasoning_content: Option<bool>

(streaming) Concatenate reasoning chunks; available in StreamEnd.captured_reasoning_content.

§capture_tool_calls: Option<bool>

(streaming) Collect tool calls; available in StreamEnd.captured_tool_calls.

§capture_raw_body: Option<bool>

Capture the raw HTTP body (primarily for debugging/inspection).

§response_format: Option<ChatResponseFormat>

Desired response format (e.g., ChatResponseFormat::JsonMode for OpenAI-style JSON mode).

Note: Additional formats may be added in the future.

§normalize_reasoning_content: Option<bool>

Extract -style reasoning blocks into ChatResponse.reasoning_content when present.

§reasoning_effort: Option<ReasoningEffort>

Preferred reasoning effort, when supported by the provider.

§verbosity: Option<Verbosity>

Verbosity (for OpenAI gpt-5),

§seed: Option<u64>

Seed for repeatability, if supported.

§service_tier: Option<ServiceTier>

Service tier preference (OpenAI-specific, for flex processing).

§extra_headers: Option<Headers>

Additional HTTP headers to include with the request.

Implementations§

Source§

impl ChatOptions

Chainable Setters

Source

pub fn with_temperature(self, value: f64) -> Self

Sets the sampling temperature.

Source

pub fn with_max_tokens(self, value: u32) -> Self

Sets the maximum number of output tokens.

Source

pub fn with_top_p(self, value: f64) -> Self

Sets nucleus sampling (top-p).

Source

pub fn with_capture_usage(self, value: bool) -> Self

Enables or disables capturing usage in streaming mode.

Source

pub fn with_capture_content(self, value: bool) -> Self

Enables or disables capturing concatenated content in streaming mode.

Source

pub fn with_capture_reasoning_content(self, value: bool) -> Self

Enables or disables capturing concatenated reasoning content in streaming mode.

Source

pub fn with_capture_tool_calls(self, value: bool) -> Self

Enables or disables capturing tool calls in streaming mode.

Source

pub fn with_capture_raw_body(self, value: bool) -> Self

Enables or disables capturing the raw HTTP body.

Source

pub fn with_stop_sequences(self, values: Vec<String>) -> Self

Sets the stop sequences.

Source

pub fn with_normalize_reasoning_content(self, value: bool) -> Self

Enables or disables normalization of reasoning content (e.g., <think>...</think>).

Source

pub fn with_response_format( self, res_format: impl Into<ChatResponseFormat>, ) -> Self

Sets the response format.

Source

pub fn with_reasoning_effort(self, value: ReasoningEffort) -> Self

Sets the reasoning effort hint.

Source

pub fn with_verbosity(self, value: Verbosity) -> Self

Sets the verbosity hint.

Source

pub fn with_seed(self, value: u64) -> Self

Sets the deterministic seed.

Source

pub fn with_service_tier(self, value: ServiceTier) -> Self

Sets the service tier preference (OpenAI-specific).

Source

pub fn with_extra_headers(self, headers: impl Into<Headers>) -> Self

Adds extra HTTP headers.

Source

pub fn with_json_mode(self, value: bool) -> Self

👎Deprecated: Use with_response_format(ChatResponseFormat::JsonMode)

Deprecated: use with_response_format(ChatResponseFormat::JsonMode).

When using JSON mode, you should still instruct the model to produce JSON in your prompt for broad provider compatibility (e.g., mention “json” in system/user messages).

Trait Implementations§

Source§

impl Clone for ChatOptions

Source§

fn clone(&self) -> ChatOptions

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 ChatOptions

Source§

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

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

impl Default for ChatOptions

Source§

fn default() -> ChatOptions

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

impl<'de> Deserialize<'de> for ChatOptions

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 ChatOptions

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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>,