Prompt Engineering and API Integration · Lesson 5
Conversational Interfaces with LLMs
LLM APIs are stateless: the model remembers nothing between calls. A chat app keeps the conversation history itself and sends the relevant messages each turn, alternating user and assistant roles.
As conversations grow they approach the context limit and cost more. Common strategies: keep only the last N turns, summarise older turns into a short memory, or retrieve only relevant past messages.
Good chat UX includes streaming responses, a clear system prompt for tone and boundaries, graceful error messages and guardrails against off-topic or unsafe requests.
Key points
- The API is stateless — you resend history
- Trim or summarise history to stay within context
- System prompt sets persona and limits
- Stream replies and handle errors gracefully