Anthropic Python SDK

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

SDK
PyPI
v1.8.0
3,922 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
95 /100 Excellent
Development Activity 96
Maintenance 100
Community 92
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
91 /100 Excellent
Architecture 92
Code Quality 95
Innovation 90
Learning Curve 85

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 34 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

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
64
Dependency
Built with
TypeScript 100%
Updated 4 days ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

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

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 4 days ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

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
64
Dependency
Built with
Python 89%
Updated 4 days ago
Python
59%
Other

Arkon

AI Assistants · Knowledge Management · Mcp

1,463

Self-hosted enterprise AI knowledge hub that compiles internal docs into a scoped, reviewable wiki and serves it to Claude and other LLMs through an MCP server.

View details
46
Repo Health
74
Technical
70
Dependency
Built with
Python 59%
TypeScript 41%
Updated 4 months ago
Python
92%
Apache 2.0

ART

AI Development

10,779

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
73
Dependency
Built with
Python 92%
Updated 5 days ago
Python
62%
MIT

AutoGen

AI Development · Automation

61,194

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
56
Repo Health
78
Technical
73
Dependency
Built with
Python 62%
C# 25%
TypeScript 12%
Updated 5 months ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

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
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
TypeScript
49%
AGPL 3.0

Banana Slides

AI Design Tools · Productivity

15,667

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

View details
84
Repo Health
82
Technical
71
Dependency
Built with
TypeScript 49%
Python 46%
Updated 5 days ago
Python
58%
MIT

Docglow

Data Engineering

147

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
Python 58%
TypeScript 42%
Updated 6 days ago

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