All projectsHow a chat message becomes a streamed reply
FoundationsFoundations~4h
AI chatbot
Your first production LLM application
Step 1 of 5
User message
The UI posts the message to /api/chat along with a session id, so the server knows which conversation it belongs to.
Guard the input, trim the history, stream the output, and count the cost of every turn.
Business problem
Create an AI chatbot that can hold a coherent conversation, maintain history, stream responses, and refuse harmful requests.
Architecture
UI → API (streaming) → LLM provider, with in-memory conversation store and input guard.
Milestones
Track your progress through the project.
0 of 5 milestones complete
Acceptance criteria
- Streaming works — first token < 500ms
- History maintains context across turns
- Persona changes behaviour visibly
- Oversized input is rejected
- Cost is logged per conversation
Deployment checklist
- API key in vault, not env
- Rate limiting per IP
- Streaming with reconnection
- Error logging
- Cost dashboard
Evaluation criteria
- Coherence across 5+ turns
- Latency budget met
- Cost budget met
- Guardrail blocks injection attempts