ai-sdk

Build AI agents, chatbots, and RAG features using the Vercel AI SDK.

Updated Aug 21, 2025
One-click install
npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill ai-sdk-adithiya-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-sdk
Source: https://github.com/Adithiya-S/AI-Study-Companion/tree/main/.agents/skills/ai-sdk/upstream
Command: npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill ai-sdk-adithiya-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ai, and includes references (resource) components.

What problem does it solve? Developers working with the Vercel AI SDK often rely on outdated training knowledge, leading to deprecated API usage, type errors, and broken implementations. This Skill forces verification against current documentation and source code, ensuring generated code uses the correct modern APIs like generateText, streamText, ToolLoopAgent, and useChat. ## Core Features & Use Cases - Documentation-Grounded Answers: Searches bundled docs in node_modules/ai/docs/ and ai-sdk.dev instead of relying on memory, preventing deprecated patterns like maxTokens or generateObject. - Agent Building Guidance: Implements the ToolLoopAgent pattern with type-safe consumption via InferAgentUIMessage and useChat, including framework-specific quickstarts. - Error Resolution: Maps common typecheck failures to renamed APIs (parameters to inputSchema, maxSteps to stopWhen) via a curated common-errors reference. - Use Case: A developer asks to add a streaming chatbot to a Next.js app. The Skill checks package.json, fetches current model IDs from the Vercel AI Gateway, and generates code using streamText with toUIMessageStreamResponse and the modern useChat transport pattern. ## Quick Start Ask the AI to build a chat agent with tool calling using the AI SDK and verify the code against the current documentation.

Frequently Asked Questions about ai-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an AI agent with the Vercel AI SDK?

Use the ToolLoopAgent class with a model, instructions, and a tools object. Search node_modules/ai/docs for current agent creation APIs, and export InferAgentUIMessage types for type-safe consumption with useChat.

How to use useChat with the latest AI SDK version?

The useChat hook no longer manages input state internally. Manage input with useState, pass a DefaultChatTransport instance via the transport option, and call sendMessage with the message text.

Why does maxSteps cause a type error in generateText?

maxSteps is deprecated in current AI SDK versions. Replace it with stopWhen: stepCountIs(n), importing stepCountIs from the ai package. Check the common-errors reference for other renamed parameters.

Does the AI SDK support OpenAI, Anthropic, and Google models?

Yes, through provider packages or the Vercel AI Gateway, which is the default provider. Fetch current model IDs with curl https://ai-gateway.vercel.sh/v1/models rather than relying on memorized model names.

What replaced generateObject for structured output?

generateObject is deprecated. Use generateText with the output option, such as Output.object({ schema }) for typed objects, Output.array for lists, or Output.choice for predefined selections.