Lesson 1 of 7
From chat box to API
7 min read
You type in a chat window and an answer appears. Behind that box is a single web request — and once you can send it yourself, you can build anything the chat can, and plenty it can't.
A chat message is an API call
The chat app you know is only one client of the API. Every message you send becomes an HTTP request: some instructions, the conversation so far, a few settings — posted to an endpoint, which posts back one reply. Learn the shape of that request and the whole chat app stops being magic.
An API call is a plain request: you send system + messages + parameters, and you get back one message. That's the whole contract.
The four parts, every time
The pieces don't change from call to call. The system prompt sets the model's role and rules. The messages carry the conversation, each turn labelled user or assistant. The parameters pick the model and cap the reply. And the response hands you the assistant's message plus a stop reason. Master these four and every SDK is just a wrapper around them.
There's no hidden state on the server — you resend the whole conversation each call. The model is stateless; your app holds the memory.
Every official SDK — Python, TypeScript, whatever — is a thin convenience layer over this one HTTP request. When something breaks, drop down to the raw call and read exactly what you sent and got back.
The shape of it
- —A chat message is an HTTP call to the API — instructions in, one message out.
- —Four parts every time: system prompt, messages, parameters, response.
- —The model is stateless — you resend the full conversation on each call.
- —SDKs are wrappers; the raw request is the source of truth.
Your app sends a second message in a conversation, but the model acts like the first one never happened. What did you most likely forget?
Continue in the app
Take the whole Building AI Apps with the API course — tracked
Get your personalized path, progress and streaks in the app — this lesson and every next one, in order.