Getting Your API Key
Summary — Key Points of This Lesson
- Issue an API key from Anthropic Console (platform.claude.com). A Console account is required separately from your Claude.ai account.
- API pricing is token-based (USD, excluding tax). Rates vary by model and the number of input/output tokens. Check the latest pricing at the official source.
- Usage follows a tier system. You are automatically promoted to higher tiers based on usage, which relaxes rate limits.
- The standard practice is to store your key in the
ANTHROPIC_API_KEYenvironment variable. Never hard-code it in source code. - The Workspace feature lets you manage keys separately by use case. Always use this for team environments.
目次 (7)
Creating a Console Account
To use the Claude API, you need an Anthropic Console account at platform.claude.com. This is independent of your Claude.ai (chat) account and requires a separate sign-up.
In the Console, you can manage API keys, monitor usage, split workspaces, and use the Workbench — an experimental environment for trying out the API in your browser (source).
Steps to Issue an API Key
- Go to platform.claude.com and sign in
- Open "Settings" → "API Keys" from the left menu
- Click the "Create Key" button and give it a descriptive name
- Copy the displayed key string (
sk-ant-...) and store it somewhere safe
The full key is only shown immediately after creation. It cannot be displayed again afterward, so be sure to copy it right away.
Setting Up the Environment Variable
The SDK reads the ANTHROPIC_API_KEY environment variable by default.
Hard-coding the key in source code risks exposing it through version control, so always use an environment variable or a secrets management tool.
# macOS / Linux — set temporarily in terminal
export ANTHROPIC_API_KEY="sk-ant-..."
# Using a .env file (combined with python-dotenv, etc.)
ANTHROPIC_API_KEY=sk-ant-...
How Billing and Pricing Work
API pricing is token-based (USD, excluding tax). You are charged separately for input tokens and output tokens, and the unit price varies by model. With Prompt Caching, cache reads are processed at just 10% of the normal cost (covered in detail in 5-5).
Always check the latest pricing on the official site (anthropic.com/pricing — USD, excluding tax).
Usage Tiers and Rate Limits
As your API usage grows, you are automatically promoted to higher tiers, which raises the limits on requests per minute (RPM) and tokens per minute (TPM). You can check your current tier and limits under "Settings → Limits" in the Console (source).
Managing Keys Separately with Workspaces
The Console's Workspace feature lets you manage API keys separately by project, team, or environment (development/production). To prevent accidental key reuse and unintended cost aggregation, it is strongly recommended to create a dedicated Workspace for production environments.
Related Article
For setup steps and your first code examples after obtaining an API key, see Getting Started with the Claude API.