In short
- New accounts include no free credits. The minimum purchase is $5 of prepaid credits, bought by card.
- Keys are created on the API keys page and shown in full only once.
- Every official SDK reads the key from the
ANTHROPIC_API_KEYenvironment variable. - A first call that fails is almost always a 401, a 404, or an empty credit balance.
Getting a key is the least interesting part of building with Claude, which is exactly why it is worth doing properly. Ten careful minutes here save an afternoon of 401 errors later. This walkthrough follows Anthropic’s own quickstart and explains every choice the Console asks you to make along the way.
Before you start
Three facts set the scene. First, the Claude API has no free tier or self-serve trial, and new accounts do not include free credits. Second, the smallest purchase is $5, paid by card, and purchased credits stay valid for one year. Third, the whole process happens in one place: the Anthropic Console, the dashboard at platform.claude.com that Anthropic’s current documentation calls the Claude Console.
You will need an email address, a payment card, and a terminal. That is all.
Step 1: Create an account
Go to platform.claude.com and sign in or create an account. Anthropic’s services are available only in the countries and regions listed on its supported-countries page, and use from an unsupported region is not permitted.
New organizations, and organizations with little usage history, may begin in an Evaluation tier with limits below the published ones. This is an anti-abuse measure rather than a judgement: the limits rise automatically as your organization builds a history.
Step 2: Add credits
In the Console, open Billing and buy at least $5 of credits. The balance is prepaid: usage is deducted from it as you go, and when it reaches zero, API calls stop until you add more. Two settings on the same page deserve a moment.
- Auto-reload buys more credits whenever your balance falls below a threshold you set, which keeps a running project from stopping in the middle of the night.
- Invoice history lists a receipt for every purchase, which is what your accountant will want at the end of the month.
Credits are non-refundable and expire one year from the purchase date, so there is little reason to buy more than a few months of expected use. If you subscribe to the Claude Max, Ultra, or Team plan, it may include monthly API credits that you can claim from the plan’s billing settings instead; those credits expire at the end of each billing cycle.
Step 3: Create the key
Open the API keys page and click Create key. If the dialog first offers other ways to connect, choose Somewhere else or Continue with an API key. You will then set three things:
- Name. Pick something you will recognize in six months, such as
local-devorbilling-service. Every request made with the key is tagged with it on the Usage page. - Expires. Presets run from 3 hours to 30 days, or pick a custom date. You cannot change this later. Choose Never only for keys that live in a secrets manager and are rotated on a schedule.
- Linked account and scope. For a key that only you run, link it to yourself; that makes it a personal key, which stops working if you ever leave the organization. Then pick the workspace it should work in.
Then comes the one moment without an undo. The Console shows the full key exactly once, and it cannot be retrieved afterward. Copy it into a password manager or secrets manager before closing the dialog. If it is lost, the only remedy is a new key.
If the Create key button is missing or greyed out, your role may not allow it, or an organization admin may have disabled key creation for everyone. Ask an admin to change your role, or to issue a service account key for your workload.
Step 4: Set the environment variable
Every official SDK and the ant command-line tool read the key from an environment variable named ANTHROPIC_API_KEY. For the current terminal session:
$ export ANTHROPIC_API_KEY="sk-ant-…"
In PowerShell on Windows, the equivalent is $env:ANTHROPIC_API_KEY = "sk-ant-…". For a project, keep the value in a .env file that your framework loads at start-up, and add that file to .gitignore so it never reaches a repository.
Step 5: Send a request
With Python, the first call takes four lines. Install the SDK, create a client, and send a message to the Messages API.
# pip install anthropic
import anthropic # reads ANTHROPIC_API_KEY from the environment
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1000,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(message.content[0].text)
The same request over plain HTTP shows what the SDK does on your behalf: it sends the key in a header and names the API version.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1000,
"messages": [{ "role": "user", "content": "Hello, Claude" }]
}'
Two headers matter. The key goes in x-api-key, or in Authorization: Bearer; send one or the other, never both. The anthropic-version header pins the API version your code was written against. Current quickstarts use 2026-10-21, and the SDKs set it for you automatically.
What comes back
The response is a JSON object. Its content array holds the model’s reply, stop_reason explains why generation ended (end_turn means the model finished naturally), and usage reports input_tokens and output_tokens. Those two numbers drive the bill. Over time they add up to the totals on the Usage and Cost pages of the Anthropic Console, where you can break them down by key, model, and workspace.
Choosing a model
Anthropic’s guidance for anyone unsure is to start with Claude Opus 5.5 for most workloads. Sonnet 5.5 offers the best combination of speed and intelligence at half the price, and Haiku 5.5 suits high-volume, latency-sensitive tasks such as classification and extraction at a fraction of it again. Fable 5.2 is reserved for demanding reasoning and long-horizon agentic work. The current models all accept a context window of one million tokens.
When the first call fails
| Error | What it means | What to do |
|---|---|---|
| 401 authentication_error | The key is mistyped, expired, or revoked. | Re-copy the key, check its expiration on the API keys page, or create a new one. |
| 404 not_found_error | Usually a misspelled model ID or endpoint. | Compare the model string with Anthropic’s model overview. |
| 400 invalid_request_error | The request body is malformed, or a required header is missing. | Validate the JSON. Keys scoped to the organization must send anthropic-workspace-id. |
| 403 permission_error | The key’s owner lacks the needed role, or the request comes from an IP outside the allowlist. | Ask an organization admin to adjust the role or the allowlist. |
| 402 billing_error | The prepaid balance is empty or payment failed. | Buy credits under Billing, or switch on auto-reload. |
| 429 rate_limit_error | A rate limit, a ramp limit, or the monthly spend cap was reached. | Wait the number of seconds in retry-after, or raise the limit in the Console. |
Error types as listed in Anthropic’s API errors documentation.
What to read next
With a working key in hand, two habits are worth adopting at once: give every key an expiration, and keep one key per project. Both are covered in our guide to API key security. When the first real bill arrives, the walkthrough of Claude API pricing will make it easier to read.
Official sources
- Get your Claude API keyplatform.claude.com
- Developer API keysplatform.claude.com
- Quickstartplatform.claude.com
- Pricing, including the FAQ on free tiers and trialsplatform.claude.com
- API errorsplatform.claude.com
- How do I pay for my Claude API usagesupport.claude.com