To get a Claude API key, open Claude Console API keys, sign in or create an account, and click Create key. Name it, choose an expiration and linked account, select a workspace, then copy the secret. Anthropic's current key guide documents this flow.
API calls draw from your Console API balance, separately from a Claude subscription. Check that balance before testing.
Already have a key? Test it, buy API credits, or diagnose an error.
How to get your Claude API key
The steps below follow Anthropic's creation instructions, checked September 21, 2026. “Claude API key” and “Anthropic API key” refer to the same direct-provider credential.
- 1Sign in to the Claude Console
Go to the Claude Console and sign in or create an account. API availability depends on your location, so check Anthropic's supported countries and regions if you cannot register.
- 2Create a named key and choose its owner
Open API keys settings, click Create key, and give it a descriptive name, such as
local-development.Set Linked account to yourself for a personal development key. For a shared app, CI pipeline, or production service, use a service account. Ask an organization admin to create that identity if needed. Identity-backed keys stop working when their linked identity loses the applicable access; legacy workspace keys can outlive their creator's membership.
If Create key is disabled, ask your admin to check your role. Buying credits will not fix a permission restriction.
- 3Choose a workspace and expiration
For your first integration, scope the key to a single workspace. This avoids having to send a workspace-selection header with each request.
Choose a lifetime appropriate for the task. Anthropic supports preset and custom expirations, subject to your organization's policy. Expiration is fixed at creation, so changing it later requires a replacement key.
- 4Copy and store the secret
Copy the full key into a secrets manager before closing the creation dialog. The Console shows the secret only once; it starts with
sk-ant-. If you lose it, create a replacement key.
Do not put a long-lived API key in browser code, a public repository, or a screenshot. Anthropic's TypeScript SDK disables browser use by default to avoid exposing secrets. Put the API call behind your server instead.

Buy Claude API credits and configure billing
For most self-serve organizations, Claude API billing uses prepaid credits. Those credits cover API calls, playground use, and Console-billed Claude Code. Creating a key and buying credits are separate tasks.
Buy credits in the correct organization
Sign in with an Admin or Billing role, then:
- Open Console Billing.
- Select Buy credits.
- Enter the amount and confirm the purchase.
- Check the available balance on the same page.
Purchased credits are available immediately. Fund the organization associated with the key. If you belong to several organizations, check which one is selected before purchasing. When its credits run out, API and playground use stop until more are added.
Anthropic provides a small amount of initial credits for new users to test the API. Check your Console balance for your allocation; there is no published universal dollar amount or ongoing free API allowance.
Auto-reload keeps a balance funded, not spending capped
On the Billing page, choose Edit under Auto-reload, enable it, and configure the minimum balance and reload setting shown in the Console. Auto-reload buys credits when the balance falls below your threshold.
That keeps the app funded. To control how much it spends, set a separate monthly spend limit before enabling unattended usage.
Receipts, invoices, and expiration
For receipts, open Settings, then Billing, then Invoice history, and choose Download or View. Each credit purchase generates a receipt, including auto-reloads. Expired grants can appear in that history too, without being new charges.
Purchased API credits expire one year after purchase and are non-refundable. Buy against expected usage. Promotional credits can have their own expiration.
Some organizations arrange monthly postpaid invoicing through Sales. Anthropic's payment guide describes those organizations as receiving a Stripe invoice at calendar-month end.
A Claude subscription is not an API credit balance
Claude Pro and Max subscription access is separate from direct API access. Pro does not include Console API usage. An environment API key causes Claude Code to use API pay-as-you-go billing, even when you are logged in with a Claude subscription.
There are three billing paths you may encounter:
| Balance or billing path | Where to manage it | What it pays for |
|---|---|---|
| Console API credits | Console Billing | API, playground, Console-billed Code |
| Paid Claude plan usage credits | Claude usage settings, per the paid-plan guide | Metered use beyond paid-plan allowances |
| Requesty-managed access | Requesty account | Model usage through Requesty's provider credentials |
Paid-plan usage credits are charged separately from the subscription. They follow their own expiration rules, rather than the Console's one-year rule. With Requesty's BYOK path, your own provider account retains its billing relationship.
Check the credential your tool is sending, then inspect the account that credential bills. A positive balance elsewhere does not fund this API request.
Test your Claude API key
These examples use a workspace-scoped Console key and the active claude-haiku-4-5 model. The prompt asks for a short hello with a 64-token output ceiling. A few dozen tokens at Haiku 4.5's rates of $1 per million input tokens and $5 per million output tokens cost well under a cent.
Set the key in your current terminal session on macOS or Linux:
export ANTHROPIC_API_KEY="your-api-key-here"On Windows PowerShell, use the documented environment-variable form:
$env:ANTHROPIC_API_KEY="your-api-key-here"An .env file alone does not load values into the process. Configure a loader if you choose that approach, and exclude the file from Git.
If you have configured a gateway before, run the cleanup commands in the note below before either SDK test.
With curl installed, run this in a Bash-compatible shell. The Messages API and API overview document the request fields and headers.
curl --include 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": "claude-haiku-4-5",
"max_tokens": 64,
"messages": [
{"role": "user", "content": "Reply with a short hello."}
]
}'--include displays response headers and the body. HTTP 200 with a Messages response containing content and usage indicates success.
The 2023-06-01 value is the API version header. Anthropic also supports API-key authentication through Authorization: Bearer in place of x-api-key. Use one authentication header.
Use Python 3.10 or later, as required by the Python SDK.
pip install anthropicSave this script as test_claude.py:
from anthropic import Anthropic
client = Anthropic()
message = client.messages.create(
model="claude-haiku-4-5",
max_tokens=64,
messages=[{"role": "user", "content": "Reply with a short hello."}],
)
for block in message.content:
if block.type == "text":
print(block.text)
print(message.usage)python test_claude.pyUse a supported Node.js 20 or later release, as required by the TypeScript SDK.
npm install @anthropic-ai/sdkSave this script as test_claude.mjs. It also works in TypeScript; the .mjs file runs without compilation.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const message = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 64,
messages: [{ role: "user", content: "Reply with a short hello." }],
});
for (const block of message.content) {
if (block.type === "text") {
console.log(block.text);
}
}
console.log(message.usage);node test_claude.mjsThe SDKs inherit gateway URLs, bearer tokens, and custom headers from your shell. Clear those settings before testing a direct Console key. In Bash or zsh, run unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL ANTHROPIC_CUSTOM_HEADERS; in PowerShell, run Remove-Item Env:ANTHROPIC_AUTH_TOKEN, Env:ANTHROPIC_BASE_URL, Env:ANTHROPIC_CUSTOM_HEADERS -ErrorAction SilentlyContinue. Sources: the Python client and published JavaScript client.
If your key is not scoped to a workspace
An unscoped identity-linked key requires anthropic-workspace-id on each inference request. Copy the ID from Console workspace settings and set a shell variable:
export ANTHROPIC_WORKSPACE_ID="your-workspace-id-here"In PowerShell:
$env:ANTHROPIC_WORKSPACE_ID="your-workspace-id-here"Add this header to the curl command:
-H "anthropic-workspace-id: $ANTHROPIC_WORKSPACE_ID"For Python, replace the client initialization with:
import os
client = Anthropic(
default_headers={
"anthropic-workspace-id": os.environ["ANTHROPIC_WORKSPACE_ID"]
}
)ANTHROPIC_WORKSPACE_ID is a variable we define for these examples. The SDK does not automatically read it as a workspace setting.
Setting ANTHROPIC_API_KEY makes Claude Code use API billing rather than subscription access. Before returning to subscription-based use, run unset ANTHROPIC_API_KEY on macOS/Linux or Remove-Item Env:ANTHROPIC_API_KEY in PowerShell, then run /status in Claude Code to confirm the authentication path. Our guide to using Claude Code with an API key instead of a subscription covers both paths in detail.
Set spending limits and check your usage tier
A request can fail even with credits available. Your balance, chosen budget, Anthropic's tier cap, and request throughput are separate controls.
Set your own monthly budget
Open Console Billing. Under Spend limits, click Adjust limit, or Set limit if none exists. Your chosen limit cannot exceed your tier's cap.
Choose the amount you are prepared to spend. Adding prepaid credits does not remove this limit, and enabling auto-reload does not replace it.
Current monthly tier caps
Anthropic consolidated its standard usage tiers into Start, Build, and Scale on June 26, 2026. The following monthly spend caps were checked September 21, 2026:
| Usage tier | Standard monthly spend cap, USD |
|---|---|
| Start | $500 |
| Build | $1,000 |
| Scale | $200,000 |
| Custom | No monthly cap; limits arranged with account team |
New organizations may begin in Evaluation, with lower limits while account history is established.
Placement and upgrades depend on usage history and account standing. Buying a particular credit amount does not guarantee a higher tier. To request a higher cap or throughput, use Request rate limit increase on the Rate limits page.
Throughput limits measure requests per minute, input tokens per minute, and output tokens per minute. Short bursts can exhaust capacity even when a minute-wide average looks low. Check your account's effective limits in the Console.

Separate environments with workspaces
Workspaces separate apps, environments, or teams while keeping centralized billing. Use separate keys and workspaces for development and production when you need that separation.
For budget isolation, use a non-default workspace: workspace spend and rate limits can be lower than the organization's, but cannot be set on the Default Workspace. Organization-wide limits still apply. Workspaces share the organization's purchased-credit balance.
Check usage and understand the bill
Open Usage for activity and Cost for charges. Usage data can be filtered or grouped by API key, workspace, and model. Reports typically receive data within five minutes, sometimes longer.
Assume 2,000 uncached input tokens and 1,000 output tokens, with no tools, caching, or other pricing modifiers. At Haiku 4.5's standard rates of $1 input and $5 output per million tokens:
| Component | Calculation | Cost, USD |
|---|---|---|
| Input | 2,000 / 1,000,000 × $1 | $0.002 |
| Output | 1,000 / 1,000,000 × $5 | $0.005 |
| Total | $0.002 + $0.005 | $0.007 |
The Messages API is stateless: later turns must include earlier conversation messages again. That context becomes billable input again, with eligible caching changing the rate. Longer chats therefore increase the input bill even when each new user message is short.
Fix common Claude API key errors
First isolate the direct API call using the curl test above. If it succeeds but an integration fails, investigate that integration's credential and request configuration before buying more credits or replacing a working key.
The table combines Anthropic's API error definitions, authentication rules, spend and rate-limit behavior, and low-credit diagnosis.
| Symptom | Likely constraint | Safe next action |
|---|---|---|
401, invalid x-api-key | Bad copy, disabled, revoked, or expired key | Check for stray whitespace and active status. Replace an expired key. |
| 400, credit balance too low | Unfunded Console organization or unintended API authentication | Check the key's organization in Billing and the tool's authentication path. |
| 400, specified usage limit | Your organization or workspace budget | Raise/remove the chosen cap or wait for reset. A top-up alone is not enough. |
| 400, workspace header required | Unscoped identity-linked key | Send anthropic-workspace-id or create a scoped key. |
| 402, billing error | Payment or billing issue | Read the message and check payment details. |
| 403, permission error | Resource or workspace access | Ask an admin to check the identity's permissions. |
| 404, model or resource not found | Old model ID, wrong endpoint, or inaccessible workspace | Check the current model and workspace. |
429 with retry-after | Throughput or special Claude Code workspace limit | Honor the delay, smooth traffic, and inspect the relevant limits. |
429 with enforced_spend_limit_reached | Tier monthly spend cap | Request a higher cap or wait for next month. Repeated retries do not help. |
| 529, overloaded | Temporary provider overload | Retry with backoff; keep the working key. |
Anthropic's issue tracker records a low-credit 400 response, while its current API reference defines 402 billing errors. Read the message to distinguish a depleted balance from another payment problem.
For a tier-cap 429, error.details.error_code is enforced_spend_limit_reached, and the response sends no retry-after header. Access remains paused until the cap is raised or 00:00 UTC on the first day of the next month. Even automatic SDK retries fail while that cap remains reached.
For support, save the error body and request-id, never the secret. The response organization and workspace headers also help verify which account handled the request.
Rotate keys and finish the setup
Follow Anthropic's key-security guidance: keep secrets out of Git, use secure secret storage, and separate development, testing, and production credentials.
For routine rotation, create a replacement, update your secrets and deployments, verify a successful request, then disable or delete the old credential. Disable is reversible; Delete is permanent, and expired keys cannot be reactivated. If you suspect a leak, disable or delete the compromised key immediately.
Claude API setup complete
0 of 4 done
Use one Requesty key for Claude and other models
Use an Anthropic key for direct Claude API access. When your app needs multiple providers, we offer one Requesty key for Claude and 600+ models in total, with OpenAI-compatible and Anthropic-compatible endpoints.
Set a monthly spend cap for each Requesty API key and track costs by key, model, provider, and user. For multiple apps or environments, label your Requesty keys so you can attribute usage to the right workload.
For Requesty-managed access, you need only a Requesty key. Set REQUESTY_API_KEY, then use this Anthropic-compatible Messages example. Browse Claude and other providers in our model catalog.
macOS/Linux:
export REQUESTY_API_KEY="your-requesty-key-here"Windows PowerShell:
$env:REQUESTY_API_KEY="your-requesty-key-here"Using the Python SDK installed above, save this as test_requesty.py:
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["REQUESTY_API_KEY"],
base_url="https://router.requesty.ai",
)
message = client.messages.create(
model="anthropic/claude-haiku-4-5",
max_tokens=64,
messages=[{"role": "user", "content": "Reply with a short hello."}],
)
for block in message.content:
if block.type == "text":
print(block.text)
print(message.usage)python test_requesty.pyThe Anthropic SDK base URL is https://router.requesty.ai; the SDK appends the Messages path.
Add your Anthropic key once with Bring Your Own Keys to keep using your Console billing. Configure a policy that uses your Anthropic key, set the request's model to policy/your-policy-name, and authenticate with your Requesty key for one endpoint and per-key caps.
For Requesty-managed access, our pay-as-you-go pricing adds 5% to provider token costs, with no seat fees or minimum spend.
Start with one Requesty key, set its monthly cap, and use Claude alongside other providers through the same gateway. Create your Requesty account: it is free to get started, with no credit card required.
Sources
Product details and prices checked September 21, 2026.
- Anthropic: current API key creation and authentication
- Anthropic: API payments, auto-reload, and credit expiration
- Anthropic: current tiers, spend caps, and rate limits
- Anthropic: Haiku 4.5 model and pricing
- Versioned Python client and published JavaScript client
- Requesty: spend limits, BYOK, and pricing
Frequently asked questions
- How do I get a Claude API key?
- Sign in to platform.claude.com, open Settings, then API keys, and select Create key. Name it, choose an expiration and linked account, optionally scope it to a workspace, then copy the secret before closing the creation dialog.
- Is a Claude API key the same as an Anthropic API key?
- Yes. Both names refer to a direct Claude API credential created in the Claude Console. You select the model in your request, subject to your account's access permissions.
- Does Claude Pro or Max include API credits?
- A Claude subscription does not fund direct Console API usage. Subscription access and Console API billing are separate paths, and configuring an API key in Claude Code can switch requests to pay-as-you-go API billing.
- Is a Claude API key free?
- Creating a key is separate from paying for usage. Anthropic provides a small initial allocation of trial credits for new users; check your Console balance for the amount available to your account. Continued API usage is billed separately.
- How do I buy Claude API credits?
- An Admin or Billing user can open Settings, then Billing in the Claude Console, select Buy credits, enter an amount, and confirm. Purchased credits are available immediately in that Console organization.
- Do Claude API credits expire?
- Purchased Console API credits expire one year after purchase, cannot be extended, and are non-refundable. Promotional credits can have different expiration dates, and paid Claude plan usage credits follow separate rules.
- Can I see my Claude API key again after creating it?
- No. The Console shows the full secret only once, and the Admin API cannot retrieve it. If you did not save the secret, create a replacement key.
- SEP '26
Claude Code API Key: Setup Without a Subscription
Use a Claude Code API key instead of Pro or Max. Follow macOS, Linux and Windows setup, verify billing, compare costs and switch back without hidden overrides.
- FEB '26
Label your API keys: the cost-attribution trick most teams miss
Requesty API keys carry arbitrary key-value labels. That one feature unlocks per-team, per-feature, per-customer spend attribution without a single line of instrumentation code. Here's the pattern.
- JUL '26
$1.8k before anyone noticed: how to cap runaway agent spend
Retry storms, agent loops, and stolen keys are the three ways teams lose four figures of LLM budget in a day. A practical setup for hard caps, per key limits, alerts, and loop detection.
