You need an Anthropic API key to use Claude models outside of the claude.ai chat interface. The setup takes about five minutes: create an account on the Anthropic Console, add billing credits, and generate a key. This guide covers each step plus the pricing, rate limits, and gotchas that trip up most developers.
One confusion we see repeatedly: the Claude.ai Pro subscription and the Anthropic API are entirely separate products. Paying $20/month for Claude Pro gives you access to the web chat interface. It does not include API access. The API lives at console.anthropic.com with its own prepaid credit billing. If you have a Claude Pro account, your login works on the Console, but you still need to set up API billing separately.
Step 1: Create Your Anthropic Console Account
Go to console.anthropic.com and click Sign up. You can register with an email address or use Google single sign-on.
Anthropic will ask you to verify your email and phone number. The phone verification is required before you can generate API keys or claim any introductory credits.
Once verified, you land on the Console dashboard. This is where you manage API keys, monitor usage, and control billing.
Step 2: Add Billing Credits
The Anthropic API uses a prepaid credit system. You load funds onto your account, and API calls draw from that balance. Without credits, your key will not process requests.
Navigate to Settings in the Console, then click Plans & Billing. Click Add to credit balance and enter your payment details.
Start with $5. That is enough for thousands of calls to Claude Haiku 4.5 or hundreds of calls to Claude Sonnet 4.6. You can always top up later.
Set a monthly spending limit while you are here. We have worked with developers who left test scripts running overnight and burned through their balance. A spending cap prevents that.
Adding $5 in credit also moves you from the free tier to Tier 1, which jumps your rate limit from 5 requests per minute to 50. This single step eliminates most “API not working” frustrations.
Step 3: Generate Your API Key
Navigate to Settings, then API Keys (or go directly to console.anthropic.com/settings/keys).
Click Create Key. Give it a descriptive name like “Openclaw Agent” or “Dev Testing” so you can identify it later.
Click Create Key and the key appears on screen.
Copy it immediately. Anthropic shows the full key exactly once. After you close this dialog, the key is masked and cannot be retrieved. If you lose it, you need to generate a new one.
Store the key in a password manager, a .env file, or your platform’s secrets manager. Never paste it into code that gets committed to a public repository.
Step 4: Verify Your Key Works
Open a terminal and run this curl command (replace your-key-here with the actual key):
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: your-key-here" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-haiku-4-5-20251001", "max_tokens": 128, "messages": [{"role": "user", "content": "Say hello"}]}'
If you get a JSON response with Claude’s reply, your key is active and billing is working.
A common mistake: Anthropic uses the x-api-key header, not Authorization: Bearer. If you are coming from OpenAI or other providers, this difference will cause a 401 Unauthorized error until you switch to the correct header format. The official SDKs handle this automatically, but raw HTTP calls require x-api-key.
If you see errors, check three things: your credit balance is funded, your key was copied correctly (no trailing whitespace), and you included the anthropic-version header.
What Your API Key Costs in Practice
There is no monthly fee for having an Anthropic API key. You pay per token based on which Claude model you use.
| Model | Input Cost | Output Cost | Best For |
|---|---|---|---|
| Claude Haiku 4.5 | $1 / 1M tokens | $5 / 1M tokens | Fast tasks, high volume, chatbots |
| Claude Sonnet 4.6 | $3 / 1M tokens | $15 / 1M tokens | Balanced speed and intelligence |
| Claude Opus 4.6 | $5 / 1M tokens | $25 / 1M tokens | Complex reasoning, coding, agents |
To put this in concrete terms: 100 short prompts and responses through Haiku 4.5 costs a few cents. The same volume through Sonnet 4.6 runs under $1. For personal projects and prototyping, $5 in credit can last weeks.
All three models support vision (image input) at standard rates. Opus 4.6 and Sonnet 4.6 have 1M token context windows. Haiku 4.5 supports 200K tokens.
Anthropic also offers batch processing at 50% off and prompt caching at 90% off. If you are doing high-volume work, these discounts stack significantly.
What to Do With Your Key Next
Having the key is step one. The value comes from connecting it to something useful.
If you are a developer, install the Anthropic SDK for Python (pip install anthropic) or Node.js (npm install @anthropic-ai/sdk). The SDK reads your key from the ANTHROPIC_API_KEY environment variable automatically:
export ANTHROPIC_API_KEY="your-key-here"
If you want an AI agent that works autonomously, connect your key to Openclaw. Openclaw is a personal AI agent that runs on your machine, connects through Telegram or WhatsApp, and handles tasks proactively. It supports Claude as a model provider through its OAuth setup, so you can use your Anthropic key to power conversations and actions.
We have setup guides for getting Openclaw running with Claude:
- How to Set Up Openclaw: 10-Step Guide covers workspace configuration, memory, and model selection
- Deploy Openclaw on Hostinger VPS for 24/7 uptime without keeping your laptop open
- Multi-Model Configuration if you want to switch between Claude, GPT, and other providers
Your API key is what powers all of this. Paste it into your environment file, select Claude as the model, and the agent handles the rest.
Keeping Your Key Secure
Three rules that prevent most problems:
-
Never commit your key to version control. Add
.envto your.gitignorefile. If you accidentally push a key to GitHub, revoke it immediately at console.anthropic.com/settings/keys and generate a new one. -
Use environment variables, not hardcoded strings. Store the key in a
.envfile and load it at runtime withdotenvor your framework’s equivalent. Every modern language and framework supports this. -
Create separate keys for separate projects. If one key gets compromised, you can revoke it without breaking everything else. Anthropic lets you create as many keys as you need at no cost.
Frequently Asked Questions
Is the Anthropic API key free?
Creating an account and generating a key costs nothing. Using the API costs money on a pay-as-you-go basis. New accounts may receive a small introductory credit for testing, but after that you need to add funds. $5 is enough to get started with most projects.
What is the difference between Claude.ai and the Claude API?
Claude.ai is the web chat interface where you interact with Claude through a browser. The Claude API is a programmatic interface for developers to integrate Claude into their own applications. They have separate billing: Claude.ai Pro costs $20/month for enhanced chat features, while the API uses prepaid credits charged per token. You can use one without the other.
How much does the Anthropic API cost per month?
There is no monthly fee. You pay only for the tokens you use. Claude Haiku 4.5 costs $1 per million input tokens, making it one of the most affordable frontier model options available. Most developers spend under $10/month during development and testing.
Why is my Anthropic API key not working?
Check four things in this order: your credit balance has funds, you are using the x-api-key header (not Authorization: Bearer), you included the anthropic-version header in your request, and the key was not accidentally revoked. The header format is the most common cause of “authentication failed” errors for developers switching from other AI providers.
Can I use one Anthropic API key for multiple projects?
You can, but creating separate keys per project is better practice. It takes seconds to generate a new key, and separate keys give you granular control over revocation and usage tracking. If one project leaks the key, your other projects are unaffected.
What are Anthropic’s rate limit tiers?
Anthropic uses a 4-tier system based on how much credit you have deposited. The free tier allows 5 requests per minute. Tier 1 (after depositing $5) allows 50 RPM. Tier 2 and above unlock 1,000+ RPM with higher token-per-minute limits. You move up tiers automatically as your cumulative spend increases.
Which Claude model should I use with my API key?
For most use cases, start with Claude Sonnet 4.6. It offers the best balance of speed, intelligence, and cost. Use Haiku 4.5 for high-volume tasks where speed matters more than depth. Use Opus 4.6 for complex coding, multi-step reasoning, or agent workflows where accuracy justifies the higher cost.
Key Takeaways
- The Claude API and Claude.ai Pro are separate products with separate billing. Go to console.anthropic.com for API access.
- Add at least $5 in billing credit before generating your key. This unlocks Tier 1 rate limits (50 RPM vs. 5 RPM) and prevents most “key not working” errors.
- Copy your key the moment it appears. Anthropic shows it exactly once.
- Use the
x-api-keyheader for authentication, notAuthorization: Bearer. This is the most common gotcha for developers switching from OpenAI. - Connect your key to tools like Openclaw to put Claude to work as an autonomous agent, not just raw API calls.
SFAI Labs