Getting Started with Claude
Set up your tools and run your very first prompt.
← All modules in this stageYour 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
- Sent your first prompt to Claude and read the response
- Understood roles, content blocks, and tokens — the three concepts the rest of the API is built on
- Picked a Claude model that matches the work you'll be doing
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:
- Swap models. Replace
claude-haiku-4-5-20251001withclaude-sonnet-4-6for richer responses, orclaude-opus-4-7for hardest reasoning. (Cost and latency go up the same way.) - Add a system prompt. Try
system="Reply only in the form of a haiku."— see the persona take over. - Continue the conversation. Append the model's reply and a new user message, call
createagain. - Lower
max_tokens. Watch responses get truncated mid-sentence. The model never decides for itself when to stop based on length — you do.
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":
notebooks/01_introduction.ipynb— guided first prompts, the messages model, structured outputs (~1.5–2h)notebooks/02_intermediate.ipynb— failure modes and how to spot them, simple eval loops (~2–3h)notebooks/03_advanced.ipynb— production-minded prompting: safety, privacy, logging (~1.5–2.5h)
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:
- [ ] You ran a Python script that got a real reply from Claude
- [ ] You can explain roles, system prompt, and content blocks in your own words
- [ ] You can name two reasons to pick Haiku over Sonnet (and two reasons to do the opposite)
- [ ] You've changed at least one parameter and seen the response change
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.