AI chat app with streaming responses
A ChatGPT-style chat UI that streams tokens from your own server route, so your API key stays secret.
Build a chat app with streaming responses from [OpenAI / Anthropic / another LLM API]. - Server route that holds the API key (server-only env var) and streams the response. - Client UI: message list, input with Enter-to-send, Stop button, auto-scroll, markdown rendering with code blocks and copy buttons. - Keep conversation history in the browser; send only the last N messages to control cost. - Per-IP or per-user rate limiting and a max input length on the server route. - Clear error messages for 401 (bad key), 429 (rate limit/quota), and network failures. Use the provider's official SDK and current docs for model names.
Tips
- Never call the LLM API directly from the browser with your key.
Works with: Cursor, Claude Code, Codex, Replit, Lovable, Bolt, v0. Last reviewed 2026-11-13.