API keys · Guide
How to get a Claude API key
A Claude API key comes from the Claude Console, and the API runs on prepaid credits: apart from a small test credit for new users, you pay for what you use. Here’s how to create a key, what you pay (including the API credits some Claude plans now include), and how to keep the key safe.
- Billing
- Prepaid credits
- Key starts with
- sk-ant-
- Key shown
- Once
- Bought credits expire
- After 1 year
Steps
Get your key
- Sign in or create an account in the Claude Console (console.anthropic.com now redirects there).
- Open Settings → API keys (direct link) and click Create key.
- Name the key, choose an expiration (from 3 hours to never; it can’t be changed later) and set Linked account to yourself or a service account. You can also scope it to one workspace.
- Copy the key. The Console shows the full key, which starts with
sk-ant-, only once, at creation. - Add credits on the billing page: Claude API usage is billed from prepaid credits.
- Paste the key into the box on this page to check it works and see which Claude models it can use.
Source: Anthropic’s Get an API key documentation.
Test your key
Your key goes from your browser straight to Anthropic, never to this site, and isn’t saved. Checking several keys or providers? Use the API key checker.
Billing
What it costs: prepaid credits
Anthropic’s help centre says: “Claude API and playground usage is billed through prepaid usage credits.” It adds: “If you run out of credits, you can no longer call the API or use the playground until you add more.” Anthropic’s pricing FAQ says new users receive a small amount of free credit to test the API, but its billing articles don’t mention it, so don’t count on it.
- Purchased credits expire one year after purchase and are non-refundable. Auto-reload is available. Anthropic doesn’t document a minimum purchase.
- Claude plans with API credits: Max 5x includes $100 a month and Max 20x $200 a month; Team includes $20 per Standard seat and $100 per Premium seat, pooled and capped at $500. You claim them by linking a Claude Console organisation to your plan (new subscribers can claim after 7 days on the plan); no payment method is needed. They expire at the end of each billing cycle without rolling over, and they don’t cover Claude Code. Free, Pro and Enterprise plans aren’t eligible.
- Usage tiers have monthly spend caps: Start $500, Build $1,000, Scale $200,000, and Custom with no cap. Anthropic places organisations on a tier automatically; new ones may start in an Evaluation tier with lower limits. You can request an increase on the limits page.
- Rate limits are per model class, in requests per minute and input and output tokens per minute. For most models, tokens read from the prompt cache don’t count towards the input limit (tokens written to it do).
- Regions: the API is only available in Anthropic’s supported countries and regions.
Use it
Call the API with your key
Save the key as an environment variable called ANTHROPIC_API_KEY; Anthropic’s SDKs read it automatically. Then send a request with the key and an anthropic-version header:
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1000,
"messages": [
{
"role": "user",
"content": "What should I search for to find the latest developments in renewable energy?"
}
]
}'This is the example from Anthropic’s get-started guide, unchanged. Anthropic’s authentication docs now lead with an Authorization: Bearer header and call x-api-key the legacy form, which is still supported. Personal or service-account keys that can act on more than one workspace must also send anthropic-workspace-id. To use another model, copy its ID from our Claude model IDs list.
Security
Keep your key safe
- Never share a key, including in support tickets.
- Keep keys in environment variables or a secrets manager, and add
.envto.gitignore. - Rotate keys regularly (Anthropic suggests, for example, every 90 days) and use separate keys for development, testing and production.
- Anthropic works with GitHub secret scanning: when a Claude API key is found in a public repository, Anthropic automatically deactivates it and emails you. Create a new key in the Console.
- Watch your usage and set a spend limit in the billing settings.
FAQ
Frequently asked questions
Is the Claude API free?
Not beyond a small test credit. Claude API usage is paid from prepaid credits, and when they run out, requests stop until you add more. Asked “Are there free tiers or trials?”, Anthropic’s pricing FAQ answers only that new users receive a small amount of free credit to test the API. Claude Max and Team plans also include monthly API credits.
Does a Claude Pro or Max subscription include API access?
Max and Team do, as monthly API credits: $100 for Max 5x, $200 for Max 20x, and $20 or $100 per Team seat, capped at $500. Free, Pro and Enterprise plans aren’t eligible. You claim them by linking a Console organisation to your plan (new subscribers after 7 days); they expire at the end of each billing cycle and don’t cover Claude Code.
Can I see my Claude API key again?
No. The Claude Console shows the full key, starting with sk-ant-, only once, when you create it. If you lose it, create a new key and delete or disable the old one. Disabling a key can be undone; deleting it is permanent. A key’s expiration can’t be changed after it’s created.
What does “Your credit balance is too low” mean?
It’s Anthropic’s message when your organisation has no prepaid credit left: “Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.” Buy credits in the Console’s billing page; if you have Max or Team credits, check you’ve claimed them and they haven’t run out this billing cycle.
Why does Anthropic say an anthropic-workspace-id is required?
Personal and service-account keys that aren’t scoped to a single workspace can act on several, so Anthropic needs to know which one each request is for. Send the anthropic-workspace-id header with the workspace ID (it starts with wrkspc_), or create a key scoped to one workspace.
What should I do if my Claude API key leaks?
Disable or delete it in the Claude Console straight away and create a new one. If the key was pushed to a public GitHub repository, Anthropic’s partnership with GitHub means it’s automatically deactivated and you get an email, but leaks elsewhere aren’t caught that way. A spend limit caps the damage.
Related