Claude API
How do you authenticate with the Claude API?
QUICK ANSWER
Authenticate with the Claude API by passing your API key in the 'x-api-key' request header. Specify the SDK version header 'anthropic-version' to ensure compatibility.
Direct Curl Request Authentication
curl https://api.anthropic.com/v1/messages -H "x-api-key: your-api-key-here" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'
Verified against: Anthropic API v1