pub struct ThinkingConfig {
pub thinking_budget: Option<i32>,
pub include_thoughts: Option<bool>,
pub thinking_level: Option<ThinkingLevel>,
}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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThinkingConfig
impl Debug for ThinkingConfig
Source§impl Default for ThinkingConfig
impl Default for ThinkingConfig
Source§fn default() -> ThinkingConfig
fn default() -> ThinkingConfig
Source§impl<'de> Deserialize<'de> for ThinkingConfig
impl<'de> Deserialize<'de> for ThinkingConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThinkingConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThinkingConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ThinkingConfig
impl Serialize for ThinkingConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ThinkingConfig
impl RefUnwindSafe for ThinkingConfig
impl Send for ThinkingConfig
impl Sync for ThinkingConfig
impl Unpin for ThinkingConfig
impl UnsafeUnpin for ThinkingConfig
impl UnwindSafe for ThinkingConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request