Implementation:Anthropics Anthropic sdk python ThinkingConfigParam
| Knowledge Sources | |
|---|---|
| Domains | Extended_Thinking, LLM, Reasoning |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
ThinkingConfigParam is a discriminated union type alias that represents the three possible thinking configuration modes in the Anthropic Python SDK. It is defined as a Union of three TypedDict subclasses, each corresponding to one thinking mode: enabled (explicit budget), disabled (no thinking), and adaptive (model decides).
Type Definition
Source: src/anthropic/types/thinking_config_param.py (Lines 14-16)
ThinkingConfigParam: TypeAlias = Union[
ThinkingConfigEnabledParam, ThinkingConfigDisabledParam, ThinkingConfigAdaptiveParam
]
Import:
from anthropic.types import ThinkingConfigParam
Variant Types
ThinkingConfigEnabledParam
Source: src/anthropic/types/thinking_config_enabled_param.py (Lines 10-24)
class ThinkingConfigEnabledParam(TypedDict, total=False):
budget_tokens: Required[int]
"""Determines how many tokens Claude can use for its internal reasoning process.
Larger budgets can enable more thorough analysis for complex problems, improving
response quality.
Must be >= 1024 and less than `max_tokens`.
See
[extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
for details.
"""
type: Required[Literal["enabled"]]
Fields:
budget_tokens(Required[int]): The maximum number of tokens the model can use for internal reasoning. Must be >= 1024 and strictly less thanmax_tokens.type(Required[Literal["enabled"]]): Discriminator field, must be"enabled".
ThinkingConfigDisabledParam
Source: src/anthropic/types/thinking_config_disabled_param.py (Lines 10-11)
class ThinkingConfigDisabledParam(TypedDict, total=False):
type: Required[Literal["disabled"]]
Fields:
type(Required[Literal["disabled"]]): Discriminator field, must be"disabled".
ThinkingConfigAdaptiveParam
Source: src/anthropic/types/thinking_config_adaptive_param.py (Lines 10-11)
class ThinkingConfigAdaptiveParam(TypedDict, total=False):
type: Required[Literal["adaptive"]]
Fields:
type(Required[Literal["adaptive"]]): Discriminator field, must be"adaptive".
Usage Examples
Enabled Mode with Explicit Budget
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
messages=[{"role": "user", "content": "Solve this step by step: What is 15% of 340?"}]
)
for block in message.content:
if block.type == "thinking":
print(f"Thinking: {block.thinking}")
elif block.type == "text":
print(f"Answer: {block.text}")
Adaptive Mode
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=16000,
thinking={"type": "adaptive"},
messages=[{"role": "user", "content": "What is 2+2?"}]
)
Disabled Mode
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=16000,
thinking={"type": "disabled"},
messages=[{"role": "user", "content": "Hello!"}]
)
Dependencies
typing.Union: Used to define the union type alias.typing_extensions.TypeAlias: Provides theTypeAliasannotation for the union.typing_extensions.Literal: Used for the discriminatortypefield in each variant.typing_extensions.Required: Marks required fields inTypedDictsubclasses (sincetotal=Falseis set).typing_extensions.TypedDict: Base class for all three variant types.
Constraints and Validation
budget_tokensmust be >= 1024 (minimum reasoning budget).budget_tokensmust be strictly less than themax_tokensparameter passed to the API call.- The
typediscriminator field is required in all variants and determines which mode is active. - All three variants use
total=FalsewithRequiredannotations, following the standard Stainless SDK generation pattern for TypedDict params.