View Source Anthropic.Thinking (anthropic_community v0.5.0)

Builds thinking request-param maps for extended thinking. Pass the result as the :thinking option to Anthropic.Messages.create/2 or stream/2.

Examples

Anthropic.Messages.create(client,
  model: "claude-opus-4-8",
  max_tokens: 4096,
  thinking: Anthropic.Thinking.enabled(budget_tokens: 10_000),
  messages: [%{role: "user", content: "..."}]
)

Summary

Functions

Enables adaptive extended thinking — Claude decides how much to think, rather than a fixed token budget.

Disables extended thinking. Equivalent to omitting :thinking entirely, provided for symmetry with enabled/1 and adaptive/1.

Enables extended thinking with a fixed token budget.

Functions

@spec adaptive(keyword()) :: map()

Enables adaptive extended thinking — Claude decides how much to think, rather than a fixed token budget.

Options

  • :display - Controls how thinking content appears in the response. When set to "summarized", thinking is returned normally. When set to "omitted", thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to "summarized".
@spec disabled() :: map()

Disables extended thinking. Equivalent to omitting :thinking entirely, provided for symmetry with enabled/1 and adaptive/1.

@spec enabled(keyword()) :: map()

Enables extended thinking with a fixed token budget.

Options

  • :budget_tokens (pos_integer/0) - Required. Token budget for Claude's internal reasoning. Must be >= 1024 and less than max_tokens.

  • :display - Controls how thinking content appears in the response. When set to "summarized", thinking is returned normally. When set to "omitted", thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to "summarized".