Next.js Chat UI
A streaming chat built with the Vercel AI SDK and @caesura-io/ai-sdk.
Source and setup · Repository setup
Use Node.js 22 or newer. In the example directory, run npm ci, copy .env.example to .env.local, set OPENAI_API_KEY and CAESURA_API_KEY, and run npm run dev. Open http://localhost:3000. Dependencies are installed from npm; keys remain server-side.
What it demonstrates
- Start conversation creates a CaesuraO conversation through
POST /api/conversations. The returned backend ID is used on chat requests. - New conversation explicitly creates another ID. Failed creation preserves the existing chat; a page refresh clears the example's browser history.
- Each customer message has a stable ID. Requests send growing dialogue history and reuse that message ID for analysis identity.
mode: 'sync'lets guidance affect the current streamed reply. The activity panel shows analysis events and reported credits.- Cancellation propagates to analysis and model generation.
HTTP persistence saves customer messages, their analyses, and completed agent replies. The example keeps active dialogue in the browser and guidance in server memory; it does not reload saved history on refresh. Shared deployments still need conversation coordination and durable guidance storage.
CAESURA_PERSIST=false disables saving transcripts and analyses to CaesuraO; a conversation ID is still required. See Conversations & Persistence for dashboard visibility.