---
title: "How to Get a Claude API Key: Console Setup, Billing, and Spend Limits"
description: "Sign up for the Anthropic Console, check your region is supported, add billing, create an API key, and set a spend limit. Includes a key-safety checklist."
url: https://cdnping.org/en/blog/how-to-get-anthropic-api-key
language: en
published: 2026-11-17
category: "Developer tools"
tags: ["Claude","Anthropic API","API key","Console","Getting started"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# How to Get a Claude API Key: Console Setup, Billing, and Spend Limits

You generate a Claude API key in Anthropic's developer console (the Console): sign up and verify your account, create or join an organization, add a payment method and prepaid credit, then create the key. This only works if your region is on Anthropic's supported list. The key is shown once, when you create it, so save it on the spot.

Below, each step in order, with what to watch for. The Console's layout and menus change between releases, so check button names and paths against Anthropic's official docs and what you actually see on screen. This article doesn't hard-code menu paths.

## What should you confirm before getting a Claude API key?

Check three things first. They head off most of the trouble later.

1. **Your region is supported.** Like Claude's other products, the Console is open only to the countries and regions Anthropic lists. The supported-regions list is in the official docs, so check the latest version yourself. In unsupported regions, sign-up, payment, or usage may be rejected.
2. **You follow the usage policy.** The API is covered by Anthropic's usage policy and terms of service, and a use that violates them can get your key disabled. For a Chinese-language walkthrough of the policy, see [Anthropic usage policy explained: what Claude prohibits](/en/blog/anthropic-usage-policy-explained).
3. **API billing and Claude subscriptions are separate.** The Pro and Max plans on claude.ai and your API credit are not interchangeable. If all you want is Claude Code, read [Claude Code: subscription login or API key](/en/blog/claude-code-subscription-or-api-key) before deciding whether you need a key at all.

## The 6 steps from sign-up to API key

1. **Sign up and log in to the Console.** Register with an email address or another method Anthropic supports, and complete the verification it asks for. What is required is whatever the page tells you.
2. **Create or join an organization.** API usage, billing, and member permissions all live under an organization. For personal use, one organization is enough. For a team, an admin invites members.
3. **Add a payment method.** The API runs on prepaid credit or invoiced billing. The exact model, minimum top-up, and accepted payment methods are whatever the official docs and the page show. No amounts are listed here because prices and rules change.
4. **Add credit or confirm your balance.** With no credit, requests return errors about credit or permissions. For a new account's usage tier and rate limits, follow the official docs.
5. **Create the API key.** On the Console's API Keys page, create a new key and give it a name that shows its purpose, such as `laptop-claude-code` or `ci-review-bot`. Copy and save it immediately; the page won't show the full key again.
6. **Set a spend limit and alerts.** Look for usage-limit and budget options in the organization or workspace settings. What you can set, and whether you can split it by workspace, depends on the official docs. As an individual, at least set the monthly cap to a number you can live with.

## How do you check that the key works?

Send a minimal request with curl. Put the key in an environment variable, not in your shell history or in code:

```bash
export ANTHROPIC_API_KEY="your key"

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": "<model name, see the official model list>",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "ping"}]
  }'
```

For the `anthropic-version` header and which model names are available, go by the official docs. The model name is left blank on purpose, because models get updated and retired.

Common responses:

| Symptom | Likely cause | What to check first |
| --- | --- | --- |
| 401 | Key copied incompletely, deleted, or the environment variable didn't take effect | `echo` the variable's length; create a new key |
| 403 | Permission or access denied; may also relate to organization status | Whether the organization is in good standing, the key's workspace permissions; see the official error docs |
| 429 | Rate limit or usage-tier limit hit | Lower your concurrency; read the official limits docs |
| Error message mentions credit or balance | Insufficient balance | Check the balance and billing in the Console |
| Connection timeout | Local network or proxy problem | See below |

For what each error code means, go by the official API docs. If you suspect the problem isn't on your side, compare against [cdnping's Anthropic API status](/en/status/anthropic), which probes the official endpoint from the Cloudflare edge every 5 minutes, or [Is Claude down?](/en/down/claude). If Claude Code reports an authentication error, see [Claude Code auth conflict warning and 401 errors](/en/blog/claude-code-auth-conflict-warning).

## How should you store the key once it exists?

A key is like a card that can be spent directly, and if it leaks, someone else uses your credit. Here is a checklist you can go through line by line:

- Keep the key out of your code repository, private repos included. Use environment variables or a secrets manager.
- One key per purpose, and don't share one key across the whole team. When something goes wrong, you can revoke just that one.
- Put the purpose and the owner in the key's name, so audits are easier.
- Rotate keys regularly, and revoke a person's keys the moment they leave.
- Set a spend limit. Even if a key leaks, the loss has a ceiling.
- Mask the key before you paste commands into chats, screenshots, or tickets.

For team setups, continue with [How to manage API keys across a team: one key per person, budget splits, and rotation](/en/blog/team-shared-api-key-management). If a key has already leaked, the approach matches OpenAI's: revoke first, then check usage, then find where it leaked. See [Your OpenAI API key leaked](/en/blog/openai-api-key-leaked-response); the process carries over as is, except the place you act is the Anthropic Console.

## What if you have no overseas credit card, or your region isn't supported?

This is the problem developers in China run into most, so let's be clear about the boundaries first:

- If your region isn't on Anthropic's supported list, follow the terms of service. Don't try to get around the region restriction, borrow someone else's account, or use multiple accounts. If your account gets restricted, appeal through Anthropic's official support channel.
- If your region is supported and you just lack a usable payment method, see [How to use the Claude API without an overseas credit card: payment options compared](/en/blog/claude-api-without-foreign-credit-card).
- If you only want to write code in tools like Claude Code or Codex, you don't necessarily need your own Console account.

For that last case, AGI Plan is one option. AGI Plan is a commercial partner of cdnping. It is a multi-provider LLM aggregation gateway sold as a monthly subscription, paid in RMB, with no overseas credit card needed. One subscription covers several capability tiers, such as frontier reasoning, balanced general-purpose, Chinese flagship models, and fast lightweight models. Tools like Claude Code and Codex only need one endpoint address changed, and Claude Code doesn't need a Claude account. Note that the service states plainly that it is not an officially authorized channel, and some models are available only outside China; see [agiplan.dev/models](https://agiplan.dev/models) for specifics. Setup steps are at [agiplan.dev/startup](https://agiplan.dev/startup).

It's a different path from an official key. An official Console key suits cases where you need to connect to Anthropic directly, use all of its official features, and have a compliant contracting entity. A gateway suits individual developers who want to pay in RMB and fuss less with accounts. Which one fits depends on your needs, and it isn't either-or. Before choosing, read [Are Claude API relays reliable? Four main risks and self-checks you can run](/en/blog/is-claude-api-relay-safe).

## What to do after you have a key

- To write your first request: [How to use the Claude API: from getting a key to your first request](/en/blog/claude-api-beginner-getting-started).
- To use the key in Claude Code: [Custom API endpoints for Claude Code, Codex, and OpenCode](/en/blog/configure-custom-api-endpoint-claude-code-codex).
- To estimate your monthly spend first: [How to estimate Claude Code token usage](/en/blog/ai-coding-agent-token-cost-estimate).
- If requests keep timing out locally: run [cdnping's online speed test](/en) to measure first-connect time and round trip to each provider's API, then check your proxy settings.

## Summary

The process itself isn't complicated: confirm your region and the policy, create an organization, add billing, create a key, and set a limit. The two places people really get stuck are region plus payment method, and key storage. Set the spend limit before you start writing code.
