- What this covers and what it does not
- Prerequisites
- Step 1: Create a Console account
- Step 2: Set up billing and understand usage-based pricing
- Step 3: Create an API key and copy it once
- Step 4: Make your first Messages API call
- Step 5: Check usage in the Console
- Key safety
- Troubleshooting
- A suspended consumer Claude account is a separate case
What this covers and what it does not
This guide covers creating an Anthropic API key in the Claude Console, making a first Messages API call, checking usage and handling common errors.
It does not cover consumer Claude plans. Signing in to Claude with a consumer plan does not give you an API key. API access is billed separately through the Console. Plan details are on Claude's pricing page.
Prerequisites
- An email address you can access and a payment method for API usage (see step 2)
- A terminal with
curlinstalled - A secure place for the key, such as a password manager or secrets manager
- Permission to create keys in your organization. If the Create key button is disabled, your role may not allow it; ask an organization admin.
Step 1: Create a Console account
Go to platform.claude.com, then sign up or sign in. The API overview lists a Claude Console account as the first requirement for the API.
Step 2: Set up billing and understand usage-based pricing
API requests are billed by tokens at per-model rates. The pricing page lists rates in USD per million tokens (MTok) for each model. This guide does not repeat the figures because they change; check the page before you plan a project.
In the Console, open the Billing page to buy credits or manage payment methods. Major credit cards are accepted for standard accounts.
Each usage tier has a monthly spend cap. You can set your own lower limit on the Spend limits page. The rate limits reference explains how spend caps and request rate limits differ.
Step 3: Create an API key and copy it once
- Open the API keys page in the Console.
- Click Create key, name it, choose an expiration, and set Linked account to yourself or a service account. You can also select a workspace.
- Copy the key immediately. The Console shows the full key, which starts with
sk-ant-, only once. If you lose it, you cannot view it again; create a new key instead.
Use a personal key for your own development. Use a service account key for anything shared, such as a CI pipeline or a production service. Store the key in a secrets manager. Do not save it in a project file.
Step 4: Make your first Messages API call
Set the key in your shell session, never inside a script or file. Then run this request:
# Set ANTHROPIC_API_KEY in this shell first, for example from your secrets manager.
# Never paste the key itself into a file, script or chat.
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1000,
"messages": [
{
"role": "user",
"content": "Say hello in one sentence."
}
]
}'
The model ID comes from the official getting-started example. Model IDs change, so replace it with one listed in the Console or on the official models documentation before you rely on it. A successful response is JSON with an id beginning with msg_ and a content array containing the text.
Step 5: Check usage in the Console
Usage tracking is available in the Claude Console. After your test call, open the usage views and confirm that the request appears under the expected workspace. Also check your Spend limits and Billing pages. The exact menu location of the usage views is UNKNOWN in the sources checked, so look for usage in the Console navigation.
Key safety
- Never commit a key. Do not put it in Git, a ticket, a chat, a screenshot or source code. Load it from an environment variable or a secrets manager.
- Rotate an exposed key. Create a new key, update your applications, then remove the old key on the API keys page.
- Use one key per project or service. Separate keys let you rotate one without breaking the others. For shared workloads, use a service account key.
- Keep keys in the browser out. Browser-based requests can return a 401 for organizations that restrict direct browser calls. Send API requests from your own back end.
Troubleshooting
The official Claude API errors reference is the source of truth for error types. Check the status code and error type in the response first.
| Status | Error type | What to check |
|---|---|---|
| 401 | authentication_error | The key may be malformed, revoked or expired. Run echo "${#ANTHROPIC_API_KEY}" to see the length only; 0 means the variable is empty in this shell. Create a new key if needed. |
| 402 | billing_error | Check payment details on the Billing page. |
| 403 | permission_error | The key lacks access to the resource. Check organization access and workspace settings. If the key is not scoped to a workspace, the authentication docs describe the anthropic-workspace-id header. Region as a cause is UNKNOWN in the sources checked. |
| 404 | not_found_error | Check the endpoint path and resource IDs. |
| 429 | rate_limit_error | Either a rate limit or a monthly spend cap. Wait and retry with exponential backoff, honoring retry-after when present. A spend-cap 429 has no retry-after and keeps failing until access resumes, so check the Spend limits page. |
| 500 | api_error | Retry with exponential backoff. If it persists, contact support with the request ID. |
| 504 | timeout_error | For long Messages API requests, use streaming. |
| 529 | overloaded_error | The API is temporarily overloaded across traffic. Retry later with backoff. |
The official SDKs retry some transient failures automatically, twice by default. The rate limits reference explains how limits are enforced over time.
A suspended consumer Claude account is a separate case
A suspended or restricted consumer Claude account is handled separately from an API key. Creating an API key does not change the status of a consumer account. Follow the official Claude help article on safeguards warnings and appeals and the instructions in your notice. Cue cannot restore or bypass vendor accounts, and cannot promise any review outcome. For Cue's guide to this case, see Cue's Claude suspension guide.
One desktop AI assistant for everyday work. Use Cue to organize notes, documents and tasks, with Claude and GPT model options. Check your Cue account for available models and allowances, and read Cue's terms. Cue cannot issue Anthropic API keys or change Anthropic's account, billing or key decisions.
Dealing with a suspended Claude account? See Cue's Claude suspension guide.