Create an API key in the Claude Console: sign in or create an account, open API keys, create a key, and copy it when it appears. Store it securely and use it from your terminal or server—not browser code. You’ll also need available API credits or an invoiced billing arrangement to make a request. (Claude API key guide)
Create your key
- Sign in to the Claude Console, or create an account.
- Open API keys.
- Select Create key, name the key, choose an expiration, and set Linked account to yourself or a service account. You can optionally select a workspace to scope the key to. Anthropic recommends a personal key for your own development and a service-account key for shared workloads.
- Copy and securely save the key immediately. The Console shows the full key only once. If you lose it, create a new one; the old key can’t be viewed again. If Create key is disabled, your role may not allow key creation. Ask an organization admin about changing your role or creating a service-account key for the workload. (Claude API key guide)
Fund API usage
Claude chat subscriptions and Claude Console API usage are billed separately. Eligible Max, Ultra, and Team subscribers can claim monthly API credits by linking a Console organization to their plan; otherwise, most organizations use prepaid credits. An organization with an invoicing arrangement is billed monthly instead. (Billing FAQ)
For the standard prepaid route, Anthropic says a new Console organization must provide additional organization and use-case information, enter payment details, and fund its account. To purchase credits, sign in to the Console with an Admin or Billing role, open Billing, select Buy credits, enter an amount, and confirm. (Getting started with API billing)
Store the key and test it
Keep the key private: don’t put it in frontend JavaScript, commit it to a repository, or include it in logs. Anthropic’s SDKs read ANTHROPIC_API_KEY automatically; direct HTTP requests send the key as a bearer token in the Authorization header. A key beginning with sk-ant- is a format clue, not proof that it is active. (Claude API key guide)
In a macOS or Linux terminal, set the variable for the current session, replacing the placeholder with your real key:
export ANTHROPIC_API_KEY="your-real-key"
Then send a test request to the Messages API. This example uses the API version 2026-10-21 and model claude-opus-5-5. (API versioning)
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": 128,
"messages": [
{"role": "user", "content": "Reply with: API key works."}
]
}'
A successful response is JSON with a content array. Look for a block with "type": "text" to find Claude’s reply. (Messages API guide)
If the request fails
- Authentication error: Check that the key was copied correctly and hasn’t expired or been revoked. Confirm the
Authorization: Bearerheader is present. - Request error: Check the model ID, JSON syntax,
max_tokens, andanthropic-versionheader. - Billing error or no available credits: Check your organization’s balance and billing status in the Console. A valid key alone does not fund API usage. (API overview)
For production, keep secrets on the server or in a secrets manager. Use separate keys for separate environments, and replace a key if it may have been exposed.
Sources
Get your Claude API key — Claude Platform Docs
Authentication — Claude Platform Docs
I created a Claude Console organization — how do I start using the Claude API?
Why is Claude API usage billed separately from my paid Claude plan?
Versions — Claude Platform Docs
