pub struct ThinkingConfig {
pub thinking_type: ThinkingType,
pub budget_tokens: Option<u32>,
pub effort: Option<ThinkingEffort>,
pub exclude_from_response: bool,
}Expand description
Configuration for extended thinking / reasoning mode.
Extended thinking allows models to “think” more deeply about problems, producing better results for complex reasoning tasks. This config works across multiple providers:
- Anthropic: Maps to Claude’s extended thinking with
budget_tokens - OpenRouter: Maps to
reasoningparameter witheffortlevels - DeepSeek: Maps to
enable_thinkingparameter - Qwen3: Controlled via provider-specific parameters
§Example
// Enable thinking with budget
let request = CompletionRequest::new(model, messages)
.with_thinking(ThinkingConfig::enabled(10000));
// Disable thinking for faster responses
let request = CompletionRequest::new(model, messages)
.without_thinking();
// Control effort level (OpenRouter)
let request = CompletionRequest::new(model, messages)
.with_thinking(ThinkingConfig::with_effort(ThinkingEffort::Low));Fields§
§thinking_type: ThinkingTypeWhether thinking is enabled
budget_tokens: Option<u32>Maximum tokens for thinking (minimum 1024 for Anthropic)
effort: Option<ThinkingEffort>Effort level for reasoning (supported by OpenRouter and similar providers)
exclude_from_response: boolIf true, reasoning is performed but excluded from the response. The model still “thinks” but the thinking tokens are hidden.
Implementations§
Source§impl ThinkingConfig
impl ThinkingConfig
Sourcepub fn enabled(budget_tokens: u32) -> Self
pub fn enabled(budget_tokens: u32) -> Self
Enable extended thinking with a token budget.
§Arguments
budget_tokens- Maximum tokens for thinking (minimum 1024)
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
Disable extended thinking/reasoning.
This will disable reasoning for providers that support it:
- OpenRouter: Sets
reasoning.effortto “none” - DeepSeek: Sets
enable_thinkingto false - Anthropic: Omits the thinking block
Sourcepub fn with_effort(effort: ThinkingEffort) -> Self
pub fn with_effort(effort: ThinkingEffort) -> Self
Create a thinking config with a specific effort level.
Useful for providers like OpenRouter that support effort-based reasoning control.
§Arguments
effort- The reasoning effort level (Low, Medium, High, Max)
Sourcepub fn with_effort_and_budget(
effort: ThinkingEffort,
budget_tokens: u32,
) -> Self
pub fn with_effort_and_budget( effort: ThinkingEffort, budget_tokens: u32, ) -> Self
Create a thinking config with effort level and token budget.
§Arguments
effort- The reasoning effort levelbudget_tokens- Maximum tokens for reasoning
Sourcepub fn exclude_from_response(self, exclude: bool) -> Self
pub fn exclude_from_response(self, exclude: bool) -> Self
Set whether to exclude thinking from the response.
When true, the model still performs reasoning but the thinking tokens are not included in the response.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if thinking is enabled.
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<'de> Deserialize<'de> for ThinkingConfig
impl<'de> Deserialize<'de> for ThinkingConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ThinkingConfig
impl PartialEq for ThinkingConfig
Source§impl Serialize for ThinkingConfig
impl Serialize for ThinkingConfig
impl Eq for ThinkingConfig
impl StructuralPartialEq for ThinkingConfig
Auto Trait Implementations§
impl Freeze for ThinkingConfig
impl RefUnwindSafe for ThinkingConfig
impl Send for ThinkingConfig
impl Sync for ThinkingConfig
impl Unpin 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.