pub struct ThinkingConfig {
pub thinking_budget: Option<i32>,
pub include_thoughts: Option<bool>,
pub thinking_level: Option<ThinkingLevel>,
}models and gemini only.Expand description
Configuration for thinking (Gemini 2.5 and 3 series)
Fields§
§thinking_budget: Option<i32>The thinking budget (number of thinking tokens)
This is the Gemini 2.5 budget-based thinking control.
- Set to 0 to disable thinking
- Set to -1 for dynamic thinking (model decides)
- Set to a positive number for a specific token budget
Model-specific ranges:
- 2.5 Pro: 128 to 32768 (cannot disable thinking)
- 2.5 Flash: 0 to 24576
- 2.5 Flash Lite: 512 to 24576
include_thoughts: Option<bool>Whether to include thought summaries in the response
When enabled, the response will include synthesized versions of the model’s raw thoughts, providing insights into the reasoning process.
thinking_level: Option<ThinkingLevel>Native thinking level for Gemini 3 models.
When set, the model uses level-based reasoning instead of a token budget.
Do not combine with thinking_budget — use one or the other.
Implementations§
Source§impl ThinkingConfig
impl ThinkingConfig
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the thinking configuration.
Returns an error if both thinking_budget and thinking_level are set,
since they are mutually exclusive controls (budget for Gemini 2.5, level for Gemini 3).
Sourcepub fn new() -> ThinkingConfig
pub fn new() -> ThinkingConfig
Create a new thinking config with default settings
Sourcepub fn with_thinking_budget(self, budget: i32) -> ThinkingConfig
pub fn with_thinking_budget(self, budget: i32) -> ThinkingConfig
Set the thinking budget (Gemini 2.5 budget-based control)
Sourcepub fn with_dynamic_thinking(self) -> ThinkingConfig
pub fn with_dynamic_thinking(self) -> ThinkingConfig
Enable dynamic thinking (model decides the budget)
Sourcepub fn with_thoughts_included(self, include: bool) -> ThinkingConfig
pub fn with_thoughts_included(self, include: bool) -> ThinkingConfig
Include thought summaries in the response
Sourcepub fn with_thinking_level(self, level: ThinkingLevel) -> ThinkingConfig
pub fn with_thinking_level(self, level: ThinkingLevel) -> ThinkingConfig
Set the thinking level (Gemini 3 native level-based control).
This is the preferred control for Gemini 3 models. Do not combine
with with_thinking_budget — use one or the other.
Sourcepub fn dynamic_thinking() -> ThinkingConfig
pub fn dynamic_thinking() -> ThinkingConfig
Create a thinking config that enables dynamic thinking with thoughts included
Trait Implementations§
Source§impl Clone for ThinkingConfig
impl Clone for ThinkingConfig
Source§fn clone(&self) -> ThinkingConfig
fn clone(&self) -> ThinkingConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more