← Blog

How to Generate API Keys for Claude (2 Ways)

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

How to Generate API Keys for Claude

There are two legitimate ways to get a Claude API key, and which one you need depends on how you're already paying for Claude. If you don't have any Claude access yet, you create an Anthropic Console account, add billing, and generate a key from the dashboard — that's the direct path to the official Anthropic API. If you already pay for a Claude subscription (Pro, Team, or Max) and just want to call Claude from your own code without setting up separate usage-based billing, a service like SubToAPI generates an HTTPS API key (sub_live_...) from your existing Claude access instead.

Both paths give you a bearer token you put in an Authorization header. The difference is billing and account setup, not the shape of the API itself. Below is how to do each one, plus how to manage keys once you have them.

Option 1: Generate a key directly from Anthropic

This is the standard route if you want to pay-as-you-go for API usage separately from any chat subscription.

  1. Create an account at the Anthropic Console (console.anthropic.com).
  2. Add a payment method. The API is billed by token usage, not a flat subscription, so you need a card on file before keys will work in production.
  3. Go to Settings → API Keys and click "Create Key." Give it a descriptive name (e.g., prod-backend, staging-worker) — you'll thank yourself later when you have five keys and need to know which one is live.
  4. Copy the key immediately. Anthropic shows the full key only once. If you lose it, you have to revoke it and generate a new one.
  5. Store it in an environment variable, never in source code:
export ANTHROPIC_API_KEY="sk-ant-..."
  1. Test it 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-3-5-sonnet-latest",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Say hello"}]
  }'

This gives you full access to Anthropic's models, rate limits tied to your usage tier, and billing based on tokens consumed — separate from any Claude.ai subscription you might also be paying for.

Option 2: Generate a key from an existing Claude subscription

A common situation: you (or your team) already pay for Claude through claude.ai and don't want a second, separate usage-based bill just to experiment with the API or wire Claude into an internal tool. SubToAPI turns that existing access into a standard API key without a separate pay-per-token account.

  1. Sign up at /signup and connect the Claude access you already have.
  2. Generate a key from the dashboard. Keys are prefixed sub_live_... so they're easy to identify in logs and secret managers.
  3. Pick a plan — Solo at €9 for individual use, Team at €19/seat if multiple people need their own keys under one account, or Scale at €49/seat for larger usage and team controls. There's a free trial at signup so you can test before committing.
  4. Call the API the same way you'd call any Messages-style endpoint:
const res = 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-3-5-sonnet-latest",
    max_tokens: 200,
    messages: [{ role: "user", content: "Summarize this ticket: ..." }]
  })
});
const data = await res.json();
console.log(data);

This path is faster if your goal is "I already pay for Claude, I just want a real API key to plug into my app," rather than setting up a second billing relationship. It also includes streaming, tool use, usage metadata per key, and seat-based keys for teams — see /docs for the full reference, /docs/quickstart to get your first request working, /docs/messages for the request format, /docs/streaming for SSE responses, and /docs/tools for function-calling.

Managing keys once you have them

Regardless of which path you took, treat API keys like passwords:

Checklist before going to production

questions

Do I need a credit card to generate a Claude API key? If you're going through Anthropic's Console directly, yes — API usage is billed by tokens, so a payment method is required before a key becomes active. If you're generating a key through SubToAPI from an existing Claude subscription, you're on a flat per-seat plan instead, starting at €9/month on Solo, with a free trial at /signup.

Can I use my Claude.ai (Pro/Team) subscription to call the API directly? Not out of the box — Anthropic's chat subscription and its pay-as-you-go API are separate products with separate billing. A service like SubToAPI bridges that gap by generating an API key from your existing subscription access.

How many API keys should I create? At minimum, one per environment (dev, staging, production) and one per teammate or service that needs independent access. This limits the blast radius if a key is ever leaked and makes usage tracking per key or per seat much easier to audit.

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 →