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: ToolChoiceTool 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: boolWhether the provider should include reasoning summaries in the response stream.
structured_outputs: boolWhether 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: boolWhether to enable native Search tool for grounding.
code_execution: boolWhether to enable native Code Execution tool.
native_tools: NativeToolsProvider-native tools that are not portable across API families.
cache: CacheOptionsProvider-specific prompt cache controls.
Implementations§
Source§impl Parameters
impl Parameters
Sourcepub fn temperature(self, value: f32) -> Self
pub fn temperature(self, value: f32) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value- The value to set for this parameter
Sourcepub fn top_p(self, value: f32) -> Self
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
Sourcepub fn top_k(self, value: u32) -> Self
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
Sourcepub fn frequency_penalty(self, value: f32) -> Self
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
Sourcepub fn presence_penalty(self, value: f32) -> Self
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
Sourcepub fn repetition_penalty(self, value: f32) -> Self
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
Sourcepub fn min_p(self, value: f32) -> Self
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
Sourcepub fn seed(self, value: u32) -> Self
pub fn seed(self, value: u32) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value- The value to set for this parameter
Sourcepub fn max_tokens(self, value: u32) -> Self
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
Sourcepub fn logit_bias(self, value: Vec<(String, f32)>) -> Self
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
Sourcepub fn logprobs(self, value: bool) -> Self
pub fn logprobs(self, value: bool) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value- The value to set for this parameter
Sourcepub fn top_logprobs(self, value: u8) -> Self
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
Sourcepub fn stop(self, value: Vec<String>) -> Self
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
Sourcepub fn parallel_tool_calls(self, value: bool) -> Self
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
impl Parameters
Sourcepub const fn include_reasoning(self, include: bool) -> Self
pub const fn include_reasoning(self, include: bool) -> Self
Sets whether providers should include reasoning summaries.
Sourcepub const fn reasoning_effort(self, effort: ReasoningEffort) -> Self
pub const fn reasoning_effort(self, effort: ReasoningEffort) -> Self
Sets the preferred reasoning effort.
Sourcepub const fn websearch(self, enabled: bool) -> Self
pub const fn websearch(self, enabled: bool) -> Self
Sets whether to enable native Google Search tool.
Sourcepub const fn code_execution(self, enabled: bool) -> Self
pub const fn code_execution(self, enabled: bool) -> Self
Sets whether to enable native Code Execution tool.
Sourcepub fn native_tools(self, tools: NativeTools) -> Self
pub fn native_tools(self, tools: NativeTools) -> Self
Sets provider-native tools.
Sourcepub fn openai_tools(self, tools: OpenAINativeTools) -> Self
pub fn openai_tools(self, tools: OpenAINativeTools) -> Self
Sets OpenAI Responses-native tools.
Sourcepub const fn gemini_tools(self, tools: GeminiNativeTools) -> Self
pub const fn gemini_tools(self, tools: GeminiNativeTools) -> Self
Sets Gemini-native tools.
Sourcepub const fn claude_tools(self, tools: ClaudeNativeTools) -> Self
pub const fn claude_tools(self, tools: ClaudeNativeTools) -> Self
Sets Claude-native tools.
Sourcepub fn prompt_cache_key(self, key: impl Into<String>) -> Self
pub fn prompt_cache_key(self, key: impl Into<String>) -> Self
Sets the OpenAI-compatible prompt cache key.
Sourcepub fn prompt_cache_retention(
self,
retention: OpenAIPromptCacheRetention,
) -> Self
pub fn prompt_cache_retention( self, retention: OpenAIPromptCacheRetention, ) -> Self
Sets the OpenAI-compatible prompt cache retention policy.
Sourcepub const fn claude_prompt_cache(self, cache: ClaudePromptCache) -> Self
pub const fn claude_prompt_cache(self, cache: ClaudePromptCache) -> Self
Sets Claude prompt caching options.
Sourcepub const fn claude_prompt_cache_automatic(
self,
ttl: ClaudePromptCacheTtl,
) -> Self
pub const fn claude_prompt_cache_automatic( self, ttl: ClaudePromptCacheTtl, ) -> Self
Sets Claude prompt caching with automatic top-level cache control.
Sourcepub const fn claude_prompt_cache_explicit(
self,
ttl: ClaudePromptCacheTtl,
breakpoints: ClaudeExplicitCacheBreakpoints,
) -> Self
pub const fn claude_prompt_cache_explicit( self, ttl: ClaudePromptCacheTtl, breakpoints: ClaudeExplicitCacheBreakpoints, ) -> Self
Sets Claude prompt caching with explicit block-level cache breakpoints.
Sourcepub const fn claude_prompt_cache_automatic_with_explicit(
self,
ttl: ClaudePromptCacheTtl,
breakpoints: ClaudeExplicitCacheBreakpoints,
) -> Self
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.
Sourcepub fn gemini_cached_content(self, cached_content: impl Into<String>) -> Self
pub fn gemini_cached_content(self, cached_content: impl Into<String>) -> Self
Sets the Gemini cached content resource name.
Sourcepub fn without_cache(self) -> Self
pub fn without_cache(self) -> Self
Clears all provider-specific cache options.
Sourcepub fn tool_choice(self, choice: ToolChoice) -> Self
pub fn tool_choice(self, choice: ToolChoice) -> Self
Sets the tool choice policy.
Trait Implementations§
Source§impl Clone for Parameters
impl Clone for Parameters
Source§fn clone(&self) -> Parameters
fn clone(&self) -> Parameters
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more