SOP-001: Getting Started with Claude API
FreshSource: Building with the Claude API
Document Control
| Field | Value |
|---|---|
| SOP ID | SOP-001 |
| Version | 1.0 |
| Status | Active |
| Last Updated | 2024-12 |
Overview
This procedure covers setting up the Anthropic Claude API for direct integration.
Prerequisites
- Python 3.8+ installed
- Basic JSON knowledge
- Anthropic API key
Setup Process
Step 1: Get API Key
- Navigate to console.anthropic.com
- Sign up or log in
- Go to API Keys section
- Click Create Key
- Copy and save securely
Security
Never commit API keys to version control. Use environment variables.
Step 2: Install SDK
bash
pip install anthropicOr with specific version:
bash
pip install anthropic==0.39.0Step 3: Configure Environment
Option A: Environment Variable
bash
export ANTHROPIC_API_KEY="sk-ant-api03-..."Option B: .env file
ANTHROPIC_API_KEY=sk-ant-api03-...Step 4: Test API Call
python
import anthropic
client = anthropic.Anthropic() # Uses ANTHROPIC_API_KEY env var
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude!"}
]
)
print(message.content[0].text)Available Models
Verification Checklist
- [ ] API key obtained from console
- [ ] SDK installed successfully
- [ ] Environment variable configured
- [ ] Test call returns response
- [ ] No errors in console
Troubleshooting
| Issue | Solution |
|---|---|
AuthenticationError | Check API key is correct |
RateLimitError | Wait and retry, or upgrade tier |
InvalidRequestError | Check message format |
Connection Error | Check network/firewall |