Claude API keys let your software authenticate requests to Anthropic’s developer API. To create one, sign in to the Claude Console, select the intended organization and workspace, generate a key, and store it securely. This guide explains key creation, usage, workspace selection, billing checks and credential rotation.
If your credentials are valid but Claude Code returns a server-side failure, see our Claude Code 500 error troubleshooting guide.
For configuring that developer credential in the coding agent, see our guide to using Claude Code with an API key.
What is a Claude API key?
A Claude API key authenticates software that sends requests to Anthropic’s Claude API. It associates those requests with an authorized organization and the applicable workspace, billing arrangement, and access permissions. It is not your Claude chat password or a subscription entitlement. The developer Console and the consumer Claude application serve different purposes.
Choose the appropriate authentication method first. Anthropic also documents short-lived credentials for supported workloads, which can be preferable to storing long-lived secrets. This guide focuses on developer keys for direct access to the Claude API.
How to generate a Claude API key
Sign in to the Claude Console at platform.claude.com. Select the organization you are authorized to use and open its API keys area. Choose Create key, give the credential a descriptive name, and choose its scope and expiry from the available options. For a small integration, prefer a key scoped to the intended workspace rather than unnecessarily broad access.
Copy the newly generated secret immediately to your approved secret manager. The Console displays the full value at creation; you cannot recover it later from the key listing. If you lose it, create a replacement and revoke the obsolete credential when appropriate.
The Console’s navigation can change. Anthropic’s current key-creation instructions and API reference, reviewed December 4, 2026, describe the available scope and expiration settings. If key creation is disabled, verify your role or ask the organization administrator. Do not attempt to work around managed restrictions.
Choose the right workspace and key type
A workspace helps separate development, testing and production activity. For example, a team building a support application could give its development service a credential for the development workspace and use a different identity for production. This limits accidental cross-environment use and makes usage easier to attribute.
Anthropic’s API overview explains that a key scoped to one workspace can use that workspace without an additional selection header. A broader organization-scoped developer key requires the request to identify its workspace using the anthropic-workspace-id header. Check the specific key type and API reference before configuring an integration.
Do not confuse a developer key for model requests with an Admin API credential for organizational management. Listing existing key records through administrative operations does not reveal the original secret. Cloud-hosted Claude integrations may instead use the cloud provider’s identity and access controls.
Store and configure your Claude API key
For Python applications using the official Anthropic SDK, ANTHROPIC_API_KEY is the standard environment variable. Configure it through your deployment platform’s secret manager. Keep it out of Git, client-side JavaScript, screenshots and application logs. Do not send the key to a chatbot or paste it into an untrusted service.
On a local machine, the following Python example reads a credential through a hidden prompt and lists model metadata. It uses an authorized workspace-scoped developer key and does not request generated content. Install the official SDK in a virtual environment first.
python -m pip install -U anthropic
from getpass import getpass
from anthropic import Anthropic
key = getpass("Claude API key: ")
client = Anthropic(api_key=key)
models = client.models.list(limit=1)
for model in models.data:
print(model.id)
Save the script and run it locally. A successful model-list response indicates that the selected credential can access that operation. It does not guarantee access to every model or establish that generation is free. The example follows the documented SDK interface; it was not executed against a live Anthropic account. No billable generation was performed.
For an application-side chat interface you can test independently of any hosted model, see our chatbot API example.
How Claude API key usage and costs work
Creating a credential does not include unlimited model usage. API requests are subject to the account’s billing arrangement, model prices and rate limits. Check the Console’s billing and usage information before making generation requests. Consumer subscriptions do not automatically pay for separate developer API usage.
Set an appropriate spending limit where available, review any automatic credit-reload arrangement, and use bounded request sizes and output limits. Track requests by environment and application. A key alone does not constrain how many requests an application makes, so implement application-level quotas and monitoring as well.
For Claude Code, be especially careful to distinguish subscription authentication from developer API billing. A configured API credential can cause requests to use separately billed API access. Inspect the selected authentication method before starting a coding session. Our Claude Code terminal guide covers the normal sign-in and first-session workflow.
Troubleshoot missing or invalid keys
Cannot create a key: Confirm the selected organization, workspace and role. Key creation may be restricted by administrator policy.
Authentication error: Confirm the intended credential is active, not expired or revoked, and is being sent using the correct authentication method. Check for a stale environment variable without printing its value.
Workspace error: Verify the credential’s scope and whether a workspace selection header is required. Check the workspace ID against the Console rather than guessing it.
Usage or rate-limit error: Check billing, service limits, and the requested model. An otherwise valid credential can be unable to perform a particular operation.
When contacting support, share a sanitized error message and request ID, not the secret itself. For broader credential and retention controls, see our generative AI API data security guide.
Rotate or revoke a Claude API key
If a key has been disclosed, revoke it through the authorized Console interface as soon as possible and inspect recent usage. Create a replacement with the necessary scope, update the application’s secret store, and validate the new configuration. For planned rotation, coordinate the replacement and retirement so legitimate applications are not unnecessarily interrupted.
Deleting a credential from a source file does not remove copies in version history or logs. Review the exposure, access permissions and billing records, and escalate suspicious activity through the organization’s incident-response process.
To estimate the charges associated with your API key, read our Claude API pricing guide.
Frequently asked questions
Where do I find my Claude API keys? In the Claude Console’s key-management area for your authorized organization. Existing key records may be listed, but their full secret values are not shown again.
Can I generate a Claude API key from the chat application? Developer keys are created in the Console, not in an ordinary Claude conversation.
Can I use one key for multiple apps? Technically this depends on scope and policy, but dedicated credentials can simplify revocation, attribution and environment separation.
Is a Claude API key free? Creating a key is distinct from using billable API operations. Check your account’s access, credit balance and applicable pricing before using it.
Should I use an API key for every deployment? Not necessarily. For supported production workloads, short-lived identity-based authentication may reduce the need to store a long-lived secret.

