Stage 01 · FoundationsModule 1 of 26~3h

Getting Started with Claude

Set up your tools and run your very first prompt.

← All modules in this stage

Your first real conversation with Claude from Python — and a clear mental model of what's actually happening on the wire.

By the end of this module you'll have

Time: about 30 minutes for the basics, ~5 hours if you do all three notebooks and the exercises.


Before you begin

Have you finished the setup? You need an activated venv and an ANTHROPIC_API_KEY in .env. If python guides/guide-01-getting-started/scripts/main_application.py already prints a response, you're ready.


Your first prompt (under 30 seconds)

Save this as hello_claude.py (or paste into a Python REPL inside your venv):

import os
from anthropic import Anthropic
from dotenv import load_dotenv

load_dotenv()                                    # reads ANTHROPIC_API_KEY from .env

client = Anthropic()                             # uses ANTHROPIC_API_KEY automatically

response = client.messages.create(
    model="claude-haiku-4-5-20251001",           # fast and cheap — great for first runs
    max_tokens=300,
    messages=[
        {"role": "user", "content": "In two sentences, what is Claude good at?"}
    ],
)

print(response.content[0].text)

Run it:

python hello_claude.py

You should see two clean sentences from Claude. If you do, congratulations — you just used the API.


What just happened?

The Claude API has three concepts you'll use everywhere. Once these click, the rest is detail.

1. The messages list is the conversation

messages=[
    {"role": "user", "content": "In two sentences, what is Claude good at?"}
]

A message is a {"role": ..., "content": ...} pair. role is one of "user" or "assistant". To continue a conversation you append the model's reply (as assistant) and the user's next turn (as user) and call create again. The model has no memory between calls — you are responsible for replaying history.

2. System instructions sit outside the messages

You don't add a {"role": "system", ...} message. You pass system="..." as a top-level argument:

response = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=300,
    system="You are a terse senior engineer. Use no marketing language.",
    messages=[{"role": "user", "content": "Explain what an API is."}],
)

System prompts shape how Claude responds across every turn. Use them for persona, format rules, and constraints.

3. The response is a list of content blocks

response.content                    # list of blocks
response.content[0].text            # text of the first block
response.usage.input_tokens         # how many tokens you sent
response.usage.output_tokens        # how many tokens you got back

Most simple text replies have a single block, so response.content[0].text is what you want. Tool use, citations, and extended thinking can produce additional block types — you'll meet those in later modules.


Try changing one thing

Re-run the script after each tweak and notice what changes:


Picking a model (quick guide)

Model When to reach for it
claude-haiku-4-5-20251001 First experiments, classification, high-volume cheap work
claude-sonnet-4-6 The default for most production work — balanced quality and cost
claude-opus-4-7 Hard reasoning, long multi-step tasks, when quality matters more than budget

Module 2 goes deeper on capability differences and when each pays off.


Going deeper: open the notebooks

Three notebooks take you from "I just sent a prompt" to "I have a small evaluation habit":

Open them in your browser without installing anything (links on the site under "Notebooks") or run them locally with Jupyter:

jupyter notebook guides/guide-01-getting-started/notebooks/01_introduction.ipynb

Module checklist

Tick these off before moving on:


Next module

When the boxes above are ticked, head to Module 2 · Models & Capabilities to learn which Claude to use when, and why. The link sits at the bottom of this page.