OverviewMembers

Claude API Python SDK guide

Claude API for Python is the Python section of Anthropic's claude-api skill, written for developers calling Claude from Python code. It covers pip install anthropic, sync and async clients that pick up credentials from the environment, per-request overrides with with_options, and the basic messages.create call with system prompts.

What it does

The client resolves ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or an ant auth login profile. with_options changes timeout or max_retries for one call without changing the client.

How to use it

Claude Code reads this file when a Python task uses the Anthropic SDK, so its code follows the patterns shown here.

Requirements and limits

It advises against hardcoding a key; pass api_key explicitly only when a specific key must be injected.

More in Overviews and the Claude Code library.

What it covers

  • Installation
  • Client Initialization
  • Client Configuration
  • Per-request overrides
  • Timeouts
  • Retries
  • Async performance aiohttp backend
  • Custom HTTP client proxy, base URL
  • Logging
  • Basic Message Request

The full text is in the members library

Book a call and we will give you access to the full Claude Code library: every entry in full, search by meaning, copy and download.

Source and license

Source: https://github.com/anthropics/skills/blob/main/skills/claude-api/python/claude-api/README.md

Author: anthropics, Anthropic skills. License: Apache-2.0.

Related entries