agentic-ai-course

Module 0 — Getting Started

Every module in this course calls Anthropic() and expects an API key to already be available. This module is that missing first step: what an API key is, how to get one, and how to give it to your code without ever writing it directly into a file.

What an API key actually is

It’s a secret string (starts with sk-ant-...) that identifies your Anthropic account to the API. Every request you make is billed to whichever account the key belongs to. Anyone who has the key can spend money on your account and see your usage — treat it exactly like a password, never like a username.

Step 1 — Create an Anthropic account

  1. Go to console.anthropic.com.
  2. Sign up with an email address, or continue with Google/GitHub.
  3. Verify your email if prompted.

Step 2 — Add billing (needed to actually make calls)

New accounts often start with a small amount of free trial credit, but you’ll need billing set up to keep using the API past that.

  1. In the console, open Settings → Billing (or Plans & Billing).
  2. Add a payment method.
  3. Optional but worth doing: set a monthly spend limit under the same page, so a bug in your code (like an infinite agent loop with no max_turns, mentioned back in Module 2) can’t run up an unexpectedly large bill.

Step 3 — Generate your API key

  1. In the left sidebar, click API Keys.
  2. Click Create Key.
  3. Give it a descriptive name — e.g. agentic-ai-course — so you can tell it apart from other keys later, and revoke it individually if needed.
  4. Click Create. The full key is shown exactly once. Copy it now.
  5. Store it somewhere safe — a password manager is ideal. If you lose it, you cannot view it again; you’d have to revoke it and create a new one.

Step 4 — Give the key to your code (without writing it into a file)

Every module’s README says export ANTHROPIC_API_KEY=your_key_here — here’s what that actually means and why it’s done this way. Setting it as an environment variable means the key lives in your terminal session, not in any file that could be committed to git or shared by accident. The Anthropic() client used throughout this course reads it from there automatically — that’s why no module ever passes a key directly in code.

macOS / Linux (bash or zsh):

export ANTHROPIC_API_KEY=sk-ant-your-actual-key-here

This only lasts for the current terminal session. To make it permanent, add that line to ~/.zshrc or ~/.bashrc and restart your terminal.

Windows (PowerShell):

$env:ANTHROPIC_API_KEY = "sk-ant-your-actual-key-here"

This also only lasts for the current session. For a permanent version: setx ANTHROPIC_API_KEY "sk-ant-your-actual-key-here" (then open a new terminal for it to take effect).

Alternative — a .env file, if you’d rather not touch shell config: Create a file named .env in the module folder you’re running:

ANTHROPIC_API_KEY=sk-ant-your-actual-key-here

Then add python-dotenv to that module’s dependencies and add these two lines at the top of the script, before Anthropic() is called:

from dotenv import load_dotenv
load_dotenv()

If you do this, also create a .gitignore file containing .env — a .env file is exactly the kind of file that ends up committed by accident and leaks a key publicly. Module 5’s .gitignore shows this pattern already, for its database file.

Step 5 — Verify it works

Run this from any module’s folder (after pip install -r requirements.txt):

python -c "from anthropic import Anthropic; print(Anthropic().messages.create(model='claude-sonnet-4-5', max_tokens=20, messages=[{'role':'user','content':'Say hi in exactly 3 words.'}]).content[0].text)"

If you see a short reply printed back, your key is set up correctly and every module in this course is ready to run.

If a key ever leaks

Delete it immediately from API Keys in the console (this is called revoking) and create a new one. A leaked key is not a “rotate it later” problem — anyone who has it can spend money on your account right away.

Next

Module 1 — Your First Agent — now that a key is set up, the first real API call.