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

  • Harness Bridge

    SDK / Tool

    A local launcher that points Claude Code and seven other coding harnesses at any OpenAI-, Anthropic- or Responses-compatible endpoint — without editing a single config file.

    • launcher
    • local-models
    • cli
    • menu-bar
  • Claude for Siri

    SDK / Tool

    Answers macOS Spotlight and Siri prompts with your signed-in Claude Code account — an experimental macOS 27 model-delegation provider.

    • macos
    • siri
    • spotlight
    • model-delegation
  • Extract your own local chat history from ten AI coding assistants into one normalized JSONL — for fine-tuning, analytics, or backing up years of conversations. Standard library only.

    • cli
    • data-export
    • jsonl
    • backup