| name | clade-sdk-patterns |
| description | Production-ready Anthropic SDK patterns — client config, retries, timeouts,
Use when working with sdk-patterns patterns.
error handling, TypeScript types, and async patterns.
Trigger with "anthropic sdk", "claude client setup", "anthropic typescript",
"anthropic python patterns".
|
| allowed-tools | Read, Write, Edit |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","anthropic","claude","sdk","typescript","python"] |
| compatibility | Designed for Claude Code |
Anthropic SDK Patterns
Overview
Production patterns for the @claude-ai/sdk (TypeScript) and anthropic (Python) SDKs.
Client Configuration
Instructions
Step 1: TypeScript
import Anthropic from '@claude-ai/sdk';
const client = new Anthropic();
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
maxRetries: 3,
timeout: 60_000,
baseURL: 'https://api.anthropic.com',
defaultHeaders: {
'claude-beta': 'prompt-caching-2024-07-31',
},
});
Step 2: Python
import anthropic
client = anthropic.Anthropic()
client = anthropic.AsyncAnthropic()
client = anthropic.Anthropic(
api_key=os.environ["ANTHROPIC_API_KEY"],
max_retries=3,
timeout=60.0,
base_url="https://api.anthropic.com",
default_headers={"claude-beta": "prompt-caching-2024-07-31"},
)