One rule
Your frontend should never call OpenAI directly. Put the OpenAI call in a backend route, read the key from an environment variable, and let your UI call your own route.
Use the Responses API for new text features. Older tutorials may show Chat Completions first, but that is no longer the recommended starting point for text generation apps.
What goes where
Think of the model call like a function. The instructions are your product rules and business logic. The input is what the user typed.
For example, instructions can say: “You are a study assistant for Indian college students. Keep answers under 120 words.” The input is the student’s actual question.