Build: a CLI assistant
Everything in this unit fits in about a hundred lines of Python. You'll build a terminal assistant that streams its replies, uses tools, and tells you exactly what each conversation cost.
In this lesson you'll learn to
- Build a chat loop that keeps the conversation history and streams each reply.
- Run tool calls inside a streaming loop, safely, until the model is done.
- Track tokens and cost per turn and per session from the usage numbers.
- Handle errors, stop reasons and growing conversations in a real tool.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.