How to Get a Claude API Key: Full Setup Guide
If you want to call Claude programmatically — from a script, a backend service, or a product you're building — you need an API key. There are two practical paths to get one: create an account directly with Anthropic and generate a key in their console, or use a service like SubToAPI that turns the Claude access you already pay for into an API key without a separate Anthropic billing setup. This guide walks through both, plus what to do with the key once you have it.
The short version: go to the Anthropic Console, create an organization, add a payment method, and generate a key from the API Keys page. It takes about five minutes if your card is handy. The rest of this article covers the details, common gotchas, and an alternative for people who don't want to manage a second billing relationship just to get programmatic access.
Option 1: Get a Claude API key from Anthropic directly
This is the standard route if you want full control over billing, rate limits, and organization settings.
- Create an account. Go to console.anthropic.com and sign up with an email address or Google account.
- Set up an organization. Anthropic groups API access under organizations, even for solo developers. You'll be prompted to name one during onboarding.
- Add billing. The API is pay-as-you-go and separate from any Claude.ai subscription. You'll need to add a credit card and typically load a minimum credit balance before you can make live calls.
- Generate a key. Navigate to Settings → API Keys and click Create Key. Give it a descriptive name (e.g.,
prod-backend,local-dev) — this matters once you have more than one key. - Store it securely. The key is shown once. Copy it into a password manager or secrets store immediately; Anthropic will not show it again.
Your key will look something like sk-ant-.... Treat it like a password — anyone with the key can rack up usage on your account.
A basic test call
Once you have a key, verify it works with a simple request:
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-sonnet-4-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
If you get a JSON response with a content array back, your key is active and billing is set up correctly.
Things that trip people up
- No free tier for new accounts in most cases. You usually need to add a payment method and prepay credits before your first real request succeeds — trial messages like "add $5" are common.
- Rate limits start low. New organizations get conservative requests-per-minute and tokens-per-minute limits. These scale up with usage history, not just by asking.
- Billing is separate from Claude.ai Pro. A Claude.ai subscription does not include API access. They're different products with different pricing, even though they use the same underlying models.
- Key scope is organization-wide by default. If you're on a team, anyone with console access to that org can see (not reveal) and revoke keys. Plan your org structure before handing out access.
Option 2: Turn existing Claude access into an API key with SubToAPI
If you already pay for Claude in some form and just want a clean HTTPS API without opening a new Anthropic billing account, managing a credit balance, or waiting for rate limits to ramp up, SubToAPI is built for exactly this. You sign up, generate an application key (sub_live_...), and start making requests immediately.
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
This is worth considering if any of the following apply to you:
- You want one dashboard and one invoice instead of juggling Anthropic console billing separately from everything else.
- You need team seats — multiple developers working under shared access with individual keys, rather than one shared organization-wide secret.
- You want streaming, tool use, and usage metadata available out of the box without building that plumbing yourself.
- You'd rather start building today and sort out formal enterprise billing later, or never.
Setup takes a couple of minutes: create an account, grab a key from the dashboard, and follow the quickstart to make your first call. Plans start at Solo for €9/month, with Team (€19/seat) and Scale (€49/seat) for larger groups — full details on pricing. There's a free trial at signup if you want to test it against your actual use case first.
What to do after you have a key
Regardless of which path you took, the next steps are the same:
- Never commit the key to source control. Use environment variables (
SUBTOAPI_KEY,ANTHROPIC_API_KEY) loaded from a.envfile that's gitignored, or a proper secrets manager in production. - Use separate keys per environment. Dev, staging, and production should each have their own key so you can revoke or rotate one without breaking the others.
- Read the Messages API docs before building anything non-trivial — understanding how
messages,system, andmax_tokensinteract will save you debugging time later. SubToAPI's Messages and Streaming and Tools docs cover the same request shape with extra metadata fields. - Set up basic monitoring early. Even a simple log of status codes and token counts per request will help you spot problems before your users do.
questions
Is a Claude API key the same as a Claude.ai subscription? No. Claude.ai Pro/Max gives you the chat interface; the API key is for programmatic access and is billed separately, whether through Anthropic directly or through a provider like SubToAPI that wraps existing access into an API.
How much does it cost to get started? Through Anthropic, you typically prepay a small credit balance before making live calls, then pay per token used. SubToAPI uses flat monthly plans starting at €9/month with a free trial, which can be simpler if you want predictable costs.
Can I use one API key for multiple apps? Technically yes, but it's not recommended. Create separate keys per app or environment so you can track usage, set limits, and revoke access independently if one key is ever exposed.