Anthropic Claude API in Python
anthropic.Anthropic(), messages.create(), content blocks, extended thinking, streaming.
The Anthropic SDK
Anthropic's Claude models are accessed through the anthropic Python package. Install with pip install anthropic. Claude excels at long-context reasoning, careful instruction following, and tool use.
pip install anthropic
import anthropicCreating the Client
Build the client with anthropic.Anthropic(). It reads your key from the ANTHROPIC_API_KEY environment variable by default, keeping credentials out of code.
import anthropic
client = anthropic.Anthropic()
# Or explicitly
client = anthropic.Anthropic(api_key="sk-ant-...")