Step 1: Create an Anthropic account
Go to console.anthropic.comand sign up. You'll need a valid email address. Anthropic offers $5 in free credits for new accounts, which is enough for thousands of API calls with their smaller models.
Once you've verified your email and logged in, you'll land on the Anthropic Console dashboard.
Step 2: Generate your API key
- In the Console, navigate to Settings → API Keys.
- Click Create Key. Give it a descriptive name (e.g., “my-app-dev”).
- Copy the key immediately — Anthropic won't show it again. It starts with
sk-ant-.
Store it safely. Use an environment variable, never commit it to source control. In your terminal:
Step 3: Install the SDK
Anthropic maintains official SDKs for Python and TypeScript. Both use the same API under the hood.
Step 4: Make your first API call
Here's a minimal working example in each language. The SDK reads your ANTHROPIC_API_KEY environment variable automatically.
Claude API pricing
Anthropic charges per million tokens (MTok) for both input and output. Output tokens typically cost 3–5x more than input tokens. Here's what's currently available:
| Model | Avg Score | $/in | $/out | Context |
|---|---|---|---|---|
| Claude Sonnet 4.6 | 4.69 | $3.00 | $15.00 | 1M |
| Claude Opus 4.6 | 4.62 | $5.00 | $25.00 | 1M |
| Claude Opus 4.7 | 4.46 | $5.00 | $25.00 | 1M |
| Claude Haiku 4.5 | 4.00 | $1.00 | $5.00 | 200K |
Common gotchas
- Rate limits. New accounts start with lower rate limits (typically 50 requests/minute). You can request increases through the Console as your usage grows.
- Key rotation. Rotate your API keys periodically. You can have multiple active keys — create a new one before revoking the old one to avoid downtime.
- Environment variables. Never hardcode your key. Use
.envfiles locally and your platform's secret management in production (Vercel, Railway, etc.). - Billing alerts. Set a monthly spending limit in the Console under Settings → Plans & Billing. Anthropic will pause your API access rather than surprise you with a large bill.
- Model versions. Use dated model IDs (e.g.,
claude-sonnet-4-20250514) in production for reproducibility. The aliasclaude-sonnet-4-latestis fine for development.
Which Claude model should you use?
Right now, Claude Sonnet 4.6 is Anthropic's top-performing model on our benchmarks (4.69/5.0). For cost-sensitive workloads, look at the cheaper models in the table above — the quality-to-price ratio varies significantly across the lineup.
Not sure if Claude is the right choice for your use case? See how it compares to every other model on our pricing page, or ask our model recommendation chatbot what's best for your specific workload.