Stage 2 · Lesson 1 of 9
The chat messages API
Every to a major provider has the same basic shape. You send a model name and a list of messages. Each message has a role: system (or developer) for your instructions, user for what the person typed, and assistant for the model's earlier replies.
You also send a maximum output length and sampling settings. You get back the reply, plus a usage count of the tokens used. The API is , meaning it remembers nothing between calls.
So a is your code adding each reply to the list and sending all of it again. Read the usage field on every response and log it, because that is your real cost. Learn one official (the provider's own library) properly before adding a framework. Then you know what a request looks like when something breaks.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Prompt Engineering for Software Engineers
Design Gurus · Beginner · Subscription
Prompting patterns for engineers building features, not for chatting
- ToolFreeVercel AI SDK Documentation
Vercel · Intermediate
Free: the Foundations and Getting Started guides for prompts, generateText and streamText
Practise
Keep handy
Also worth your time
Few-shot, chain of thought, JSON enforcement and parsing failures in one place