Claude API key

How to get a Claude API key

Create a Claude API key in 5 steps: sign in at platform.claude.com, open settings/keys, click Create key, choose an expiration from 3 hours to never, and copy the key. It starts with sk-ant- and is shown only once. Calls are normally paid from prepaid credits; Claude Pro includes no API usage.

Key prefix
sk-ant-
Shown
Once, at creation
Expiration
3 hours to never
Billing
Prepaid credits

Updated

Create a Claude API key in 5 steps

  1. Sign in to the Claude Console at platform.claude.com, or sign up for a new account if you don't have one yet.
  2. Open the keys page at platform.claude.com/settings/keys.
  3. Click Create key and enter a name for your new Anthropic Console API key.
  4. Pick an expiration (3 hours, 1 day, 7 days, 30 days, a custom duration, or Never), set the linked account to yourself for a personal key or to a service account, and optionally scope the key to a workspace.
  5. Copy the sk-ant- key secret right away and store it somewhere safe, because the Console only shows it once at creation and you can't view it again later.

If the Create key button is greyed out, your role in the organization lacks permission to create keys, so ask an organization admin.

Add credits before your first call

Most organizations pay for API usage with prepaid credits bought on the Console Billing page at platform.claude.com/settings/billing with Buy credits, where you can also turn on auto-reload to top up your balance automatically. Organizations with an invoicing arrangement through Anthropic's sales team are billed monthly instead. The table below outlines how billing and spend tiers work, and you can check per-model token rates for individual model costs.

New organizations, or those with limited history, may start in an Evaluation tier with limits below the standard tiers.

Claude API billing basics
ItemDetail
How you payPrepaid credits on the Console Billing page, or monthly invoicing via sales
Free test creditsA small, unpublished amount for new users
Credit expiry1 year after purchase, non-refundable
Auto-reloadOptional automatic top-up
What is billedSuccessful calls only
Start tier spend cap$500 a month
Build tier spend cap$1,000 a month
Scale tier spend cap$200,000 a month

Does a Claude subscription include API access?

A Claude subscription and Console API usage are paid separately, but Max and Team plans include monthly API credits. The table below shows what each plan includes.

  • You can claim subscriber API credits 7 days after subscribing by linking a Claude Console organization under Settings > Billing on Max (Organization settings > Billing on Team), and they will appear as Promotional credits in the Console.
  • Any claimed subscriber credits expire at the end of each billing cycle (monthly on annual plans), and on Team plans all seat credits are pooled into one monthly balance capped at $500.
  • These promotional credits don't pay for Claude Code, which Pro and Max users run without a key by signing in with /login (see Claude Code pricing and plan details).
Monthly API credits included with Claude plans
PlanPriceMonthly API credits
Free$0None
Pro$20 a monthNone
Max 5x$100 a month$100
Max 20x$200 a month$200
Team Standard$25 a seat a month, or $20 billed yearly$20 a seat, pooled up to $500
Team Premium$125 a seat a month, or $100 billed yearly$100 a seat, pooled up to $500
Enterprise$20 a seat plus usageNone

Make your first API call

Export your key in your shell as ANTHROPIC_API_KEY, and pass it in the x-api-key header (or Authorization: Bearer) when calling POST https://api.anthropic.com/v1/messages. Every request also needs the anthropic-version header, such as anthropic-version: 2023-06-01, alongside content-type: application/json. If your key isn't scoped to a single workspace, also send an anthropic-workspace-id header with the workspace ID from platform.claude.com/settings/workspaces.

Official SDKs exist for Python, TypeScript, C#, Go, Java, PHP and Ruby.

curl
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": "Hello, Claude"}]
  }'

Keep your API key safe

  • Store your key in a secrets manager or an environment variable, and never put it in client-side code or commit it to a git repository.
  • Set an expiration date when you create a key and rotate your keys on a regular schedule; Anthropic emails the key's creator 7 days before expiry for keys that last at least 14 days, and 1 day before for keys that last at least 7 days.
  • Use service account keys for CI, production and agents instead of personal keys, since a personal key acts as you and stops working if you leave the organization.
  • Disable a key right away if you suspect it leaked (which sets its status to inactive and is reversible), or delete it permanently (archived).
  • Remember that an expired key returns 401 authentication_error and cannot be reactivated.
  • In Claude Code, having ANTHROPIC_API_KEY set in your environment overrides a Pro or Max login and bills your Console credits at standard API rates.

Alternative: a key backed by your Claude plan

If you already pay for a Claude Pro or Max subscription and want an API key without separate per-token billing, Plan2API's Claude subscription proxy gives you a p2a_ key backed directly by your plan. Your subscription's own usage limits apply, and you keep paying Anthropic for your plan while Plan2API never bills per token. You can link your account at the Plan2API connect page on the Free plan, which costs $0 with no card required and includes 1 connected subscription, 2 API keys, and 50 chat requests a day.

Requests go to https://api.plan2api.com/v1 using POST /v1/chat/completions in the OpenAI Chat Completions format with an Authorization: Bearer header, and you select a Claude model by using the claude/ or anthropic/ model id prefix. A key sent in an x-api-key header gets 401 invalid_api_key, and there is no Anthropic /v1/messages endpoint, so use the OpenAI SDK as shown below.

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.plan2api.com/v1",
    api_key="p2a_...",
)

reply = client.chat.completions.create(
    model="claude/claude-opus-5-5",
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(reply.choices[0].message.content)

Use the AI subscriptions you already pay for as one OpenAI-compatible API key.

  • Free: 1 subscription, 50 requests a day, no card
  • Pro: $12 a month

FAQ

Is a Claude API key free?

Creating a key in the Console is free, though your API calls are normally paid from prepaid usage credits bought at platform.claude.com/settings/billing. New users do receive a small amount of free Claude API credits to test the API, though Anthropic doesn't publish the exact dollar amount.

Does Claude Pro come with an API key?

No, the Pro plan does not include API usage through the Claude Console. If you are on a Max plan, Max 5x ($100 a month) includes $100 a month in API credits and Max 20x ($200 a month) includes $200 a month.

What does a Claude API key look like?

A Claude API key secret starts with sk-ant-. The Console shows the secret only once, right when you create it.

I lost my Anthropic API key. Can I see it again?

No, the Claude Console never shows the key secret again after creation, and the Admin API never returns it either. You'll need to create a new key at platform.claude.com/settings/keys and delete or disable the old one.

Do I need an API key for Claude Code?

Not if you have a Claude Pro or Max plan, since you can sign in directly with the /login command. Watch out if ANTHROPIC_API_KEY is set in your environment, because Claude Code will use that key and bill API rates instead of your subscription.

Sources

  1. Get your Claude API keyplatform.claude.com
  2. Get started with the Claude APIplatform.claude.com
  3. How do I pay for my Claude API usage?support.claude.com
  4. Claude API rate limitsplatform.claude.com
  5. API credits for Claude subscribersplatform.claude.com
  6. Claude plans and pricingclaude.com
  7. Claude API pricingplatform.claude.com
  8. Claude API authentication and key expirationplatform.claude.com