← Blog

How to Generate an Anthropic API Key: Step-by-Step

2026-10-02 · 5 min read · SubToAPI Team

Generating an Anthropic API key takes about five minutes: you create an Anthropic Console account, add a payment method, open the API Keys page, and click Create Key. The key starts with sk-ant- and gives you direct HTTPS access to Claude models through the Messages API.

This guide walks through every step, including the parts people usually get stuck on — billing setup, workspace permissions, and testing the key once you have it. It also covers what to do once a single key isn't enough for your team or product.

Step 1: Create an Anthropic account

Go to console.anthropic.com and sign up with an email address or a Google account. If you're setting this up for a company, use a shared or role-based email (like dev@yourcompany.com) rather than a personal one — it makes handing off billing and admin access much easier later.

Step 2: Add a payment method

Anthropic's API is pay-as-you-go. Before you can create a live key, you need to:

  1. Open Settings → Billing in the Console.
  2. Add a credit card.
  3. Optionally set a monthly spend limit so usage can't run away unexpectedly.

Without a payment method attached, you can still create keys, but requests will fail with a billing error the moment you try to use them.

Step 3: Open the API Keys page

In the left sidebar, click API Keys. This page lists every key tied to your organization or workspace, along with when it was created and who created it. If you're part of a team, make sure you're in the correct workspace — Anthropic scopes keys per workspace, not per account.

Step 4: Create the key

Click Create Key, give it a descriptive name (e.g. prod-backend, staging-worker, local-dev), and confirm. Anthropic will show you the full key exactly once:

sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Copy it immediately and store it somewhere safe — a password manager, a secrets manager, or your deployment platform's environment variable settings. If you navigate away without copying it, you'll have to delete the key and generate a new one; Anthropic never shows the full value again.

Step 5: Store the key as an environment variable

Never hardcode the key in source files or commit it to version control. Export it locally for testing:

export ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

And in production, set it through your platform's environment variable or secrets manager (Vercel, Railway, AWS Secrets Manager, Docker secrets, etc.).

Step 6: Test the key with a request

Confirm the key works before wiring it into your app:

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-20250929",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

A 200 response with a content array confirms billing and the key are both active. A 401 means the key is wrong or revoked; a 400 with a billing message means the payment method isn't attached correctly yet.

Step 7: Rotate and revoke keys when needed

Treat API keys like passwords. If a key ever leaks — in a commit, a log file, a client-side bundle — revoke it immediately from the API Keys page and generate a replacement. Good habits:

When a single raw key isn't enough

A single sk-ant- key works fine for a solo script or a prototype. It starts to break down once you have more than one developer, more than one app, or a product you're shipping to customers:

This is the gap SubToAPI fills. Instead of managing raw Anthropic keys by hand, you connect your Claude access once and issue application-level keys (sub_live_...) per project, with usage visible per key, team seats for shared access, and the same streaming, tool use, and messages endpoints you'd expect from Claude directly. Check the quickstart to see how the same curl request above looks when routed through SubToAPI, or review streaming and tool use docs if your app needs those.

Plans start at €9/month for solo use, with Team (€19/seat) and Scale (€49/seat) tiers for shared access — see pricing for details, or sign up and get a free trial to test it against your current setup.

Quick checklist

Questions

Do I need a credit card to generate an Anthropic API key? You can create the key without one, but requests will fail until a valid payment method is attached under Settings → Billing, since the API is billed per token used.

Can I have multiple Anthropic API keys at once? Yes. Anthropic lets you create as many keys as you need per workspace, and giving each environment or service its own key makes revoking access much safer than sharing one key everywhere.

What's the difference between an Anthropic key and a SubToAPI key? An Anthropic key (sk-ant-...) connects directly to Anthropic's billing and infrastructure. A SubToAPI key (sub_live_...) sits on top of your existing Claude access and adds per-application keys, team seats, and usage visibility without changing how you call the Messages API — see the docs for the full request format.

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 →