SDKs (Python, TypeScript)
Anthropic's official Python and TypeScript SDKs are client libraries that wrap the Claude Messages API, making it easier to build applications without dealing with raw HTTP requests or manual response parsing. Each SDK provides idiomatic language interfaces, strong type safety, automatic retry logic with exponential backoff, and built-in streaming support via server-sent events. They handle authentication, request formatting, and error handling so developers can focus on application logic rather than infrastructure.
The Python SDK is available as the `anthropic` package on PyPI and supports both synchronous and asynchronous (`AsyncAnthropic`) clients. The TypeScript SDK is available as `@anthropic-ai/sdk` on npm and is designed for Node.js and browser environments. Both SDKs expose the same core capabilities—text generation, tool use, streaming, vision, and extended thinking—with language-appropriate patterns.
Beyond basic message generation, both SDKs include helpers for advanced workflows: streaming helpers that accumulate events into a final message object, tool execution loops, Model Context Protocol (MCP) integration, and beta feature access via a dedicated namespace. They are open-source and actively maintained on GitHub.
When you’d use it
- ◆Simple chatbot backend — A developer wants to add a Claude-powered Q&A feature to a web app. They use the Python SDK's synchronous client inside a Django or Flask route to send user messages and return Claude's reply.
- ◆High-throughput async batch processing — A data engineering team needs to categorize thousands of support tickets overnight. They use Python's `AsyncAnthropic` client with `asyncio.gather()` to run hundreds of concurrent, non-blocking API calls, completing the job in minutes instead of hours.
- ◆Streaming real-time responses — A writing tool wants to show Claude's output word-by-word rather than waiting for the full response. The developer uses the SDK's `.stream()` context manager to pipe text tokens to the UI as they arrive, then calls `.get_final_message()` to retrieve usage statistics.
- ◆Tool use and function calling — A developer builds an assistant that can look up live stock prices. They define a `get_stock_price` tool in the SDK's schema format, and when Claude returns a `tool_use` block, the application executes the real function and feeds the result back in a follow-up message.
- ◆Agentic workflows with MCP — An engineering team wants Claude to autonomously query internal databases and call external APIs during a multi-step task. They use the SDK's in-process MCP server helpers (`create_sdk_mcp_server` in Python, `createSdkMcpServer` in TypeScript) to expose custom tools without running a separate process.
What changed recently
- ◆2026-04-30 — The 1M token context window beta for Claude Sonnet 4.5 and Claude Sonnet 4 was retired. The beta header now has no effect on these models, and requests exceeding the standard 200k-token context window return an error. Migration to models that support the larger context window is required.
- ◆2026-06-15 — Agent SDK monthly credit became available for eligible Pro, Max, Team, and Enterprise plan users. Claude Platform accounts authenticating via API key do not receive this credit and continue on pay-as-you-go billing.
- ◆2026-04 — Tool helpers entered beta for both Python and TypeScript SDKs. These helpers simplify tool creation and execution by providing input validation with type safety and an automated tool executor that manages the tool-use loop in conversations.
- ◆2026-02 — The Claude Code SDK was rebranded as the Claude Agent SDK. It provides access to the same core tools, context management systems, and permissions frameworks that power Claude Code. SDK support for subagents and hooks was also released.
This is the short version
The full chapter has three worked examples, the common pitfalls, and the workflow that makes it pay — plus the other 84 features, kept current.
Get Claude Master — $97 →