ClaudeMap

Anthropic Python SDK

Official Python client for the Anthropic API.

SDKs & Toolingofficialsdkpythonanthropic

Official Python client for the Anthropic API — Messages, Batch, Files, Token Counting, and Vision. Idiomatic Python with sync / async / streaming; the canonical client for Claude in Python.

What it does

  • Messages API with sync / async / streaming clients
  • Built-in prompt caching via cache_control breakpoints
  • Batch API for 50% off async workloads
  • Token counting and cost estimation helpers
  • Tool use with strict schema validation and tool_choice controls

When to use it

Best for Python services calling the Claude API directly, async backends doing batch processing, and notebooks / scripts that need streaming for UIs. Pairs naturally with FastAPI for serving, LangChain for orchestration, and any database for memory.

Getting started

pip install anthropic

Set ANTHROPIC_API_KEY (and optionally ANTHROPIC_BASE_URL for Bedrock / Vertex) before importing.

Things to know

The SDK tracks prompt caching version differences carefully — pinning to a major version is recommended in production. For long-running batch workloads, use the AsyncAnthropic client; the sync client can hold the event loop.

Repository

anthropics/anthropic-sdk-python

Charted

Related on the map

  • E2B

    SDK / Tool

    Open-source secure sandboxes where AI agents run code — the de facto execution layer for agent apps.

    • sandbox
    • code-execution
    • sdk
    • agents
  • FastMCP

    SDK / Tool

    Pythonic framework for building MCP servers — decorators, type hints, and zero boilerplate.

    • framework
    • python
    • mcp
    • type-driven
  • Anthropic's official TypeScript SDK for building agentic applications.

    • official
    • sdk
    • typescript
    • anthropic