anthropic
Test your Anthropic API key.
Verify a Claude key, see which Opus / Sonnet / Haiku models it can call, and time the round trip — without burning tokens on a real message.
Stateless proxy — keys never logged, stored, or persisted. What happens to your key →
What this key does
An Anthropic API key authenticates against the Messages API (Opus / Sonnet / Haiku across the Claude 4 line), the streaming endpoint, and the prompt caching feature. The key uses the x-api-key header (not Bearer) and the anthropic-version header is required. Calling /v1/models is the cheapest validation path.
How to get a Anthropic API key
- Sign in at console.anthropic.com.
- Open Settings → API Keys and click Create Key.
- Pick the workspace this key should belong to. Workspaces let you split production from dev.
- Copy the key (shown once) and paste it here to confirm it works.
- Set a per-workspace spend limit before issuing the key to anyone — including yourself.
Common errors and fixes
- 401 Unauthorized: Key is invalid, revoked, or pasted with extra whitespace. Generate a new key from the provider console and try again.
- 403 Forbidden: Key is valid but lacks permission for this resource. Check project / org / workspace scope, or that billing is set up for this key.
- 429 Too Many Requests: You hit the per-minute or per-day rate limit. Wait a moment and retry, or upgrade your tier.
- 404 Not Found: The endpoint or model id changed. Check the provider docs for the current path and model identifier.
- 5xx: The provider is having issues. Check their status page before assuming the bug is yours.
Security best practices
- Store keys in an env var or secret manager — never commit them to a repo, even a private one.
- Restrict scope: prefer per-project or per-deployment keys over a single root key shared across services.
- Rotate on a schedule (90 days is a sane default) and immediately on suspected leak.
- Audit usage in the provider console after rotation to confirm the old key has zero traffic.
- Set per-key spend limits where the provider supports them, so a leaked key has a bounded blast radius.
Pricing at a glance
Anthropic bills per million input/output tokens, with prompt caching giving a 90% discount on cached input tokens. Sonnet is the price/performance pick for most workloads; Haiku is the cheap-and-fast lane; Opus is the heavy-reasoning tier. The Batch API gives a flat 50% off.
FAQ
- What's the difference between an Anthropic API key and a Claude.ai login?
- Different products. Claude.ai is the consumer chat. The API key authenticates against the Anthropic platform and is what you'd use from your code.
- Why does my key need workspaces?
- Workspaces let you set spend caps and rate limits per environment. Production should always be in its own workspace with its own key.
- Does Anthropic have a free tier?
- Anthropic offers small starter credits on signup. They expire. After that it's pay-as-you-go.
- What's the latest Claude model?
- As of early 2026, Claude Opus 4.7 is the flagship; Sonnet 4.6 and Haiku 4.5 cover the price/performance and speed tiers. Always pull /v1/models to see the current set tied to your key.
- How do I enable prompt caching?
- Set cache_control breakpoints in the message content. Cache hits are billed at ~10% of normal input cost.
- Why is my key returning 403 even though it's valid?
- Workspace permission. The key may be valid but tied to a workspace that has no model access enabled. Check the workspace settings.
Test other providers
Related reading
- How to get an Anthropic API keyCreate a Claude API key from the Anthropic console, set workspace limits, and verify it in seconds.
- API key security best practices for LLMsHow to store, scope, rotate, and revoke LLM API keys without leaking them through git, logs, or shared environments.
- OpenAI vs Anthropic pricing in 2026A side-by-side breakdown of OpenAI and Anthropic per-token pricing, batch discounts, and prompt-caching savings.