Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Anthropics Anthropic sdk python ThinkingConfigParam

From Leeroopedia
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 than max_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 the TypeAlias annotation for the union.
  • typing_extensions.Literal: Used for the discriminator type field in each variant.
  • typing_extensions.Required: Marks required fields in TypedDict subclasses (since total=False is set).
  • typing_extensions.TypedDict: Base class for all three variant types.

Constraints and Validation

  • budget_tokens must be >= 1024 (minimum reasoning budget).
  • budget_tokens must be strictly less than the max_tokens parameter passed to the API call.
  • The type discriminator field is required in all variants and determines which mode is active.
  • All three variants use total=False with Required annotations, following the standard Stainless SDK generation pattern for TypedDict params.

Related Pages

Implements Principle

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment