AI Chat

OpenAI-powered chat with streaming responses (SSE).

Overview

AI Chat is powered by TanStack AI + OpenAI and streams responses to the browser.

  • UI: tanstarter/src/components/AIChat.tsx
  • Server route: tanstarter/src/routes/api/ai-chat.ts
  • Model tiers: tanstarter/src/lib/ai.ts

Enable it

Set:

OPENAI_API_KEY=sk-your-openai-api-key

How streaming works

The client POSTs to /api/ai-chat and reads Server-Sent Events (text/event-stream) until it receives [DONE].

Model selection is based on planId and the mapping in tanstarter/src/lib/ai.ts (basic, pro, enterprise).