Skip to main content

Parameters

Struct Parameters 

Source
pub struct Parameters {
Show 23 fields pub temperature: Option<f32>, pub top_p: Option<f32>, pub top_k: Option<u32>, pub frequency_penalty: Option<f32>, pub presence_penalty: Option<f32>, pub repetition_penalty: Option<f32>, pub min_p: Option<f32>, pub seed: Option<u32>, pub max_tokens: Option<u32>, pub logit_bias: Option<Vec<(String, f32)>>, pub logprobs: Option<bool>, pub top_logprobs: Option<u8>, pub stop: Option<Vec<String>>, pub tool_choice: ToolChoice, pub parallel_tool_calls: Option<bool>, pub reasoning_effort: Option<ReasoningEffort>, pub include_reasoning: bool, pub structured_outputs: bool, pub response_format: Option<Schema>, pub websearch: bool, pub code_execution: bool, pub native_tools: NativeTools, pub cache: CacheOptions,
}
Expand description

Parameters for configuring the behavior of a language model.

This struct contains various parameters that can be used to control how a language model generates responses. All parameters are optional and use the builder pattern for easy configuration.

§Examples

use aither::llm::model::Parameters;

let params = Parameters::default()
    .temperature(0.7)
    .top_p(0.9)
    .max_tokens(1000)
    .seed(42);

Fields§

§temperature: Option<f32>

Sampling temperature.

Controls randomness in generation. Higher values (e.g., 1.0) make output more random, lower values (e.g., 0.1) make it more deterministic.

§top_p: Option<f32>

Nucleus sampling probability.

Only consider tokens with cumulative probability up to this value. Typical values are between 0.9 and 1.0.

§top_k: Option<u32>

Top-k sampling parameter.

Only consider the k most likely tokens at each step.

§frequency_penalty: Option<f32>

Frequency penalty to reduce repetition.

Positive values penalize tokens that have already appeared.

§presence_penalty: Option<f32>

Presence penalty to encourage new tokens.

Positive values encourage the model to talk about new topics.

§repetition_penalty: Option<f32>

Repetition penalty to penalize repeated tokens.

Values > 1.0 discourage repetition, values < 1.0 encourage it.

Local inference only: this maps onto a llama.cpp sampler and none of the hosted provider APIs accept it, so setting it has no effect on them.

§min_p: Option<f32>

Minimum probability for nucleus sampling.

Alternative to top_p that sets a minimum threshold for token probabilities.

Local inference only, like Self::repetition_penalty.

§seed: Option<u32>

Random seed for reproducibility.

Use the same seed to get deterministic outputs.

§max_tokens: Option<u32>

Maximum number of tokens to generate.

Limits the length of the generated response.

§logit_bias: Option<Vec<(String, f32)>>

Biases for specific logits.

Each tuple contains a token string and its bias value.

§logprobs: Option<bool>

Whether to return log probabilities.

When true, the model returns probability information for tokens.

§top_logprobs: Option<u8>

Number of top log probabilities to return.

Only used when logprobs is true.

§stop: Option<Vec<String>>

Stop sequences to end generation.

Generation stops when any of these strings are encountered.

§tool_choice: ToolChoice

Tool choice policy for the model.

Controls whether tools are allowed, required, or constrained to a specific tool.

§parallel_tool_calls: Option<bool>

Whether the model may request several tools in a single turn.

None leaves the decision to the provider’s own default. Set it only to override that default — forcing false serializes an agent loop that could otherwise fan its tool calls out concurrently.

§reasoning_effort: Option<ReasoningEffort>

Preferred reasoning effort when supported.

§include_reasoning: bool

Whether the provider should include reasoning summaries in the response stream.

§structured_outputs: bool

Whether to enable structured outputs.

When true, the model will attempt to return outputs in a structured format (e.g., JSON).

§response_format: Option<Schema>

The expected response format schema.

When set, the model will attempt to return outputs matching this schema.

§websearch: bool

Whether to enable native Search tool for grounding.

§code_execution: bool

Whether to enable native Code Execution tool.

§native_tools: NativeTools

Provider-native tools that are not portable across API families.

§cache: CacheOptions

Provider-specific prompt cache controls.

Implementations§

Source§

impl Parameters

Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_p(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn frequency_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn presence_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn repetition_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn min_p(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn logit_bias(self, value: Vec<(String, f32)>) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_logprobs(self, value: u8) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn stop(self, value: Vec<String>) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

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

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source§

impl Parameters

Source

pub const fn include_reasoning(self, include: bool) -> Self

Sets whether providers should include reasoning summaries.

Source

pub const fn reasoning_effort(self, effort: ReasoningEffort) -> Self

Sets the preferred reasoning effort.

Source

pub const fn websearch(self, enabled: bool) -> Self

Sets whether to enable native Google Search tool.

Source

pub const fn code_execution(self, enabled: bool) -> Self

Sets whether to enable native Code Execution tool.

Source

pub fn native_tools(self, tools: NativeTools) -> Self

Sets provider-native tools.

Source

pub fn openai_tools(self, tools: OpenAINativeTools) -> Self

Sets OpenAI Responses-native tools.

Source

pub const fn gemini_tools(self, tools: GeminiNativeTools) -> Self

Sets Gemini-native tools.

Source

pub const fn claude_tools(self, tools: ClaudeNativeTools) -> Self

Sets Claude-native tools.

Source

pub fn prompt_cache_key(self, key: impl Into<String>) -> Self

Sets the OpenAI-compatible prompt cache key.

Source

pub fn prompt_cache_retention( self, retention: OpenAIPromptCacheRetention, ) -> Self

Sets the OpenAI-compatible prompt cache retention policy.

Source

pub const fn claude_prompt_cache(self, cache: ClaudePromptCache) -> Self

Sets Claude prompt caching options.

Source

pub const fn claude_prompt_cache_automatic( self, ttl: ClaudePromptCacheTtl, ) -> Self

Sets Claude prompt caching with automatic top-level cache control.

Source

pub const fn claude_prompt_cache_explicit( self, ttl: ClaudePromptCacheTtl, breakpoints: ClaudeExplicitCacheBreakpoints, ) -> Self

Sets Claude prompt caching with explicit block-level cache breakpoints.

Source

pub const fn claude_prompt_cache_automatic_with_explicit( self, ttl: ClaudePromptCacheTtl, breakpoints: ClaudeExplicitCacheBreakpoints, ) -> Self

Sets Claude prompt caching with automatic and explicit breakpoint modes combined.

Source

pub fn gemini_cached_content(self, cached_content: impl Into<String>) -> Self

Sets the Gemini cached content resource name.

Source

pub fn without_cache(self) -> Self

Clears all provider-specific cache options.

Source

pub fn tool_choice(self, choice: ToolChoice) -> Self

Sets the tool choice policy.

Trait Implementations§

Source§

impl Clone for Parameters

Source§

fn clone(&self) -> Parameters

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 Parameters

Source§

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

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

impl Default for Parameters

Source§

fn default() -> Parameters

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

impl<'de> Deserialize<'de> for Parameters

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 Parameters

Source§

fn eq(&self, other: &Parameters) -> 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 Parameters

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 Parameters

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.