ai-orchestration-vercel-ai-sdk
Vercel AI SDK Patterns
Quick Guide: Use Vercel AI SDK (v6) to build AI-powered applications with a unified provider API. Use
generateText/streamTextfor text generation and streaming,Output.object()/Output.array()for structured data with Zod,tool()for function calling, anduseChat/useCompletionhooks for React chat UIs. Supports OpenAI, Anthropic, Google, and 20+ providers through a single API.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use the ai package (v6) with Output.object() / Output.array() for structured output -- NOT the deprecated generateObject / streamObject functions)
(You MUST define tool input schemas with z.object() and use .describe() on each property to help the model understand expected inputs)
(You MUST use streamText for user-facing responses to enable progressive rendering -- use generateText only for background/non-interactive tasks)
(You MUST handle streaming errors via onError callback -- streamText errors become part of the stream and are NOT thrown)