pub struct ThinkingType {
pub mode: ThinkingMode,
pub clear_thinking: Option<bool>,
}Expand description
Controls thinking/reasoning capabilities in AI models.
This structure determines whether a model should engage in step-by-step
reasoning when processing requests, and whether to preserve reasoning
content across turns via clear_thinking. Thinking mode can improve
accuracy for complex tasks but may increase response time and token usage.
§Fields
mode- Whether thinking is enabled or disabledclear_thinking- Whenfalse, preservesreasoning_contentacross turns (recommended for Coding / Agent scenarios)
§Usage
ⓘ
let client = ChatCompletion::new(model, messages, api_key)
.with_thinking(ThinkingType::enabled());
// Preserve reasoning content across turns (Coding / Agent)
let client = ChatCompletion::new(model, messages, api_key)
.with_thinking(ThinkingType::enabled().with_clear_thinking(false));§Model Compatibility
Thinking capabilities are available only on models that implement the
ThinkEnable trait, such as GLM-5.1, GLM-5, GLM-4.7, and GLM-4.5 series
models.
Fields§
§mode: ThinkingModeWhether thinking is enabled or disabled.
clear_thinking: Option<bool>Whether to clear historical reasoning_content.
true(default for standard API): Clears reasoning content each turn.false(recommended for Coding / Agent): Preserves reasoning content across turns, enabling better context for multi-step tool calls.
Implementations§
Source§impl ThinkingType
impl ThinkingType
Sourcepub fn with_clear_thinking(self, clear: bool) -> Self
pub fn with_clear_thinking(self, clear: bool) -> Self
Set whether to clear historical reasoning content.
Use false for Coding / Agent scenarios where reasoning content should
be preserved across turns.
Trait Implementations§
Source§impl Clone for ThinkingType
impl Clone for ThinkingType
Source§fn clone(&self) -> ThinkingType
fn clone(&self) -> ThinkingType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThinkingType
impl Debug for ThinkingType
Auto Trait Implementations§
impl Freeze for ThinkingType
impl RefUnwindSafe for ThinkingType
impl Send for ThinkingType
impl Sync for ThinkingType
impl Unpin for ThinkingType
impl UnsafeUnpin for ThinkingType
impl UnwindSafe for ThinkingType
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
Mutably borrows from an owned value. Read more