← ClaudeAtlas

anthropic-pythonlisted

Anthropic Python SDK for Claude API integration. Covers messages API, streaming, tool use, vision, error handling, and best practices. Use when building Python applications that call the Claude API. USE WHEN: user mentions "anthropic", "claude api", "anthropic sdk", "anthropic.Anthropic()", "client.messages.create", "claude-opus", "claude-sonnet", "tool_use", "streaming claude", "claude python" DO NOT USE FOR: OpenAI API, other LLM providers, JavaScript/TypeScript Anthropic SDK
claude-dev-suite/claude-dev-suite · ★ 33 · AI & Automation · score 80
Install: claude install-skill claude-dev-suite/claude-dev-suite
# Anthropic Python SDK ## Installation ```bash pip install anthropic>=0.25.0 ``` ## Basic Usage ```python import anthropic client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from env message = client.messages.create( model="claude-opus-4-6", max_tokens=1024, messages=[ {"role": "user", "content": "Analyze this tag list and identify patterns."} ] ) print(message.content[0].text) ``` ## Model Selection | Model | ID | Best For | |-------|-----|---------| | Claude Opus 4.6 | `claude-opus-4-6` | Complex analysis, expert reasoning | | Claude Sonnet 4.6 | `claude-sonnet-4-6` | Balanced performance/cost | | Claude Haiku 4.5 | `claude-haiku-4-5-20251001` | Fast, lightweight tasks | ## System Prompts ```python message = client.messages.create( model="claude-sonnet-4-6", max_tokens=2048, system="You are an industrial automation expert specializing in DCS engineering.", messages=[ {"role": "user", "content": "Review this motor tag list for ISA-5.1 compliance."} ] ) ``` ## Multi-Turn Conversations ```python def chat(client: anthropic.Anthropic, history: list, user_message: str) -> tuple[str, list]: history.append({"role": "user", "content": user_message}) response = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, messages=history, ) assistant_text = response.content[0].text history.append({"role": "assistant", "content": assistant_text}) return assis