working-with-vercel-ai-sdk
Use when working with the Vercel AI SDK (the `ai` package) — generateText, streamText, generateObject, streamObject, embeddings, tools/tool-calling, agents (ToolLoopAgent), AI SDK UI hooks (useChat, u
Files565
View on GitHubSKILL.mdskills/working-with-vercel-ai-sdk/SKILL.md
GitHubWorking with the Vercel AI SDK
Comprehensive offline documentation for the Vercel AI SDK (ai package), fetched verbatim from ai-sdk.dev and stored in references/. Use these files instead of guessing the API from memory.
How to use this skill
- Read the bundled
references/first. Files are named by their doc path, with/replaced by__— e.g.https://ai-sdk.dev/docs/ai-sdk-core/generating-text→references/docs__ai-sdk-core__generating-text.md. Each file carriessource/fetched_at/sha256frontmatter so you know exactly which page and when it was fetched. - If something looks stale or missing, fetch the live Markdown — append
.mdto any ai-sdk.dev page URL (e.g.https://ai-sdk.dev/docs/agents/overview.md) — or query the docs search API:https://ai-sdk.dev/api/search-docs?q=your+query(append.mdto returned URLs). grepthereferences/directory by topic (generateText,useChat,ToolLoopAgent, a provider name, an error message) to find the right page fast.
Behavioral guidance (when writing AI SDK code)
- Never rely on memory for model IDs. Provider model identifiers change often. Fetch the current list before writing provider code — e.g. the relevant
references/providers__*.mdpage, or the live provider doc. - Default to the Vercel AI Gateway provider unless the user specifies a direct provider. See
references/providers__ai-sdk-providers__ai-gateway.md. - Check the installed package version. If the project has
node_modules/ai/, prefer its docs and match its major version; the AI SDK has meaningful API changes across majors (see the migration guides). - Prefer streaming + typed output patterns (
streamText,streamObject, Zod schemas) where they fit, matching the surrounding codebase.
Reference map
References are grouped by their path prefix:
docs__getting-started__*— framework quickstarts (Next.js, Node, Svelte, Nuxt, Expo) and library navigation.docs__foundations__*— core concepts: providers/models, prompts, tools, streaming, agents.docs__ai-sdk-core__*— server-side generation:generateText,streamText,generateObject,streamObject, embeddings, image/speech, tool calling, middleware, provider/model management, error handling, telemetry.docs__ai-sdk-ui__*— client framework hooks:useChat,useCompletion,useObject, streaming, message persistence, transport.docs__ai-sdk-rsc__*— React Server Components streaming UI (streamUI, generative UI).docs__agents__*— building agents,ToolLoopAgent, loop control, memory, workflows, subagents.docs__advanced__*— caching, rate limiting, backpressure, stopping streams, rendering UI with language models.docs__reference__*— full API reference for AI SDK Core, UI, RSC, and provider utilities.docs__troubleshooting__*— common errors and fixes.docs__migration-guides__*— version-to-version migration (3.x → 6.0).providers__*— first-party and OpenAI-compatible/community provider docs (OpenAI, Anthropic, Google, AI Gateway, Bedrock, Groq, and more).cookbook__*— task-oriented recipes for Next.js, Node, and framework-agnostic guides (RAG, multi-modal chat, structured extraction, etc.).
Keeping this current
The references/ directory is regenerated by scripts/update_docs.js, which reads ai-sdk.dev/sitemap.md, filters to the /docs, /providers, and /cookbook sections, and re-fetches each page. A weekly GitHub Action (.github/workflows/update-docs.yml) runs it and commits any changes. To refresh locally: make update-working-with-vercel-ai-sdk.
Note: official live-search skill
Vercel also ships an official, thinner skill (npx skills add vercel/ai, source vercel/ai → skills/use-ai-sdk) that performs live documentation search at runtime instead of bundling docs offline. This skill differs by bundling the full docs locally — prefer it for offline/grep-able access; use the official one if you want only live search.