Lesson 1 of 8
Request → Model → Response
Most simple AI apps are easier to understand when you reduce them to one loop.
Active reading
USER→SERVER→MODEL→SERVER→UI
The browser should not do everything
A basic AI app has a user interface, server-side code, a model request, and a response. Keeping these roles separate makes the app easier to secure, debug and extend.
Understand
1. UI
Collects the user’s input and shows state.
2. Server
Validates input and protects secrets.
3. Model
Processes the request and returns output.
4. UI again
Renders success or error states.
Important
Do not put private API keys directly in browser JavaScript.
The browser is controlled by the visitor. Secrets belong on a trusted server or another protected execution environment.
Try it
{
"input": "...",
"response_format": "..."
}Key takeaway
Start simple: browser collects input, server protects secrets and calls the model, then the interface renders the response. Add complexity only when the product needs it.