Anthropic Python SDK
The official Python SDK for the Anthropic Claude API, with typed clients, streaming, and tool use.
Repository Health
Technical Analysis
The Anthropic Python SDK is the official client library for calling the Claude API from Python applications. It exposes a fully typed, ergonomic interface over the Messages API, streaming, tool use, batch processing, and model management, so you can integrate Claude without hand-writing HTTP requests or response parsing.
Generated from Anthropic’s OpenAPI specification and hand-augmented with helpers, it ships synchronous and asynchronous clients, automatic retries with backoff, rich error types, and first-class support for running on Amazon Bedrock and Google Vertex AI. Pydantic-backed models give editor autocompletion and static type checking across every request and response.
What You Get
- Synchronous (
Anthropic) and asynchronous (AsyncAnthropic) clients over the full Claude API surface - First-class streaming helpers with typed events for incremental message output
- Built-in tool use, a tool runner, and MCP integration for agentic workflows
- Automatic retries with exponential backoff, configurable timeouts, and typed error hierarchy
- Cloud-provider clients for Amazon Bedrock and Google Vertex AI alongside the direct API
Common Use Cases
- Building chat and assistant experiences powered by Claude models
- Streaming long-form generations token-by-token to a UI or terminal
- Orchestrating tool-calling and agent loops with function definitions and MCP servers
- Running large offline jobs through the Message Batches API
- Deploying Claude on enterprise infrastructure via Bedrock or Vertex AI
Under The Hood
Architecture
The public entry points Anthropic and AsyncAnthropic in src/anthropic/_client.py (~1,100 lines) subclass SyncAPIClient/AsyncAPIClient in src/anthropic/_base_client.py (~2,650 lines), which centralizes the httpx transport, request building, retry-with-backoff logic, pagination, and streaming decode. API surface is organized into resource namespaces under src/anthropic/resources/ (messages, models, completions, and a beta tree), each mapping to typed request/response models in types/. Streaming lives in _streaming.py, while agentic features (tool runner, MCP integration, session runners) sit in lib/tools/, and hand-written auth plus cloud variants live in lib/credentials, lib/bedrock, and lib/vertex.
Tech Stack
Targets Python 3.9+ and is built on httpx for HTTP, Pydantic (v1.9-v3) for validated models, anyio for async, and jiter for fast JSON decoding, with distro and sniffio as runtime helpers. Optional extras pull in aiohttp, boto3/botocore (Bedrock/AWS), google-auth (Vertex), and the mcp package. The core is generated from Anthropic’s OpenAPI spec by Stainless and hand-augmented; the dev toolchain uses uv for locking plus ruff, pyright, mypy, and pytest.
Code Quality
The library is fully typed and ships py.typed, with strict type checking enforced via pyright and mypy in CI. Testing is substantial — roughly 103 test files under tests/ using pytest, pytest-asyncio, respx for HTTP mocking, and inline-snapshot. Error handling is well-structured: _exceptions.py defines a granular hierarchy keyed to HTTP status codes, and retry/timeout behavior is configurable and consistent across sync and async paths.
API Design
The developer experience is a strong point: a client is instantiated with an API key (auto-read from ANTHROPIC_API_KEY) and used through resource-oriented calls like client.messages.create(...), with sync and async interfaces kept symmetric. Getting started requires almost no boilerplate, and the repo backs the API with 30-plus runnable scripts in examples/ plus dedicated api.md, helpers.md, and tools.md references, making the naming and usage patterns easy to discover.
Used by 32 apps in this directory
Activepieces
Automation · AI Assistants
Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.
Agno
Devops · AI Development · Automation
Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.
Apache Airflow
Data Engineering
Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.
ART
AI Development
Give your LLM agents on-the-job training—ART lets you apply GRPO reinforcement learning to any multi-step agentic workflow with minimal code changes.
AutoGen
AI Development · Automation
Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.
AutoGPT
Automation · Productivity · AI Assistants
Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.
Banana Slides
AI Design Tools · Productivity
AI-native PPT generator with Vibe editing, multi-LLM support, and fully editable PPTX export
Docglow
Data Engineering
A next-generation documentation site generator for dbt Core projects — lineage explorer, health scoring, and full-text search for teams without access to dbt Cloud's built-in docs features.
Dragonfly
Databases · Developer Tools · Devops
A modern Redis and Memcached replacement engineered for multi-core servers — delivering 25x more throughput, better cache hit rates, and up to 80% lower memory consumption with full API compatibility.