Exercise 1 of 10 · 0 passed
Your First Claude API Call
The Anthropic Python SDK lets you call Claude in a few lines. At its core:
- Create a client:
anthropic.Anthropic() - Send messages:
client.messages.create(...) - Read the reply:
message.content[0].text
Why care? This is the foundation of every AI-powered app. Structured outputs, tool use, agents — everything builds on this one pattern.
Task
Complete get_completion(prompt) so it calls Claude and returns the text response.
Requirements:
- Model:
claude-sonnet-4-6 max_tokens=256- Return the text of the first content block
Click "Run tests". First time loads Python in your browser (~5s). After that, runs are instant on this page and ~1s on the others.
Loading tests…
Pass the tests to reveal the reference solution.
The point of the exercise is the struggle, not the answer. Once your tests are green, the reference solution unlocks here so you can compare patterns.
Loading solution…
That's the warm-up.
You ran ten exercises against a mocked SDK. The cohort builds the real thing: an AI agent shipped to production with 150+ passing tests, Telegram bot, FastAPI, Streamlit, Docker. Six weeks. Every PR reviewed.
See the cohort → Next free live session
Get sharper at building with AI, every two weeks
A biweekly email on working with AI and building agentic systems in Python: the architecture, testing, and prompting patterns we use to ship real agents, the same ones behind the cohort. One focused read, no fluff. Plus first word when the next seats open.
No spam. Unsubscribe anytime.