Skip to main content
Build a streaming chatbot with Next.js App Router, @runcrate/ai, and the Vercel AI SDK’s useChat hook. Under 50 lines of code for a working chat interface.

Prerequisites

Set your API key in .env.local:

API route


Chat component

Run npm run dev and open http://localhost:3000.

Add a system prompt selector


Tips

  • DeepSeek-V3 is the recommended default — fast, cheap, strong across general tasks.
  • useChat manages conversation history client-side. Each POST sends the full message array.
  • Error handling: useChat exposes an error property you can render in the UI.

Next steps