← Blog

How to Get a Claude AI API Key (Step-by-Step)

2026-09-04 · 4 min read · SubToAPI Team

If you want to call Claude from your own code, you need an API key — a credential that authenticates your requests to Anthropic's servers instead of a browser session. This guide walks through the exact steps: creating an account, setting up billing, generating the key, and making your first request. It also covers a faster path if you already pay for Claude.ai and don't want to set up a separate billing account.

Two things trip people up most often: confusing your Claude.ai chat login with API access (they're separate systems), and forgetting that the API requires prepaid credit before any request will succeed. Fix those two points and the rest takes about ten minutes.

Step 1: Create an Anthropic Console account

The API key comes from the Anthropic Console, not from claude.ai.

  1. Go to console.anthropic.com
  2. Sign up with an email address (or Google/GitHub SSO)
  3. Verify your email
  4. Complete the organization setup — you'll be asked for a name and sometimes an intended use case

Your claude.ai subscription and your Console account are not linked. Paying for Claude Pro does not give you API credit, and having API credit does not give you Claude Pro. They're billed and provisioned separately.

Step 2: Add billing and prepaid credit

The Anthropic API is pay-as-you-go with no free tier for production use. Before your key will work:

  1. In the Console, go to Settings → Billing
  2. Add a payment method
  3. Purchase credit (minimum purchase amounts apply and vary by region)

Without credit on the account, every API call returns a billing/quota error even if the key itself is valid. This is the single most common reason a "working" key suddenly stops working — the balance ran out.

Step 3: Generate the API key

  1. Go to Settings → API Keys
  2. Click Create Key
  3. Give it a name you'll recognize later (e.g., backend-prod, local-dev)
  4. Copy the key immediately — it starts with sk-ant- and is shown only once

Store it in an environment variable, not in source code:

export ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxx

Step 4: Make your first request

Test the key with a minimal 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-opus-4-5",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

A 200 response with a content array means the key works and billing is active. A 401 usually means a bad key; a 400 or credit-related error usually means the account has no balance.

Step 5: Set limits before you ship

Once the key works, go back to Settings → Limits in the Console and set a spend cap. New API accounts have no ceiling by default, and a bug that loops a Claude call in production can burn through credit fast. This step is easy to skip and expensive to skip.

What if you already pay for Claude.ai and don't want a second billing setup?

Some teams already have a Claude.ai subscription and just want programmatic access without managing a separate Anthropic Console account, prepaid credit balance, and spend limits. That's a common enough situation that tools exist specifically for it.

SubToAPI turns an existing Claude subscription into an HTTPS API with its own key (sub_live_...), so you skip the Console setup entirely. Instead of x-api-key, you send:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-5",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

You get streaming responses, tool use, usage metadata per key, and team seats for sharing access without sharing credentials — all from one dashboard. Plans start at €9/month (Solo), with Team at €19/seat and Scale at €49/seat, and there's a free trial at /signup. Full request/response formats are in /docs/messages and /docs/quickstart if you want to see the exact payloads before signing up.

This is worth considering if you're a solo developer testing an idea, or a small team that wants shared API access without every member managing their own Anthropic billing account.

Getting a Claude AI API key: the short version

Either path gets you an HTTPS endpoint you can call from a backend, script, or app. The right choice depends on whether you want direct Anthropic billing and rate limits, or a faster setup layered on top of a subscription you already have.

questions

Is the Claude AI API key the same as my claude.ai login? No. Your claude.ai account handles the chat interface; the API key comes from a separate Anthropic Console account with its own billing. You can have one without the other.

Why does my Claude API key return an error even though it looks correct? The most common cause is an empty billing balance, not a bad key. Check Settings → Billing in the Console — the API requires prepaid credit and returns errors on every request once it runs out.

Can I get a Claude API key without setting up Anthropic billing separately? Yes — services like SubToAPI issue an API key backed by an existing Claude subscription, so you skip the Console billing setup and get a working key right after signup.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →