Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, embed, tools, WorkflowAgent, Agent, HarnessAgent, useChat, or useCompletion, (2) Want to build AI agents, chatbots, RAG systems, durable workflows, or text generation features, (3) Have questions about AI providers, streaming, tool calling, structured output, embeddings, reasoning, approvals, telemetry, MCP Apps, file/skill uploads, or AI SDK testing. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat", "WorkflowAgent", "AI SDK test".
Before searching docs, check if node_modules/ai/docs/ exists. If not, install only the ai package using the project's package manager (e.g., pnpm add ai).
Do not install other packages at this stage. Provider packages (e.g., @ai-sdk/openai) and client packages (e.g., @ai-sdk/react) should be installed later when needed based on user requirements.
Everything you know about the AI SDK is outdated or wrong. Your training data contains obsolete APIs, deprecated patterns, and incorrect usage.
When working with the AI SDK:
ai package is installed (see Prerequisites)node_modules/ai/docs/ and node_modules/ai/src/ for current APIsuseChat has changed significantly - check Common Errors (references/common-errors.md) before writing client codereferences/ai-gateway.md) for usage details.curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '[.data[] | select(.id | startswith("provider/")) | .id] | reverse | .[]' (replacing provider with the relevant provider like anthropic, openai, or google) to get the full list with newest models first. Use the model with the highest version number (e.g., claude-sonnet-4-5 over claude-sonnet-4 over claude-3-5-sonnet).WorkflowAgent, Agent, HarnessAgent, tool approvals, tool/runtime context, files, skills, MCP Apps, sandbox support, terminal UI, telemetry, lifecycle events, and reasoning controls before choosing a primitive.If you cannot find documentation to support your answer, state that explicitly.
Search bundled docs and source in node_modules/ai/:
grep "query" node_modules/ai/docs/grep "query" node_modules/ai/src/Provider packages include docs at node_modules/@ai-sdk/<provider>/docs/.
https://ai-sdk.dev/api/search-docs?q=your_query.md URLs from results (e.g., https://ai-sdk.dev/docs/agents/building-agents.md)Before searching source code, grep Common Errors (references/common-errors.md) for the failing property or function name. Many type errors are caused by deprecated APIs documented there.
If not found in common-errors.md:
node_modules/ai/src/ and node_modules/ai/docs/Do not assume one agent primitive is always correct. Search node_modules/ai/docs/ and source for current agent APIs, then choose the smallest primitive that matches the work:
WorkflowAgent / workflow integration for durable or resumable agents that must survive restarts, deploys, interruptions, or delayed approvals.HarnessAgent / harness adapters when embedding Claude Code, Codex, Pi, or another mature harness behind AI SDK-compatible streams.Agent, generateText, or streamText when the loop is simple and the app owns the tool/control flow directly.File conventions: See type-safe-agents.md (references/type-safe-agents.md) for where to save agents and tools.
Type Safety: When consuming agents with useChat, always use InferAgentUIMessage<typeof agent> for type-safe tool results. See reference (references/type-safe-agents.md).
Before implementing agent consumption:
package.json to detect the project's framework/stackreferences/common-errors.md) - Renamed parameters reference (parameters → inputSchema, etc.)references/ai-gateway.md) - Gateway setup and usagereferences/type-safe-agents.md) - End-to-end type safety with InferAgentUIMessagereferences/devtools.md) - Set up local debugging and observability (development only)wiki/tools/vercel-ai-sdk.md for current routing, and wiki/tools/ai-test-kit.md for deterministic AI SDK test helpers.