Skip to main content

Claude API Key: How to Get One and Make a First Call

How to get a Claude API key in the Claude Console: create it, buy credits, set ANTHROPIC_API_KEY and make a first call. Per Anthropic's docs, 13 October 2026.

Founder of IImagined.ai

Published
May 8, 2026
Updated
Oct 13, 2026
Reading time
9 min read
Quick answer

Sign in to the Claude Console at platform.claude.com, open Settings then API keys, and click Create key. Name the key, choose an expiration and copy it at once: the Console shows the full value, which starts with sk-ant-, only once. Buy prepaid credits under Billing, export the key as ANTHROPIC_API_KEY and send one request to the Messages API. A Claude Pro subscription does not include API usage.

To get a Claude API key, sign in to the Claude Console at platform.claude.com, open Settings then API keys, and click Create key. The key starts with sk-ant- and is shown only once, so copy it straight into a secrets manager or an environment variable named ANTHROPIC_API_KEY.

This guide follows Anthropic's own pages as read on 13 October 2026: get your API key, authentication, the quickstart, rate limits, API errors and pricing, plus the help centre articles on paying for API usage and API key safety. Prices are US dollars. Older guides send you to a different Console address and promise a fixed free credit; neither matches these pages.

Quick answer: from zero to a first call
  1. 1
    Sign in to the Claude Console

    platform.claude.com. It is a separate product from the Claude chat apps.

  2. 2
    Settings, API keys, Create key

    Name the key, choose an expiration and set the linked account.

  3. 3
    Copy the key once

    It starts with sk-ant- and cannot be viewed again.

  4. 4
    Buy credits

    Settings, Billing, Buy credits. API usage is prepaid.

  5. 5
    Export ANTHROPIC_API_KEY and call the Messages API

    The official SDKs read that variable automatically.

What you need first

You need a Claude Console account and a way to pay. The Console is Anthropic's developer platform: it is where you create keys, add teammates, set up billing and try prompts in a playground. It is not the same as a Claude chat subscription. Anthropic's Pro plan article says Pro does not include API usage through the Console.

There is one overlap. Max and Team plans now include monthly API credits, $100 on Max 5x and $200 on Max 20x, which you claim by linking a Console organization to your plan. If the idea of an API is new, start with API in the glossary.

How to get a Claude API key, step by step

Step 1: Create the key

  1. Go to platform.claude.com and sign in, or create an account.
  2. Open Settings, then API keys.
  3. Click Create key. Name the key, choose an expiration, and set Linked account to yourself or a service account. You can also choose a workspace to scope the key to.
  4. Copy the key and store it somewhere safe. If you lose it you cannot view it again, only create a new one.

If the Create key button is disabled, your role may not allow it. Ask an organization admin to change your role or to create a service account key for you.

Step 2: Buy credits

Claude API usage is billed through prepaid usage credits. In the Console, with an Admin or Billing role, go to Settings, then Billing, click Buy credits, enter an amount and confirm. Credits are available immediately, expire one year after purchase and are non-refundable. You are billed only for successful API calls. Auto-reload, which tops up the balance when it falls below a threshold you set, is optional (help centre).

Step 3: Set the key as an environment variable

# macOS / Linux
export ANTHROPIC_API_KEY="your-api-key-here"

# Windows PowerShell
$env:ANTHROPIC_API_KEY="your-api-key-here"

# Windows CMD
set ANTHROPIC_API_KEY=your-api-key-here

These set the key for the current terminal session. Anthropic's client SDKs read ANTHROPIC_API_KEY automatically, so the key never appears in your code.

Step 4: Make a first call

With curl, straight from the quickstart:

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1000,
    "messages": [
      {
        "role": "user",
        "content": "What should I search for to find the latest developments in renewable energy?"
      }
    ]
  }'

Or in Python, after pip install anthropic:

import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1000,
    messages=[
        {
            "role": "user",
            "content": "What should I search for to find the latest developments in renewable energy?",
        }
    ],
)

for block in message.content:
    if block.type == "text":
        print(block.text)

A JSON reply with a content block and a usage count means the key, billing and model access all work. The quickstart uses claude-opus-5-5; for a cheap test, change the model to claude-haiku-5-5. The TypeScript version installs with npm install @anthropic-ai/sdk. From here, our Claude API tutorial builds a first app.

Which key type to choose

When you create a key you choose its type, which decides what it acts as and when it stops working. Anthropic recommends a personal key for your own development and a service account key for anything shared.

TypeActs asStops working whenUse it for
Personal keyYou, with your roles and permissionsYou leave the organizationYour own development and scripts
Service account keyA service accountThe service account is archivedCI, production services and anything shared
Workspace key (legacy)No one. It belongs to the workspaceIt expires or is deleted, even after its creator leavesExisting integrations only
Admin API keyAn organization adminIt expires or is deletedAutomating key management. It cannot call models

The reason to prefer the first two: they belong to an identity your organization already manages, so a key cannot outlive the person or workload that owns it. A key scoped to one workspace needs nothing extra. A key that works across workspaces must send the anthropic-workspace-id header on every request.

Key expiration

Expiration is set when the key is created and cannot be changed afterwards. Shorter is safer, because it limits how long a leaked key stays usable.

ChoiceGood for
3 hours, 1 day or 7 daysA demo, a test or a contractor
30 daysA project with a known end
Custom durationMatching your own rotation schedule
NeverKeys held in a secrets manager and rotated by you

Anthropic emails the key's creator 7 days before expiry for keys with a lifetime of at least 14 days, and 1 day before for keys with a lifetime of at least 7 days. After expiry, requests return a 401 and the key cannot be reactivated.

Billing, spend limits and tiers

Three controls stand between a bug and a large bill.

  • Your credit balance. When credits run out, API calls stop until you add more, unless auto-reload is on.
  • Your own spend limit. Under Billing, in Spend limits, click Adjust limit and set a monthly figure below your tier's cap.
  • Your tier's spend cap. $500 a month on Start, $1,000 on Build and $200,000 on Scale. New organizations may begin in an Evaluation tier with lower limits that rise automatically as usage history builds.

Rate limits are per organization and per model. On the Start tier, Opus 5.5, Sonnet 5.5 and Haiku 5.5 each allow 1,000 requests, 2,000,000 input tokens and 400,000 output tokens a minute (rate limits). What each call costs is in our Claude API pricing post.

Keep the key safe

From Anthropic's key safety guidance
  • Never share a key. Anyone who needs access should create their own
  • Keep it out of public forums, emails and support tickets, even with Anthropic
  • Load it from an environment variable or a secret manager, never from source code
  • If you use a .env file locally, add it to .gitignore
  • Rotate on a schedule, for example every 90 days
  • Use separate keys for development, testing and production
  • Turn on secret scanning in your source control provider
  • Review usage in the Console and set a spend limit

If a key does leak, act on the API keys page. Disable is reversible and Delete is permanent. There is also a safety net: Anthropic is part of GitHub's secret scanning partner program, so a Claude API key found in a public repository is reported to Anthropic and deactivated automatically (help centre).

Claude Code and API keys

You do not need an API key to use Claude Code on a Claude subscription. If you have both, be careful which one is active.

Source: managing API key environment variables in Claude Code. For teams on Console billing, admins can give a member the Claude Code role, which only allows creating Claude Code API keys. Setup is in how to install Claude Code, and plan prices are in the Claude pricing guide.

Errors you may see

ResponseCauseFix
401 authentication_errorThe key is malformed, revoked or expiredCreate a new key. Expired keys cannot be reactivated
400 invalid_request_errorA key that works in several workspaces sent no workspace header, or you hit a spend limit you setSend anthropic-workspace-id, or raise the limit
402 billing_errorA problem with billing or payment detailsCheck payment details in the Console
403 permission_errorThe key may not use that resourceCheck organization and workspace settings
429 rate_limit_errorA rate limit, or the monthly spend cap of your tierWait for retry-after. A spend-cap 429 has no such header
529 overloaded_errorThe API is temporarily overloadedRetry with backoff

The official SDKs retry rate limits and server errors twice by default, with exponential backoff, and honour the retry-after header. The full list is on Anthropic's errors page.

Using the key in n8n

In n8n the key goes into an Anthropic credential that the Anthropic and Anthropic Chat Model nodes share. Per the n8n docs, create a key in the Console, name it something like n8n-integration, and paste it into the credential's API Key field. Our Claude and n8n guide takes it from there.

What to build next

A working key is the start. Claude tool use lets the model call your functions, and the prompt engineering guide covers writing the instructions. If you also want an OpenAI key, see how to get an OpenAI API key, and Claude vs GPT compares the two APIs. AI SaaS Builder, one of our programs, builds a full product on the Claude API, and the AI automation library lists every related guide.

What changes often

Model IDs in the examples, tier names and caps, and Console labels all change. Anthropic now describes workspace keys as legacy and prefers identity-backed keys, and its plan page marks the monthly API credits on Max and Team as new. The steps are stable; check the linked page for any figure before you rely on it.

Claude API key: FAQ

How do I get a Claude API key?

Sign in to the Claude Console at platform.claude.com, go to Settings, then API keys, and click Create key. Name it, choose an expiration, and set the linked account to yourself or a service account. The Console shows the full key, which starts with sk-ant-, only once, so copy it straight into a secrets manager or an environment variable.

Is the Claude API key free?

Creating a key is free; using it is paid per token from prepaid credits. Anthropic's pricing docs say new users receive a small amount of free credits to test the API, and give no figure. There is no free tier beyond that. The cheapest current model, Claude Haiku 5.5, starts at $0.10 per million input tokens as of 13 October 2026.

Is an Anthropic API key the same as a Claude API key?

Yes. Anthropic's docs describe API keys for the Claude API as also called Anthropic API keys. They are created in the Claude Console, they start with sk-ant-, and the SDKs read them from the ANTHROPIC_API_KEY environment variable.

Does Claude Pro include an API key?

No. Anthropic's help centre says the Pro plan does not include API usage through the Claude Console, which you set up and pay for separately. Max and Team plans are different: they include monthly API credits, $100 on Max 5x and $200 on Max 20x, claimed by linking a Console organization.

Can I see my Claude API key again after creating it?

No. The Console shows the full key only once, at creation. If you lose it, you cannot view it again; create a new key, update your application, and delete the old one. The Admin API cannot recover a lost key either. It returns only a partially redacted hint.

What happens if my Claude API key leaks?

Delete or disable it on the API keys page immediately, then create a replacement. Disable is reversible; Delete is permanent. Anthropic also takes part in GitHub's secret scanning partner program: if a Claude API key is found in a public repository, GitHub notifies Anthropic, the key is deactivated automatically and you receive an email.

Can I use my Claude API key in Claude Code?

Yes, but know the billing effect. If ANTHROPIC_API_KEY is set and you approve it, Claude Code uses that key and charges the work at API rates, even if you are logged in with a Claude subscription. To use your plan instead, keep the variable unset. Run /status inside Claude Code to see which method is active.

Free · no card needed

Start with the free Starter Kit.

A unit economics calculator from AI SaaS Builder, plus four more working files.

Starter Kit5 files · free
See All Access: $99/mo →30-day money-back guarantee