Requesty
Back|SEP '26INTEGRATIONS / COST OPTIMIZATION
13 MIN READ|

How to Get a Claude API Key (and Manage Credits and Billing)

Last updated

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.

  1. 1
    Sign 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.

  2. 2
    Create 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.

  3. 3
    Choose 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.

  4. 4
    Copy 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.

A server-side app sends a request with a workspace-scoped API key to the Messages API, and usage is billed to the Claude Console organization's credit balance and monthly limit. A Claude Pro or Max subscription sits apart, with separate billing and no API credits.
The key connects your request to workspace access and organization billing, while Claude subscription billing stays separate. Source: Anthropic authentication, workspace, and payment docs.

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:

  1. Open Console Billing.
  2. Select Buy credits.
  3. Enter the amount and confirm the purchase.
  4. 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.

Note
Are there free Claude API credits?

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 pathWhere to manage itWhat it pays for
Console API creditsConsole BillingAPI, playground, Console-billed Code
Paid Claude plan usage creditsClaude usage settings, per the paid-plan guideMetered use beyond paid-plan allowances
Requesty-managed accessRequesty accountModel 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:

Shell
export ANTHROPIC_API_KEY="your-api-key-here"

On Windows PowerShell, use the documented environment-variable form:

PowerShell
$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.

Shell
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.

Note
Clear old gateway settings before an SDK test

The 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:

Shell
export ANTHROPIC_WORKSPACE_ID="your-workspace-id-here"

In PowerShell:

PowerShell
$env:ANTHROPIC_WORKSPACE_ID="your-workspace-id-here"

Add this header to the curl command:

Shell
-H "anthropic-workspace-id: $ANTHROPIC_WORKSPACE_ID"

For Python, replace the client initialization with:

Python
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.

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 tierStandard monthly spend cap, USD
Start$500
Build$1,000
Scale$200,000
CustomNo 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.

Four checks for an API request: valid credentials, funded organization, available spend allowance, and throughput capacity, with the corresponding authentication, billing, spend-limit, and rate-limit errors.
Check credentials, funding, spend allowance, and throughput to identify what stopped the request. Source: Anthropic authentication, billing, and limits docs.

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:

ComponentCalculationCost, USD
Input2,000 / 1,000,000 × $1$0.002
Output1,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.

SymptomLikely constraintSafe next action
401, invalid x-api-keyBad copy, disabled, revoked, or expired keyCheck for stray whitespace and active status. Replace an expired key.
400, credit balance too lowUnfunded Console organization or unintended API authenticationCheck the key's organization in Billing and the tool's authentication path.
400, specified usage limitYour organization or workspace budgetRaise/remove the chosen cap or wait for reset. A top-up alone is not enough.
400, workspace header requiredUnscoped identity-linked keySend anthropic-workspace-id or create a scoped key.
402, billing errorPayment or billing issueRead the message and check payment details.
403, permission errorResource or workspace accessAsk an admin to check the identity's permissions.
404, model or resource not foundOld model ID, wrong endpoint, or inaccessible workspaceCheck the current model and workspace.
429 with retry-afterThroughput or special Claude Code workspace limitHonor the delay, smooth traffic, and inspect the relevant limits.
429 with enforced_spend_limit_reachedTier monthly spend capRequest a higher cap or wait for next month. Repeated retries do not help.
529, overloadedTemporary provider overloadRetry 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:

Shell
export REQUESTY_API_KEY="your-requesty-key-here"

Windows PowerShell:

PowerShell
$env:REQUESTY_API_KEY="your-requesty-key-here"

Using the Python SDK installed above, save this as test_requesty.py:

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)
Shell
python test_requesty.py

The 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.

Requesty
One credential, explicit budgets

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.

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.
Related reading

Start building with Requesty

One line of code. 600+ models. Full control.

Speak to founders