01 · Reality check
What Claude actually does well here
Good at
- Programmatic access to Claude from your own code and scripts
- Building products and integrations that call Claude
- Fine control over model choice, temperature and token limits
- Usage-based billing that scales with what you actually use
- Powering tools and editors that accept your own key
Not the right tool for
- Being included in a Pro or Max subscription, which it is not
- Being free: prepaid credits must be purchased before it works
- Replacing the Claude.ai app for ordinary chat, where the subscription is better value
- Predictable cost, since usage-based billing varies with what you send
- Beginners who just want to use Claude, who should use the app instead
02 · The method
Step by step
- 1
Decide whether you actually need the API
If you want to chat, use Claude.ai and pay for a subscription. You need the API only if you are writing code that calls Claude, or using a tool that requires your own key.
- 2
Create a Console account
Go to platform.claude.com. This is separate from your Claude.ai login even if you use the same email, and it is billed separately.
- 3
Buy usage credits
The API is prepaid: you must add credits before any request works. Credits expire a year after purchase and are non-refundable, and you can set a monthly spend cap and optional auto-reload.
- 4
Create the key
Go to platform.claude.com/settings/keys and generate a key. Copy it immediately and store it somewhere safe, and never commit it to a repository or paste it into a public page.
- 5
Set it as an environment variable
Export ANTHROPIC_API_KEY in your environment. The official SDKs read it automatically, so you never hardcode the key in your source.
- 6
For editors, prefer the official extension
In Cursor and VS Code the Claude Code extension signs in with your account and needs no API key. Only use the editor's bring-your-own-key setting if you specifically want API billing instead.
03 · Use this now
Minimal Python setup
Install the SDK and set your key, then this is the whole thing: pip install anthropic export ANTHROPIC_API_KEY=your-key-here from anthropic import Anthropic client = Anthropic() # reads ANTHROPIC_API_KEY automatically msg = client.messages.create( model="claude-sonnet-5", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], ) print(msg.content[0].text) Never hardcode the key in your source, and never commit it. Anthropic also publishes SDKs for TypeScript, C#, Go, Java, PHP and Ruby, plus an official ant CLI.
04 · Avoid these
Common mistakes
- Assuming a Claude Pro or Max subscription includes API access. It does not, and they are billed separately.
- Following a guide that sends you to console.anthropic.com. It redirects, but the current home is platform.claude.com.
- Believing the widely-repeated claim of free starter API credits. Anthropic does not document any, so budget for prepaid credits.
- Hardcoding the key in source or committing it to a repository, which is the most common way keys leak.
- Using an editor's bring-your-own-key mode when the official Claude Code extension would work without a key at all.
05 · Questions
Frequently asked questions
Where do I get a Claude API key?
From the Claude Console at platform.claude.com/settings/keys. If a guide sends you to console.anthropic.com, that address now redirects to the same place. You need a Console account, which is separate from your Claude.ai login, and you must add prepaid usage credits before the key will work.
Is there a free Claude API key?
Not for ordinary users. Anthropic's documentation states you must purchase usage credits before using the API or Workbench. The commonly repeated claim of free starter credits does not appear in any official Anthropic documentation, so do not count on it. Documented free-credit routes exist only through specific programmes such as AI for Science, researcher access and Claude for Startups.
Does my Claude Pro subscription include API access?
No, and this is the most common misunderstanding. Anthropic states plainly that a paid Claude subscription enhances your chat experience but does not include access to the Claude API or Console. Pro, Max, Team and Enterprise include no API credits, and you set up and pay for Console access separately.
How do I use a Claude API key in Cursor or VS Code?
The best answer is usually that you do not need one. The official Claude Code extension works in both VS Code and Cursor, signs in with your Claude account, and Anthropic states no API key is required. If you specifically want API billing, Cursor has a bring-your-own-key setting under Models, though note it covers chat models only and Cursor's zero-data-retention policy does not apply to it.
How do I use the Claude API in Python?
Install the official SDK with pip install anthropic, then set the ANTHROPIC_API_KEY environment variable. The client reads that variable automatically, so you can create an Anthropic() client with no arguments and never put the key in your code.
Does Claude Code need an API key?
Not necessarily. Claude Code can authenticate with a Claude subscription, which Anthropic marks as the recommended route, or with a Console account using prepaid API credits, or through a cloud provider. If you already have ANTHROPIC_API_KEY set in your environment, Claude Code will skip the login prompt and ask you to approve that key instead.