Skip to main content

GenerationOptions

Struct GenerationOptions 

Source
#[non_exhaustive]
pub struct GenerationOptions { pub temperature: Option<f32>, pub max_tokens: Option<u32>, pub reasoning_effort: Option<String>, pub extra_body: Map<String, Value>, pub output_schema: Option<Value>, }
Expand description

Generation knobs a caller may pin for the invocation. None leaves the provider default in force. Protocol adapters reject options they cannot faithfully render. Hosts own model-specific capability validation, defaults, and aggregate budgets; reasoning_effort and extra_body are sent as given for that reason.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§temperature: Option<f32>

Sampling temperature; None leaves the provider default in force.

§max_tokens: Option<u32>

Upper bound on generated tokens, including reasoning tokens where the provider counts them. None leaves the limit unconstrained by the caller.

§reasoning_effort: Option<String>

Reasoning effort, written to the protocol’s effort key exactly as given: Chat reasoning_effort, Responses reasoning.effort, Anthropic output_config.effort. None omits the key. The value is not checked or mapped; which values a model accepts is the host’s knowledge, and a value the provider refuses comes back as the provider’s error.

§extra_body: Map<String, Value>

Further request fields, merged into the request body exactly as given. This is where protocol- or model-specific settings go, such as an Anthropic thinking object. Where the adapter wrote an object and the same key here is an object too, the two are merged key by key, so {"reasoning": {"summary": "auto"}} joins the effort the adapter wrote. Any other value the adapter writes itself (model, the messages, tools, the options above) is kept and the value given here is dropped without an error. output_schema is kept whole: a key beside the schema is merged, a key inside it is not. Every other key is sent unchecked, a null included.

“Kept” goes by the key the adapter wrote, not by meaning: a key the protocol also understands under another name is sent beside the adapter’s own. An adapter may write further keys by default, and on a streaming call it sets the keys that turn streaming on whatever is given here; the adapter’s documentation lists them. A field that changes the shape of the response can make it unreadable to the adapter.

A serialized null reads as empty.

§output_schema: Option<Value>

JSON Schema the final response should satisfy, rendered natively where the underlying protocol supports it. Schema validation and corrective retry stay host-side. None omits it.

Implementations§

Source§

impl GenerationOptions

Source

pub fn with_temperature(self, temperature: f32) -> Self

Sets the sampling temperature.

Source

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

Sets the upper bound on generated tokens.

Source

pub fn with_reasoning_effort(self, reasoning_effort: impl Into<String>) -> Self

Sets the reasoning effort.

Source

pub fn with_extra_body(self, extra_body: Map<String, Value>) -> Self

Replaces the extra request body fields.

Source

pub fn with_output_schema(self, output_schema: Value) -> Self

Sets the JSON Schema the final response should satisfy.

Trait Implementations§

Source§

impl Clone for GenerationOptions

Source§

fn clone(&self) -> Self

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 GenerationOptions

Source§

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

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

impl Default for GenerationOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for GenerationOptions

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 PartialEq for GenerationOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for GenerationOptions

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 StructuralPartialEq for GenerationOptions

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.