Anthropic Python SDK

raw JSON →
0.84.0 verified Mon May 11 auth: no python install: verified quickstart: verified

Official Python SDK for the Anthropic API providing access to Claude models. Current version is 0.84.0 (Feb 2026). Releases approximately weekly. Two separate packages exist: anthropic (core SDK) and claude-agent-sdk-python (agent workflows).

pip install anthropic
error ModuleNotFoundError: No module named 'anthropic'
cause The 'anthropic' package is not installed in the Python environment.
fix
Install the package using 'pip install anthropic'.
error ImportError: cannot import name 'Anthropic' from 'anthropic'
cause The import statement is incorrect; 'Anthropic' is not a valid import from the 'anthropic' package.
fix
Use 'from anthropic import AnthropicClient' instead.
error AttributeError: module 'anthropic' has no attribute 'Anthropic'
cause The 'Anthropic' class does not exist in the 'anthropic' module.
fix
Instantiate the client with 'client = anthropic.AnthropicClient()'.
error TypeError: __init__() missing 1 required positional argument: 'api_key'
cause The 'AnthropicClient' class requires an 'api_key' argument during initialization.
fix
Initialize with 'client = anthropic.AnthropicClient(api_key="your_api_key")'.
error ValueError: Invalid API key provided
cause The provided API key is incorrect or malformed.
fix
Ensure the API key is correct and properly formatted.
breaking anthropic.Client() is removed. Use anthropic.Anthropic() instead.
fix client = Anthropic(api_key=os.environ.get('ANTHROPIC_API_KEY'))
gotcha SDK releases weekly. Pin your version in production or expect frequent behaviour changes.
fix Pin with anthropic==0.84.0 in requirements.txt
gotcha message.content is a list, not a string. Access text via message.content[0].text.
fix print(message.content[0].text) not print(message.content)
gotcha max_tokens is required. No default value. Omitting raises a validation error.
fix Always pass max_tokens=1024 or appropriate value
deprecated claude-agent-sdk-python no longer requires Claude Code to be installed separately. It is bundled.
fix Remove any separate Claude Code install steps from your setup.
breaking The package `claude-agent-sdk` is not a valid PyPI package and cannot be found. If you are trying to install the main Anthropic SDK, use `anthropic`. If you are looking for an agent-specific SDK, you might be looking for `claude-agent-sdk-python`.
fix Replace `claude-agent-sdk` with `anthropic` or `claude-agent-sdk-python` in your requirements/install commands.
breaking Failed to authenticate due to missing API key. Ensure `api_key` is passed during client initialization or set the `ANTHROPIC_API_KEY` environment variable.
fix client = Anthropic(api_key=os.environ.get('ANTHROPIC_API_KEY'))
pip install claude-agent-sdk
npm install @anthropic-ai/sdk
python os / libc variant status wheel install import disk
3.10 alpine (musl) anthropic - - 3.29s 39.8M
3.10 alpine (musl) claude-agent-sdk - - - -
3.10 slim (glibc) anthropic - - 2.37s 39M
3.10 slim (glibc) claude-agent-sdk - - - -
3.11 alpine (musl) anthropic - - 4.27s 43.2M
3.11 alpine (musl) claude-agent-sdk - - - -
3.11 slim (glibc) anthropic - - 3.65s 42M
3.11 slim (glibc) claude-agent-sdk - - - -
3.12 alpine (musl) anthropic - - 3.97s 34.6M
3.12 alpine (musl) claude-agent-sdk - - - -
3.12 slim (glibc) anthropic - - 3.91s 34M
3.12 slim (glibc) claude-agent-sdk - - - -
3.13 alpine (musl) anthropic - - 3.56s 34.3M
3.13 alpine (musl) claude-agent-sdk - - - -
3.13 slim (glibc) anthropic - - 3.70s 33M
3.13 slim (glibc) claude-agent-sdk - - - -
3.9 alpine (musl) anthropic - - 3.19s 39.1M
3.9 alpine (musl) claude-agent-sdk - - - -
3.9 slim (glibc) anthropic - - 2.94s 38M
3.9 slim (glibc) claude-agent-sdk - - - -

Minimal message call using the Anthropic SDK 0.84.x.

from anthropic import Anthropic

client = Anthropic()  # reads ANTHROPIC_API_KEY from env
message = client.messages.create(
    model='claude-opus-4-6',
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude"}
    ]
)
print(message.content[0].text)