Lesson 1 · 15 min · Windows
Your first Claude API call
A bot is just a program that sends a prompt to Claude and does something with the reply.
Install Python and the SDK
Windows steps
winget install Python.Python.3.12
py -m pip install anthropicStore your key (never in code)
Windows steps
setx ANTHROPIC_API_KEY "sk-ant-...your key..."Close and reopen PowerShell so it takes effect.
hello_bot.py
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
reply = client.messages.create(
model="claude-haiku-5-5",
max_tokens=300,
system="You are a friendly assistant. Answer in 3 short sentences.",
messages=[{"role": "user", "content": "Give me one tip to save time at work."}],
)
print(reply.content[0].text)Run it: py hello_bot.py (Windows) or python3 hello_bot.py (Mac/Linux).
Cost tip: set max_tokens low and use Haiku for simple jobs. Add a monthly spend limit in the Anthropic Console.
Quick quiz
Pass 2 of 3Quick assignment
To doRun hello_bot.py, change the system prompt to give it a personality, and paste the reply you got.
Hint: Never paste your API key.
Join free to submitStuck or proud of what you built? Discuss this course in the forum.