ai-sdk

Build AI agents, chatbots, and streaming features with the Vercel AI SDK.

Updated Jul 17, 2026
One-click install
npx skills add https://github.com/usmangurowa/socialmocks --skill ai-sdk-usmangurowa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-sdk
Source: https://github.com/usmangurowa/socialmocks/tree/main/.agents/skills/ai-sdk
Command: npx skills add https://github.com/usmangurowa/socialmocks --skill ai-sdk-usmangurowa

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? The AI SDK changes rapidly, and outdated knowledge leads to deprecated APIs, type errors, and broken code. This Skill forces verification against current documentation and source code so AI features are built with correct, up-to-date patterns. ## Core Features & Use Cases - Current API Verification: Searches bundled docs in node_modules/ai/docs/ and ai-sdk.dev instead of relying on stale training data. - Agent Building: Guides creation of ToolLoopAgent-based agents with type-safe consumption via useChat and InferAgentUIMessage. - Error Resolution: Maps deprecated APIs (maxTokens, maxSteps, parameters, generateObject) to their modern replacements. - Use Case: A developer asks to add a streaming chatbot to a Next.js app; the Skill checks the installed ai package docs, fetches current model IDs from the Vercel AI Gateway, and produces type-safe server and client code. ## Quick Start Ask the assistant to build a streaming chat endpoint using the AI SDK with the latest Anthropic model.

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 tools defined via the tool function with inputSchema. Export the agent and infer its UIMessage type with InferAgentUIMessage for type-safe rendering in useChat.

How do I generate structured output with the AI SDK?

Use generateText with the output option instead of the deprecated generateObject. Pass Output.object with a Zod schema, or use Output.array, Output.choice, or Output.json depending on the shape you need.

Why is maxTokens not working in generateText?

maxTokens is deprecated and replaced by maxOutputTokens. Similarly, maxSteps is replaced by stopWhen with stepCountIs(n), and tool parameters are now defined with inputSchema instead of parameters.

Does useChat still manage input state automatically?

No, useChat no longer manages input state internally. You must manage input with useState, configure a DefaultChatTransport, and call sendMessage with the message text on submit.

How do I find current AI model IDs for the AI SDK?

Fetch the model list from the Vercel AI Gateway API at ai-gateway.vercel.sh/v1/models and filter by provider prefix. Never rely on memorized model IDs, and prefer the highest version number available.