How to Create a Claude API Key in 5 Minutes
How to Create a Claude API Key
There are two ways to create a Claude API key, and which one you need depends on whether you already have a Claude Pro/Max subscription or you're starting fresh with a pay-as-you-go Anthropic Console account.
If you don't have Claude yet: sign up at the Anthropic Console, add billing details, and generate a key from the API Keys page. If you already pay for Claude Pro or Max but don't want a second, separate billing account, you can turn that subscription into an API key through a service like SubToAPI instead of opening a new console account. Both paths get you a working key — the rest of this guide walks through both.
Method 1: Create a Key in the Anthropic Console
This is the standard route if you're building a new project and don't mind a separate usage-based bill.
- Go to the Anthropic Console and create an account (or sign in).
- Add a payment method under Billing — API access is prepaid/usage-based and won't work without one.
- Navigate to API Keys in the left sidebar.
- Click Create Key, give it a descriptive name (e.g.
prod-backend,local-dev), and save it somewhere secure — it's only shown once. - Set an optional spending limit if you want a hard cap on usage.
Once you have the key, 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-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, Claude"}]
}'
This works well if you're comfortable managing a separate billing relationship, tracking token-based costs, and rotating keys manually across a team.
Method 2: Create a Key From Your Claude Subscription
Many developers already pay for Claude Pro or Max and would rather not open a second account just to get programmatic access. This is where SubToAPI fits in — it turns your existing Claude subscription into an HTTPS API with its own key, without asking you to manage a separate Anthropic billing account.
The setup looks like this:
- Create a SubToAPI account and start the free trial at /signup.
- Connect your existing Claude access.
- Generate an application key from your dashboard — it will look like
sub_live_.... - Send requests to
https://api.subtoapi.app/v1/messagesusing that key.
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": 1024,
"messages": [{"role": "user", "content": "Hello, Claude"}]
}'
The request/response shape matches what you'd expect from a Claude Messages API, including streaming and tool use, so you're not learning a new interface — just a different way of authenticating and billing. See /docs/quickstart and /docs/messages for the full request format.
This route makes sense if you want:
- A single key per application instead of sharing one raw account credential across services
- Team seats and shared usage visibility without giving every developer console access
- To avoid setting up a second, usage-metered billing account just to prototype
Plans start at €9/month for Solo use, with Team (€19/seat) and Scale (€49/seat) tiers for shared projects — see /pricing for details.
Which Method Should You Use?
| Situation | Recommended path | |---|---| | No Claude subscription yet, want pay-per-token pricing | Anthropic Console | | Already have Claude Pro/Max, want an API key without new billing | SubToAPI | | Need multiple app-specific keys under one account | Either — both support key management | | Building a team product with shared usage tracking | SubToAPI (seat-based plans, team dashboard) | | Need enterprise contracts, custom rate limits, SLAs | Anthropic Console (direct relationship) |
Securing Your Key After Creation
Regardless of where you generate it, treat the key like a password:
- Store it in environment variables or a secrets manager, never hardcoded in source
- Add
.envfiles to.gitignorebefore your first commit - Use separate keys for development, staging, and production so you can revoke one without breaking the others
- Rotate keys periodically, especially after a team member leaves or a key is accidentally exposed in logs
A leaked key is the most common way API costs spiral unexpectedly — a few minutes of key hygiene up front saves debugging a surprise bill later.
Testing Your New Key
Once you've created a key, run a minimal request before wiring it into your application:
const response = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"content-type": "application/json"
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens": 256,
messages: [{ role: "user", content: "Say hi in one sentence." }]
})
});
const data = await response.json();
console.log(data);
If you get a valid JSON response with a content array, your key is active and correctly scoped. If not, double-check the header name, that the key hasn't expired, and that billing is set up on the account behind it.
Questions
Do I need a credit card to create a Claude API key? For the Anthropic Console, yes — API access is usage-based and requires a payment method before keys become active. If you go through SubToAPI, you sign up and start a free trial first, then choose a plan.
Can I create more than one API key per account? Yes, in both the Anthropic Console and SubToAPI you can generate multiple keys — useful for separating dev, staging, and production, or giving each application its own key so you can revoke access individually.
What's the difference between an API key and a Claude subscription login? A subscription login (Claude Pro/Max) is for using Claude's chat interface. An API key is a separate credential for programmatic access from your own code, with its own authentication headers, usage tracking, and — in the Console's case — separate billing.