Claude API Python — Anthropic Messages API Integration
How to use the Claude API with Python or curl via the Anthropic Messages format. Set base URL and API key to access Claude Sonnet 4.6, Opus 4.8, and Fable 5 through APIMaster.ai at discounted pricing.
Claude Messages
For the Anthropic SDK or tools that call the Messages API, use:
- Base URL:
https://apimaster.ai(site root, no/v1; OpenAI useshttps://apimaster.ai/v1) - API key: your APIMaster token
Example:
curl -s "https://apimaster.ai/messages" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}]
}'
Some clients send Authorization: Bearer instead of x-api-key. If one returns 401, try the other.
Claude Code / Desktop
- Open API Provider / Custom API in settings.
- API URL:
https://apimaster.ai(no/v1) - API Key: APIMaster console token.
- Model: e.g.
claude-sonnet-4-6(list).
See Claude Code for CLI env vars.