LLM API Requests and Responses
In this article
- Read a request to a model: name its model, its system prompt, the role of each message and its output limit.
- Read a response: find the reply text, say from the stop reason why it ended, and tell whether it is complete.
- Explain why a follow-up in the same chat is a new request that carries the earlier turns again.
- Check whether a request and its reply fit in the context window, counted in tokens.
- Terms defined here: model API, message role, system prompt, stop reason, context window.
Overview
Ask a chat assistant "In which city is the Eiffel Tower?" and "Paris." comes back. Follow up with "Describe the Eiffel Tower in one word." and one word comes back. Behind the screen, the application talks to the model through an LLM API (also called a model API): it sends a request with named parts, and the company running the model, its provider, sends back a response with named parts of its own. A model you download and run on your own machine has no provider in this sense: your program calls it directly. Read both and you can see what the model was actually told, why a reply stopped where it did, why the second request is longer than the first, and why a long chat runs out of room.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- The request
- What the model reads
- The response
- The second turn
- The context window
- Sources
- Check yourself, 5 questions