
Anthropic Python SDK
https://github.com/anthropics/anthropic-sdk-python- Category
- Developer Tools
- Rank
- No. 291Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- anthropics
- GitHub
- 3.9k stars
- Latest release
- v1.4.0
- Date
About
Official Anthropic Python SDK for the Claude API — messages, tool use, streaming, batch, files, citations, vision, and prompt caching.
What it does
A typed Python client that turns Claude API requests and responses into familiar objects. It offers synchronous and asynchronous clients, structured errors, configurable transports, middleware, and generated models for request and response data.
Why it's ranked here
A strong default for Python teams using Anthropic directly or through supported cloud providers. The package combines broad API coverage with strict typing, explicit error classes, streaming variants, and optional integrations without forcing every dependency into the base installation.
What's good
The public surface covers synchronous and asynchronous work consistently. Generated data models expose detailed content, event, capability, citation, tool, and error shapes. Separate clients support AWS, Google Cloud, Vertex, Foundry, and Bedrock. Strict Pyright settings, extensive mypy checks, warning failures, and parallel tests indicate serious maintenance discipline.
Tradeoffs
Python 3.8 and older are unsupported. Several integrations require separate optional dependency groups, and MCP support requires Python 3.10 or newer. Much of the public model surface is generated from an OpenAPI specification, so users face a large vocabulary of closely related stable and beta types.
How to use it well
Choose it for typed Python services, scripts, or workers that call Claude and need synchronous or asynchronous execution. Add only the cloud, webhook, alternate transport, or MCP extras your deployment needs. It does not serve Python 3.8 environments or replace the remote API and credentials it connects to.
Technical notes+
README.md documents the basic client flow and environment-based API key. pyproject.toml packages src/anthropic with Hatchling, declares the base HTTP, validation, async, parsing, and typing dependencies, and defines optional extras for aiohttp, Vertex, Google Cloud, AWS, Bedrock, MCP, and webhooks. src/anthropic/__init__.py exports sync and async clients, streams, middleware, transport classes, error types, cloud clients, tool decorators, and generated API models. src/anthropic/resources/__init__.py exposes sync, async, raw-response, and streaming-response resource variants. src/anthropic/types/__init__.py and src/anthropic/types/beta/__init__.py show a large Stainless-generated type surface. The test configuration targets tests, enables strict expected-failure handling, treats warnings as errors, and runs pytest in parallel.
Observed
- License
- MIT License
- Primary language
- Python
- Install surface
- Published Python package installed with pip install anthropic
- Interface
- Typed Python library for the Claude API with synchronous and asynchronous clients
- Python support
- Requires Python 3.9 or newer; MCP extra requires Python 3.10 or newer
- Platform support
- Classified as OS independent, with POSIX, macOS, Linux, and Windows support
- Packaging
- Hatchling build backend with source package under src/anthropic
- Structure
- Core API exports and type modules are generated from an OpenAPI specification by Stainless
Read from README.md, pyproject.toml, src/anthropic/__init__.py, src/anthropic/lib/__init__.py, src/anthropic/tools/__init__.py, src/anthropic/types/__init__.py, src/anthropic/_utils/__init__.py, src/anthropic/resources/__init__.py, src/anthropic/lib/aws/__init__.py, src/anthropic/lib/tools/__init__.py, src/anthropic/lib/vertex/__init__.py, src/anthropic/types/beta/__init__.py, src/anthropic/lib/_extras/__init__.py, src/anthropic/lib/bedrock/__init__.py, src/anthropic/lib/sessions/__init__.py.
What it can do
Send messages to Claude AI
Text prompts and conversation context → AI-generated text responses
Execute tool use with Claude
Function definitions and parameters → Structured function call results
Stream real-time responses from Claude
Text prompts → Incremental text tokens as they're generated
Process batch requests to Claude API
Multiple prompts or requests → Batch response results
Upload and manage files for Claude
File data and metadata → File references for use in conversations
Analyze images with Claude
Image files and optional text prompts → Text descriptions or analysis of image content
Generate responses with source citations
Text prompts with reference materials → Responses with citation metadata
Cache prompts for repeated use
Prompt templates or frequently used prompts → Cached prompt references for faster API calls
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.