examples/anthropic-interleaved-thinking/README.md
This example demonstrates Claude 3.7+'s interleaved thinking capability, which allows the model to use thinking tokens between tool calls for better multi-step reasoning.
Interleaved thinking enables Claude to:
# Set your API key
export ANTHROPIC_API_KEY=your-api-key
# Run the example
go run .
// Enable interleaved thinking for tool use
opts := []llms.CallOption{
// Thinking mode for reasoning
llms.WithThinkingMode(llms.ThinkingModeMedium),
// Enable interleaved thinking beta feature
anthropic.WithInterleavedThinking(),
// Provide tools for the model to use
llms.WithTools(tools),
}
The demo presents a multi-step analysis task:
Between each tool call, Claude uses thinking tokens to:
The example displays detailed token usage:
claude-3-7-sonnet-20250219)