Anthropic Python SDK

The official Python SDK for the Anthropic Claude API, with typed clients, streaming, and tool use.

SDK
PyPI
v0.122.0
3,834stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
96/100Excellent
Development Activity100
Maintenance100
Community92
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
91/100Excellent
Architecture92
Code Quality95
Innovation90
Learning Curve85

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

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

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.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
88%
Apache 2.0

ART

AI Development

10,603

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.

View details
85
Repo Health
82
Technical
72
Dependency
Built with
Python88%
Cuda10%
Updated today
Python
62%
MIT

AutoGen

AI Development · Automation

60,518

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
57
Repo Health
78
Technical
75
Dependency
Built with
Python62%
C#25%
TypeScript12%
Updated 4 months ago
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
TypeScript
48%
AGPL 3.0

Banana Slides

AI Design Tools · Productivity

15,476

AI-native PPT generator with Vibe editing, multi-LLM support, and fully editable PPTX export

View details
83
Repo Health
82
Technical
71
Dependency
Built with
TypeScript48%
Python47%
Updated 3 days ago
Python
57%
MIT

Docglow

Data Engineering

137

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.

View details
67
Repo Health
65
Technical
82
Dependency
Built with
Python57%
TypeScript42%
Updated 1 weeks ago
C++
74%
Other

Dragonfly

Databases · Developer Tools · Devops

31,013

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.

View details
90
Repo Health
9
Technical
71
Dependency
Built with
C++74%
Python16%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search