A chat interface is the most common AI feature and Lovable can scaffold one end-to-end. Ask for "a chat page powered by AI" and you'll get a server route, the client hook, streaming message rendering, and a clean UI.
/What gets built
- 01Server route: Handles the request, calls the model, streams tokens back to the browser.
- 02useChat hook: Manages messages, input state, and streaming on the client.
- 03Message list: Renders user and assistant turns with markdown and code highlighting.
- 04System prompt: One editable string that shapes the assistant's personality and rules.
ts
import { streamText } from "ai";
import { createLovableAiGatewayProvider } from "@/lib/ai-gateway.server";
const gateway = createLovableAiGatewayProvider(process.env.LOVABLE_API_KEY!);
const result = streamText({
model: gateway("openai/gpt-5.5"),
system: "You are a helpful cooking assistant.",
messages,
});Prompt engineering lives in the system prompt
The system prompt is where you set tone, rules, and forbidden topics. Iterate on it in Chat mode before shipping.