ChatGPT is a general-purpose AI chat assistant built by OpenAI. Users can have ongoing conversations with it, and a large language model generates each reply. The response appears gradually on the screen as the model produces it.
Popular examples of AI chat assistants: ChatGPT, Claude, Gemini, Microsoft Copilot
In this chapter, we'll design a ChatGPT-style assistant. The basic interaction is straightforward: a user sends a message, the backend passes it to a language model, and the response streams back to the user.
The challenge is making this work reliably at scale. A consumer chat assistant may serve hundreds of millions of users each week. Every response takes GPU time and can keep a connection open for several seconds or longer. Conversations can grow to hundreds of turns, users can attach files, and the system may offer several models with different capabilities, costs, and response times.
We'll start with the requirements and overall architecture, then explore streaming and reconnects, long conversation histories, GPU capacity, model routing, and usage limits for different subscription plans.