ai-streaming
Installation
SKILL.md
Wire streaming AI responses from model to browser. Uses the Vercel AI SDK — the right abstraction for Next.js AI apps. Reads the project first, wires into existing auth and model config.
Four things that silently break AI streaming
- Wrong runtime on the route handler. Streaming requires the Edge runtime or a Node.js runtime with proper response handling. Without
export const runtime = 'edge'or proper streaming setup, the response buffers entirely and "streams" all at once at the end. - No abort handling. If the user navigates away mid-generation, the model keeps running and spending tokens. Always pass
abortSignalfrom anAbortControllerand clean up on component unmount. - Auth check after the stream starts. Once you call
streamText, headers are sent. You can't return a 401 after streaming begins. Auth must be checked and validated before calling any SDK method. - Missing error boundaries on the client. If the stream errors mid-response,
useChatsurfaces it in theerrorstate — but if you don't render it, the UI freezes silently with partial output.
Phase 1: Detect the Project
cat package.json | grep -E "ai|anthropic|openai|@ai-sdk"
aipackage present? → Vercel AI SDK installed, go to Phase 3@anthropic-ai/sdkonly? → add Vercel AI SDK on topopenaionly? → add Vercel AI SDK on top- Nothing? → install from scratch