How to Get an Anthropic API Key: Step-by-Step
Getting an Anthropic API key means creating an account on the Anthropic Console, setting up billing, and generating a key that starts with sk-ant-. That key is what you put in your x-api-key header when calling Claude programmatically instead of using the chat interface.
This guide walks through the exact steps, what to do once you have the key, and a couple of things that trip people up — like billing setup and key management once you have more than one project using Claude.
Step 1: Create an Anthropic Console account
Go to the Anthropic Console (console.anthropic.com) and sign up with an email address or a Google account. This is a separate account system from claude.ai — a Claude Pro or Max subscription does not give you API access or an API key. The console is specifically for developers building on the API.
Verify your email if prompted, then you'll land on the console dashboard.
Step 2: Add a payment method
Unlike claude.ai's flat subscription, the API is pay-as-you-go. Before you can generate a working key, you need to:
- Go to Settings → Billing
- Add a credit card
- Optionally load prepaid credits or set a monthly spend limit
You typically get a small amount of free trial credit on signup, enough to test the API before committing to real spend. Once that's used up, calls will fail until billing is set up.
Step 3: Generate the API key
- Navigate to Settings → API Keys
- Click Create Key
- Give it a descriptive name (e.g.,
prod-backend,local-dev) - Copy the key immediately — it starts with
sk-ant-and is shown only once
If you lose it, you can't retrieve it again — you have to revoke it and generate a new one. Store it in a secrets manager or .env file, never in source control.
Step 4: Make your first API call
With the key in an environment variable, test it with curl:
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-4-1-20250805",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
If you get a JSON response with a content array, the key works. A 401 means the key is wrong or missing; a 403 usually means billing isn't set up yet.
Step 5: Set spend limits and rotate keys
Once the key is live, two things matter for staying safe:
- Spend limits: set a monthly cap in the billing settings so a bug or leaked key doesn't produce a surprise invoice.
- Key rotation: create separate keys per environment (dev, staging, prod) and per team member where possible. If one leaks, you revoke just that one instead of rotating everywhere.
Anthropic's console also shows usage broken down by key, which helps you spot which key is burning through credits if something looks off.
Where this gets harder at scale
A raw Anthropic API key works fine for a single developer hitting the API from one service. It gets messier once you have:
- Multiple team members who each need their own credentials but shouldn't share one root key
- Several apps or environments that need usage tracked separately
- A need for streaming, tool use, and consistent error handling across services without reimplementing the same wrapper code each time
That's the gap SubToAPI fills. Instead of managing raw Anthropic keys per project, you generate sub_live_... application keys from one dashboard, each scoped to its own usage metadata, while the underlying Claude access stays centralized. Streaming and tool use work the same way they would against the Anthropic API directly — see the streaming docs and tool use docs — but you get team seats and per-key usage without building that layer yourself.
Getting started looks similar to the steps above: sign up, grab a key from the dashboard, and send your first request per the quickstart:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-4-1-20250805",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
Plans start at Solo €9 for individual use, with Team (€19/seat) and Scale (€49/seat) tiers for shared usage and higher limits — details on the pricing page. Full request and response formats are in the messages docs.
Common mistakes to avoid
- Using the claude.ai login for API access. They're separate systems. A Pro subscription doesn't unlock the API.
- Hardcoding the key in client-side code. Anthropic API keys should never be exposed in frontend JavaScript — they belong on a server, in an environment variable.
- Forgetting to set a spend cap. A runaway loop or bad retry logic can burn through credits fast without one.
- Sharing one key across a whole team. It makes usage impossible to attribute and means one leak forces everyone to rotate.
questions
Do I need a separate account to get an Anthropic API key if I already pay for Claude Pro? Yes. Claude Pro and Max are consumer subscriptions on claude.ai; the API requires a separate Anthropic Console account with its own billing.
Is the Anthropic API key free to use? New accounts usually get a small amount of free trial credit, but ongoing use is billed per token based on the model you call — it's not a flat free tier.
Can I use one Anthropic API key across multiple projects? Technically yes, but it's not recommended — separate keys per project or environment make usage tracking and revocation much easier if something goes wrong.