← Blog

How to Get a Claude API Key: Full Setup Guide

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

If you want to call Claude programmatically — from a script, a backend service, or a product you're building — you need an API key. There are two practical paths to get one: create an account directly with Anthropic and generate a key in their console, or use a service like SubToAPI that turns the Claude access you already pay for into an API key without a separate Anthropic billing setup. This guide walks through both, plus what to do with the key once you have it.

The short version: go to the Anthropic Console, create an organization, add a payment method, and generate a key from the API Keys page. It takes about five minutes if your card is handy. The rest of this article covers the details, common gotchas, and an alternative for people who don't want to manage a second billing relationship just to get programmatic access.

Option 1: Get a Claude API key from Anthropic directly

This is the standard route if you want full control over billing, rate limits, and organization settings.

  1. Create an account. Go to console.anthropic.com and sign up with an email address or Google account.
  2. Set up an organization. Anthropic groups API access under organizations, even for solo developers. You'll be prompted to name one during onboarding.
  3. Add billing. The API is pay-as-you-go and separate from any Claude.ai subscription. You'll need to add a credit card and typically load a minimum credit balance before you can make live calls.
  4. Generate a key. Navigate to Settings → API Keys and click Create Key. Give it a descriptive name (e.g., prod-backend, local-dev) — this matters once you have more than one key.
  5. Store it securely. The key is shown once. Copy it into a password manager or secrets store immediately; Anthropic will not show it again.

Your key will look something like sk-ant-.... Treat it like a password — anyone with the key can rack up usage on your account.

A basic test call

Once you have a key, verify it works 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-sonnet-4-5",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

If you get a JSON response with a content array back, your key is active and billing is set up correctly.

Things that trip people up

Option 2: Turn existing Claude access into an API key with SubToAPI

If you already pay for Claude in some form and just want a clean HTTPS API without opening a new Anthropic billing account, managing a credit balance, or waiting for rate limits to ramp up, SubToAPI is built for exactly this. You sign up, generate an application key (sub_live_...), and start making requests immediately.

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

This is worth considering if any of the following apply to you:

Setup takes a couple of minutes: create an account, grab a key from the dashboard, and follow the quickstart to make your first call. Plans start at Solo for €9/month, with Team (€19/seat) and Scale (€49/seat) for larger groups — full details on pricing. There's a free trial at signup if you want to test it against your actual use case first.

What to do after you have a key

Regardless of which path you took, the next steps are the same:

  1. Never commit the key to source control. Use environment variables (SUBTOAPI_KEY, ANTHROPIC_API_KEY) loaded from a .env file that's gitignored, or a proper secrets manager in production.
  2. Use separate keys per environment. Dev, staging, and production should each have their own key so you can revoke or rotate one without breaking the others.
  3. Read the Messages API docs before building anything non-trivial — understanding how messages, system, and max_tokens interact will save you debugging time later. SubToAPI's Messages and Streaming and Tools docs cover the same request shape with extra metadata fields.
  4. Set up basic monitoring early. Even a simple log of status codes and token counts per request will help you spot problems before your users do.

questions

Is a Claude API key the same as a Claude.ai subscription? No. Claude.ai Pro/Max gives you the chat interface; the API key is for programmatic access and is billed separately, whether through Anthropic directly or through a provider like SubToAPI that wraps existing access into an API.

How much does it cost to get started? Through Anthropic, you typically prepay a small credit balance before making live calls, then pay per token used. SubToAPI uses flat monthly plans starting at €9/month with a free trial, which can be simpler if you want predictable costs.

Can I use one API key for multiple apps? Technically yes, but it's not recommended. Create separate keys per app or environment so you can track usage, set limits, and revoke access independently if one key is ever exposed.

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 →