Anthropic now keeps everything for the Claude API in the Claude Console at platform.claude.com. Key creation also changed this year: you now pick a key type, a linked account and an expiry before the key is made.
This guide walks you through the whole path. You will sign up, add credits, create a key, store it safely and make your first call in Python and curl.
- Where: sign in at platform.claude.com, then open Settings, API keys (
platform.claude.com/settings/keys). - Cost: the API is prepaid. Buy credits on the Billing page first, or your calls will fail.
- Key types: personal key for you, service account key for shared apps, workspace key is legacy.
- Shown once: the key starts with
sk-ant-and is shown only at creation. Copy it into a secrets manager. - Use it: set
ANTHROPIC_API_KEYand the official SDKs pick it up automatically.
What You Need Before You Start
Getting a key takes about five minutes. You only need a few things ready.
- An email address: to create a Claude Console account (you can also sign in with an existing account).
- A payment card: API usage runs on prepaid credits, so you need to buy some before real calls work.
- A terminal: macOS Terminal, Linux shell or Windows PowerShell, for setting the key and testing it.
- Python 3 (optional): if you want to use the official
anthropicPython SDK.
Note: A Claude.ai chat subscription and the Claude API are billed separately. Paying for Claude Pro does not give you an API key. Anthropic’s help center does say that Max, Ultra and Team plans include monthly API credits, which expire at the end of each billing cycle.
Step 1: Sign Up and Add Credits
The Claude API uses prepaid usage credits. When your balance hits zero, API and playground access stops until you add more. Anthropic’s billing article does not list any free trial credits, so plan to buy a small amount to start.
- Open the Console. Go to platform.claude.com and sign up, or sign in.
- Go to Billing. Open
platform.claude.com/settings/billing. You need the Admin or Billing role in your organization. - Click Buy credits. Enter an amount and confirm. Purchased credits are available right away.
- Turn on auto-reload (optional). In the Credit balance section, set a trigger balance and a target balance. The Console tops you up when you drop below the trigger.
Warning: Credits are non-refundable and expire one year from purchase. Start small, watch your usage, then buy more.
Your credits also cover Claude Code usage billed through the Console. If you only want to test prompts, the Console playground at platform.claude.com/playground uses the same credits.
Which Key Type to Pick
When you click Create key, the Console asks who the key belongs to. This choice decides when the key stops working. Here is how the three types compare, based on Anthropic’s authentication docs.
| Key type | Acts as | Best for | Stops working when |
|---|---|---|---|
| Personal key | You, with your roles | Your own scripts and local development | You lose access to the organization |
| Service account key | A service account | CI pipelines, production apps, shared agents | The service account is archived |
| Workspace key (legacy) | No one, it belongs to the workspace | Older setups only | It expires, is deleted, or the workspace is archived |
Anthropic recommends a personal key for your own tooling and a service account key for anything shared. Both are tied to an identity, so they shut off on their own when that person or account is removed.
Step 2: Create Your Claude API Key
With credits in place, you can create the key itself. Follow these steps in the Console.
- Open the API keys page. Go to
platform.claude.com/settings/keys. - Click Create key. If the button is greyed out, your role cannot create keys. Ask an organization admin.
- Name the key. Use a clear name like “laptop-dev” or “blog-bot-prod” so you know what to revoke later.
- Pick an expiration. Choose 3 hours, 1 day, 7 days, 30 days, a custom length, or Never. You cannot change this later.
- Set the Linked account. Pick yourself for a personal key, or a service account for a shared workload.
- Choose a workspace (optional). Scope the key to one workspace to keep projects and spending apart.
- Copy the key now. The full key starts with
sk-ant-and is shown only once. Paste it into a password manager or secrets manager.
Tip: Lost the key? You cannot view it again, and the Admin API only returns a redacted hint. Just create a new key and delete the old one.
How expiry warnings work
Anthropic emails a warning 7 days before expiry for keys that live at least 14 days. Keys that live at least 7 days get a warning 1 day before. Shorter keys expire with no email, and expired keys cannot be turned back on.
Workspaces: Keep Projects Apart
Workspaces split one organization into separate areas. Anthropic says they are there “to separate environments and control spend by use case.” Every organization starts with a Default Workspace.
- Create them at:
platform.claude.com/settings/workspaces. - Scoped keys: a key made for one workspace only works there, and you do not need to send a workspace ID.
- Unscoped keys: a personal or service account key that is not tied to a workspace must send the
anthropic-workspace-idheader on every request. - Common setup: one workspace for “dev” and one for “prod”, each with its own spend limit.
If you forget the header on an unscoped key, the API returns a 400 invalid_request_error. The fix is shown in the troubleshooting section below.
Step 3: Save the Key as an Environment Variable
Never paste the key straight into your code. The official SDKs and the ant CLI read it from an environment variable named ANTHROPIC_API_KEY.
macOS and Linux
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
That lasts for the current terminal only. To keep it, add the same line to ~/.zshrc (macOS default) or ~/.bashrc (most Linux), then open a new terminal.
Windows PowerShell
# current session only
$env:ANTHROPIC_API_KEY = "sk-ant-api03-your-key-here"
# saved for future sessions (open a new window after)
setx ANTHROPIC_API_KEY "sk-ant-api03-your-key-here"
A .env file for projects
Many projects keep secrets in a .env file loaded by a tool like python-dotenv. If you do this, add .env to your .gitignore before your first commit.
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
Note: For local work, Anthropic’s quickstart now also suggests signing in with the CLI using ant auth login. The SDKs then pick up that login with no key in your environment at all.
Step 4: Make Your First Call (Python and curl)
Time to test the key. Both examples below use Claude Opus 5.5 (claude-opus-5-5), the model in Anthropic’s own quickstart.
Python
- Make a project folder and virtual environment. Run the commands in the first code block.
- Install the SDK.
pip install anthropicpulls in the official package. - Save the script. Paste the second block into
quickstart.py. - Run it. Type
python quickstart.pyand you should see Claude’s reply.
mkdir claude-quickstart && cd claude-quickstart
python3 -m venv .venv && source .venv/bin/activate
pip install anthropic
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1000,
messages=[{"role": "user", "content": "Say hello in five words."}],
)
for block in message.content:
if block.type == "text":
print(block.text)
On Windows, activate the virtual environment with .venv\Scripts\activate instead of the source command. For a deeper walkthrough with streaming and tools, see our Claude API Python tutorial.
curl
Direct HTTP calls send the key as a bearer token. The anthropic-version header is required, and the current version in the docs is 2026-10-21.
curl https://api.anthropic.com/v1/messages \
-H "Authorization: Bearer $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 200,
"messages": [{"role": "user", "content": "Say hello in five words."}]
}'
The older x-api-key header still works as a fallback. If your key is not scoped to a workspace, add -H "anthropic-workspace-id: wrkspc_..." as well.
Tip: Want to test cheaply? Swap the model for claude-haiku-5-5. It costs $0.10 per million input tokens for prompts up to 100K tokens.
Spend Limits, Tiers and Costs
Every organization sits on a usage tier. Each tier sets a monthly spend cap plus rate limits in requests and tokens per minute. Anthropic moves you up automatically based on usage history and account standing.
| Usage tier | Monthly spend cap | Notes |
|---|---|---|
| Evaluation | Below standard limits | Some new organizations start here |
| Start | $500 | Standard entry tier |
| Build | $1,000 | Reached automatically over time |
| Scale | $200,000 | High-volume apps |
| Custom | No cap | Arranged with Anthropic’s account team |
You can check your current limits at platform.claude.com/usage/limits. The Request tier increase button on that page asks for more. Our LLM API rate limits guide compares these tiers with other providers.
Set your own spend limit
The tier cap is Anthropic’s limit. You can set a lower one yourself at platform.claude.com/settings/spend-limits, for the whole organization or per workspace. When usage reaches a limit you set, the API returns a 400 error instead of charging more.
What calls cost
Prices are per million tokens (MTok). These are the current base rates from Anthropic’s pricing page.
| Model | Input / MTok | Output / MTok |
|---|---|---|
| Claude Fable 5.2 | $8 | $40 |
| Claude Opus 5.5 | $4 | $20 |
| Claude Sonnet 5.5 | $2 | $10 |
| Claude Haiku 5.5 (up to 100K prompt) | $0.10 | $0.50 |
The Message Batches API cuts both rates by 50%. For caching, long-context rules and worked examples, read our full Claude API pricing guide. To track what you spend, see Claude API cost tracking in the Console.
Keep Your Key Safe
Anyone who has your key can spend your credits. Anthropic’s authentication docs list a few clear rules.
- Never put keys in browser code: anyone can read a key in a web page’s source. Call the API from your back end.
- Use a secrets manager: store keys in a vault or your host’s secret settings, not in Git.
- Set an expiry: it limits how long a leaked key can be abused. Pick Never only for keys you rotate yourself.
- Rotate on a schedule: create a new key, update your app, then delete the old one.
- Disable fast if leaked: Disable is reversible. Delete is permanent.
- Lock it down: IP allowlisting restricts where a key works. For cloud production, Workload Identity Federation swaps static keys for short-lived tokens.
If you also use OpenAI, the same habits apply there. Our guide to getting an OpenAI API key covers its projects and key settings.
Troubleshooting: Common Problems and Fixes
Most first-call errors come down to the key, the balance or a missing header. Here is what each error means, using Anthropic’s error docs.
| Error | Likely cause | Fix |
|---|---|---|
| 401 authentication_error | Key is wrong, revoked, expired or not loaded | Run echo $ANTHROPIC_API_KEY to check it is set. Create a new key if it expired. |
| 400 invalid_request_error | Bad request body, low credit balance, missing workspace header, or your own spend limit reached | Read the message text. Add credits, add anthropic-workspace-id, or raise your limit. |
| 402 billing_error | Payment details problem | Check your card on the Billing page. |
| 403 permission_error | Key cannot use that resource | Check workspace access and your role. |
| 404 not_found_error | Wrong endpoint, model ID or workspace ID | Copy the model ID exactly, for example claude-opus-5-5. |
| 429 rate_limit_error | Rate limit or tier spend cap hit | Retry with backoff. A spend-cap 429 has no retry-after header. |
| 529 overloaded_error | API busy for everyone | Wait and retry. The SDK retries twice by default. |
More quick fixes
- “Create key” is greyed out: your role cannot make keys. Ask an admin to change your role or create a service account key.
- Works in terminal, fails in your IDE: the IDE started before you set the variable. Restart it, or open a new terminal after
setx. - CORS error in the browser: you are calling the API from front-end code. Move the call to a server.
- Key worked yesterday, not today: check its expiry on the API keys page. Expired keys cannot be re-enabled.
For a deeper dive on rate limit and overload errors, see our Claude API 429 and 529 fix guide.
Frequently Asked Questions
Is the Claude API key free?
Creating a key is free, but calls use prepaid credits. Anthropic’s billing article does not mention free trial credits, so you need to buy credits before you can make real requests.
Does Claude Pro include API access?
No. Claude Pro covers the Claude apps only. Anthropic says Max, Ultra and Team plans include monthly API credits, which are used before purchased credits and expire each billing cycle.
Where do I find my Claude API key again?
You cannot. The full key is shown only once when you create it. Create a new key at platform.claude.com/settings/keys and delete the old one.
What does a Claude API key look like?
It starts with sk-ant-. Regular API keys follow the pattern sk-ant-api..., while Admin API keys start with sk-ant-admin.
Can I change a key’s expiration date?
No. Expiration is set when you create the key and cannot be changed later. Make a new key with the expiry you want.
Do I need a workspace ID?
Only if your key is not scoped to a workspace. In that case, send the anthropic-workspace-id header on every request, or set it once as a default header in the SDK.
Do Claude API credits expire?
Yes. Purchased credits expire one year from the purchase date, and that date cannot be extended. Credit purchases are also non-refundable.



