Claude API gives you direct access to Anthropic's models. This guide covers everything from signup to production patterns.
Step 1 — Sign Up
console.anthropic.com → Sign Up. Email + password.
Step 2 — Add Credit
Billing → add $5 minimum. Card payment.
Step 3 — API Key
API Keys → Create Key. Name it (my-app-prod). Store the key in secret manager — it won't be shown again.
Step 4 — First Request
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)
print(response.content[0].text)
Step 5 — Streaming
with client.messages.stream(model="claude-sonnet-4-6", max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Essential for chat UIs.
Step 6 — System Prompt
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a helpful coding assistant.",
messages=[{"role": "user", "content": "..."}]
)
Step 7 — Tool Use
See what is tool calling for full pattern.
Models 2026
- claude-opus-4-7: strongest, $15/$75 per M tokens
- claude-sonnet-4-6: balanced, $3/$15
- claude-haiku-4-5: fast + cheap, $0.80/$4
Rate Limits
Standard tier: 50 RPM. Production tier (after spend $400+): 1000 RPM. Enterprise: custom.
Best Practices
- Don't put the API key in client-side code
- Set max_tokens conservatively to control cost
- Handle 429 (rate limit) with exponential backoff
- Log inputs + outputs for debugging (omit PII)
- Use prompt caching for repeated system prompts
Next Step
Build an agent with tool calling.