How to Get a Claude API Key: Step-by-Step Guide
Getting a Claude API key takes about five minutes if you go through Anthropic's Console, but the process has a few steps that trip people up: billing setup, organization roles, and key scoping. This guide walks through the exact steps, then covers what to do once you have the key and a faster alternative if you already pay for Claude through a subscription.
Short answer: create an Anthropic Console account, add a payment method, generate a key under Settings → API Keys, then use it in the x-api-key header of your HTTP requests. If you'd rather not manage billing and rate limits yourself, a service like SubToAPI can generate an API key from your existing Claude subscription instead.
Getting a Claude API Key from Anthropic
- Create an account. Go to the Anthropic Console and sign up with an email or Google account. This is separate from a Claude.ai subscription — they use different billing systems.
- Add billing. The API is pay-as-you-go. You'll need to add a credit card and usually load a small prepaid balance before you can generate a working key.
- Generate the key. Navigate to Settings → API Keys, click Create Key, name it something identifiable (e.g.,
prod-backendorstaging-worker), and copy it immediately — Anthropic only shows the full key once. - Store it securely. Never commit it to source control. Use environment variables or a secrets manager.
A typical key looks like sk-ant-api03-.... Once you have it, a basic request looks like this:
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-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, Claude"}]
}'
Common Setup Mistakes
- Confusing Claude.ai with the API. A Claude.ai Pro or Team subscription does not automatically give you API access. They're billed and provisioned separately.
- Forgetting the
anthropic-versionheader. Requests without it will fail or default to unexpected behavior. - Sharing one key across environments. If your dev, staging, and production environments all use the same key, you lose the ability to see which environment is burning through your usage or causing errors. Create separate keys per environment from the start.
- No rotation plan. If a key leaks (pushed to a public repo, exposed in client-side code), you need to revoke and reissue quickly. Build that into your process before it becomes an emergency.
Organizing Keys for a Team
If more than one person or service needs access, don't just paste the same key into every .env file. Anthropic's Console lets you create multiple keys under one organization, and you should:
- Name keys by purpose, not by person (
billing-service,internal-tool, notjohns-key) - Set spending limits where the Console allows it
- Review the key list periodically and delete anything unused
This becomes harder to manage as a team grows, since Anthropic's own dashboard doesn't give you per-key usage breakdowns or seat-based access control out of the box.
A Faster Path: Turning a Claude Subscription into an API Key
If you already pay for Claude and don't want to set up separate API billing, track usage manually, or manage a pile of environment-specific keys, SubToAPI takes a different approach: it turns your existing Claude access into a proper HTTPS API with its own key format (sub_live_...), a dashboard, and team seats.
The setup looks like this:
- Sign up at /signup and connect your Claude access.
- Generate an application key from the dashboard — it starts with
sub_live_. - Call the API the same way you'd call any REST API:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, Claude"}]
}'
This is useful if you want:
- Streaming responses without building your own SSE handling from scratch — see /docs/streaming
- Tool use support already wired into the request/response format — see /docs/tools
- Per-key usage metadata so you can see exactly which key or team member is generating traffic
- Team seats instead of sharing one key across a whole engineering team
Plans start at €9/month for a Solo seat, €19/seat for Team, and €49/seat for Scale, with a free trial at signup — see /pricing for the full breakdown. Full request and response formats are documented at /docs/messages, and the fastest way to make your first call is the /docs/quickstart guide.
Using the Key Once You Have It
Regardless of which path you take, the pattern for actually using a Claude API key in your code is the same: store it in an environment variable, load it at runtime, and never hardcode it into client-side JavaScript (anyone opening dev tools would see it). A minimal Node.js example:
const response = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-3-5-sonnet-20241022",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude" }],
}),
});
const data = await response.json();
console.log(data);
Swap the endpoint and header for Authorization: Bearer $SUBTOAPI_KEY if you're using SubToAPI instead — the request body format stays the same.
questions
Do I need a credit card to get a Claude API key? Yes, if you're going through Anthropic directly — the API is pay-as-you-go and requires billing setup before a key becomes active. Some third-party wrappers, including SubToAPI, offer a free trial that doesn't require prepaying for usage.
Can I use my Claude.ai subscription to get an API key? Not directly. Claude.ai (the chat interface) and the Claude API are separate products with separate billing. If you want to use your existing subscription as the basis for API access, a service like SubToAPI bridges that gap.
How many API keys should I create? At minimum, one per environment (development, staging, production) so you can track usage and revoke access independently. For teams, create one key per service or purpose rather than sharing a single key across multiple people.