This is the documentation for the Claude SDK for Python (anthropic-sdk-python, published to PyPI as anthropic) — Anthropic's official Python client for the Claude API and its surrounding platform services. The SDK covers the direct Anthropic API plus first-party cloud backends (AWS Bedrock, Google Vertex AI, Microsoft Azure Foundry, and AnthropicAWS for Claude Platform on AWS) and the Managed Agents (CMA) platform for hosted agent orchestration. The bulk of the surface is generated by Stainless codegen, with substantial hand-written helpers layered on top for streaming, tool-running, credential resolution, and middleware; Python 3.9 or later is required.
Client setup is the entry point: Installation and packaging covers install and extras, Client construction and credentials shows the minimal Anthropic() usage, Credential providers and chain details the full precedence order, and Base client and pagination documents shared client machinery. Messages and streaming groups the core inference surface — Messages API and Beta messages surface describe the resources, while Raw stream primitives, MessageStream helpers, and Streaming event types cover synchronous and asynchronous streaming. HTTP and middleware covers the plumbing: HTTP core and models for BaseModel and response parsing, Exceptions for the error hierarchy, Middleware system for the extension point, and Refusal fallback middleware for the built-in BetaRefusalFallbackMiddleware. Function tools covers agentic helpers — the beta_tool decorators, the Tool runner loop, Agent toolset and skills (bash, read, write, edit, glob, grep), and MCP integration for Model Context Protocol servers. Managed Agents platform documents the CMA surface: the Agents resource and Sessions resource, plus the self-hosted execution helpers Environment worker, Work poller, and Session event accumulation. Cloud and deployment covers Cloud backends (Bedrock and Vertex clients) and Upgrading and version history, and Development and examples covers Development and CI plus runnable Examples.
If you came here to send your first request, read Installation and packaging and then Client construction and credentials — the quickstart shows the canonical client.messages.create(...) call in a few lines. If you came here to build an agent that calls tools in a loop, start with Function tools and then Tool runner, and consult Agent toolset and skills or MCP integration depending on where your tools come from. If you came here to stream responses or handle events incrementally, read MessageStream helpers first and then Streaming event types to understand the ParsedMessageStreamEvent union that iteration yields. If you came here to debug an HTTP failure, customize retries, or plug in auth logic, read Exceptions and Middleware system; for Bedrock or Vertex specifics jump to Cloud backends. If you came here to contribute, read Development and CI for the uv-based toolchain and lint/test setup, and browse Examples for the canonical multi-turn, tool-use, and streaming patterns.