Setting Up an Anthropic Account and API Access
Independent educational resource, not an official Anthropic course. Facts about the API, prices and limits were checked against Anthropic's documentation on 15 November 2026 and the code was run against a local mock of the API, not the live service. Check the linked official pages before relying on a number, and test with your own key.
Everything you build in this module needs an Anthropic Console account and an API key. This lesson walks you through creating both, explains the limits that apply to a new account, and ends with a one-minute check that proves your setup works before you write any application code.
Learning objectives
- Create a Claude Console account and find the API keys page.
- Understand usage tiers, spend limits and rate limits, and what a new account can expect.
- Set a spend limit of your own so a bug cannot run up a large bill.
- Store the key in an environment variable and verify it with a read-only request.
Prerequisites
The Console, workspaces and keys
The Claude Console at platform.claude.com is where you manage everything about your API access: keys, billing, usage, limits and workspaces. A workspace is a container inside your organisation. Keys can be tied to one workspace, which keeps a test project and a production project apart and lets you set separate limits for each.
Your account belongs to an organisation. Limits (described next) apply to the organisation as a whole, and you can set lower limits per workspace.
Step by step: create the account and a key
- Sign up or sign in at the Console and complete any billing or verification steps it asks for. The exact steps change over time, so follow the screens rather than a screenshot.
- Open the API keys page (
platform.claude.com/settings/keys) and click Create key.
- Name the key after what will use it, for example
laptop-dev-2026. A good name tells you which key to delete if it leaks.
- Choose an expiration. For learning, pick a short one such as 7 days. The Console offers presets (3 hours, 1 day, 7 days, 30 days), a custom duration, or Never. Expiration cannot be changed afterwards.
- Copy the key once and store it in your password manager or secret store. Treat it like a password.
Lesson 2.2 explains the key types in detail. For now, a personal key for your own development is the right choice.
How limits work
Anthropic describes two kinds of limits.
| Limit | What it caps | What you see when you hit it |
| Spend limit | The maximum monthly cost. Each of the Start, Build and Scale tiers has a cap ($500, $1,000 and $200,000 per month on the page checked). | HTTP 429 rate_limit_error with no retry-after header when you reach your tier's cap. HTTP 400 invalid_request_error when you reach a limit you set yourself. |
| Rate limit | How fast you can go: requests per minute (RPM), input tokens per minute (ITPM) and output tokens per minute (OTPM), per model class. | HTTP 429 rate_limit_error, usually with a retry-after header. |
New organisations, and those with little usage history, may start in an Evaluation tier with limits below the standard ones; they rise automatically as you build usage history. As an example of standard numbers, the Start tier lists 4,000 RPM, 2,000,000 ITPM and 400,000 OTPM for Claude Sonnet 5.5. These figures change, so read your own limits on the Console's Rate limits page rather than relying on a tutorial.
Rate limits use a token-bucket algorithm, so capacity refills continuously instead of resetting on the minute. A short burst can still trip a limit even when your per-minute average looks safe.
Set your own spend limit
Do this before you write code. In the Console, open Spend limits (platform.claude.com/settings/spend-limits), click Set limit next to the monthly limit and enter an amount well below your tier's cap, for example $10 while you learn. A limit you set cannot exceed your tier's cap. When it is reached, requests fail with a 400 error whose message starts "You have reached your specified API usage limits", which is far better than discovering a runaway loop on your invoice.
Step by step: store the key and verify it
Put the key in an environment variable for your shell. On Linux or macOS:
export ANTHROPIC_API_KEY="your-api-key-here"
For a project, keep it in a .env file that is ignored by Git, and commit a .env.example with an empty value so teammates know the variable exists:
# .env.example (committed)
ANTHROPIC_API_KEY=
# .gitignore must contain:
.env
Install the Python SDK, then run a read-only request that lists the models your key can use. It sends no prompt, so it costs nothing in tokens:
python3 -m venv .venv && source .venv/bin/activate
pip install anthropic
python verify_key.py
import anthropic
# Reads ANTHROPIC_API_KEY from the environment.
client = anthropic.Anthropic()
# Listing models is a cheap, read-only call that proves the key works.
for model in client.models.list(limit=5):
print(model.id, "-", model.display_name)
If the script prints model IDs, your key, network path and account are working. If you see authentication_error, the key is wrong, expired or revoked. If you see permission_error, the key lacks access to the resource; check your workspace settings in the Console.
Real-world use case (illustrative scenario)
This scenario is an invented example to show how the ideas fit together. It is not a case study and its details are not measured results.
A freelancer builds a client's support tool. They create one workspace per client, a key scoped to that workspace, and a spend limit for the workspace equal to the client's monthly AI budget. When the client's traffic grows, the budget is a single number they can raise. If a key leaks, only that one workspace is exposed and the key can be disabled without touching other projects.
Common errors and solutions
| Symptom | Cause | Fix |
authentication_error (401) from a key that used to work | The key expired. Expired keys cannot be reactivated. | Create a new key and update your environment. |
400 mentioning anthropic-workspace-id | The key is not scoped to a workspace and the request did not name one. | Use a workspace-scoped key, or send the header (lesson 2.2). |
429 with no retry-after | Monthly spend cap reached. | Wait for the reset (00:00 UTC on the first of the month) or request a tier increase in the Console. |
402 billing_error | Problem with payment details. | Fix billing in the Console. |
| Script cannot find the key | Variable set in a different terminal, or .env not loaded. | Run echo $ANTHROPIC_API_KEY in the same shell that runs the script. |
Security considerations
- A key is a password that spends your money. Never commit it, paste it in chat or tickets, or put it in front-end code.
- Use a short expiration while learning, and delete keys you no longer use.
- Give each project its own key so one leak does not force you to rotate everything.
- Calls from users' browsers directly to the API are the wrong design. Anthropic's documentation advises calling the API from your own back end, and organisations with zero data retention or the Compliance API enabled cannot call it from a browser at all.
Performance and cost considerations
A spend limit is your first cost control, rate limits are your second, and neither replaces measuring tokens in code (lesson 2.9). Expect a new account to have lower limits than the tables in the documentation until usage history builds, so do not load-test on day one.
Key takeaways
- The Console manages keys, billing, usage, limits and workspaces.
- Two kinds of limits exist: monthly spend limits and per-minute rate limits (RPM, ITPM, OTPM).
- Set your own spend limit before writing code.
- Keep the key in an environment variable, ignored by Git, and verify with a read-only call.
Lesson recap: set up the account, create a key, cap your spend, verify with a read-only request.
Knowledge check
- Which two kinds of limit does Anthropic describe, and which HTTP statuses do they produce?
- Why should you set your own spend limit below your tier's cap?
- A 429 arrives with no
retry-after header. What does that suggest?
- Why is
.env.example committed while .env is not?
- Why does the verification script list models instead of sending a prompt?
Answers and explanations
- Spend limits (monthly cost) and rate limits (RPM, ITPM, OTPM). A rate limit returns 429. A tier spend cap also returns 429, while a spend limit you set yourself returns 400.
- A bug such as an endless retry loop can burn money quickly. Your own limit stops it at an amount you chose.
- The spend cap has been reached. Retrying fails until access resumes, so do not loop.
- The example file documents which variables the app needs without exposing real secrets; the real file holds the secret and must stay out of version control.
- Listing models is read-only and uses no tokens, so it proves authentication without any generation cost.
Official references and further reading
Related tutorials