New to Claude Skills? Learn how to install them →

vercel on GitHub

AI SDK

OfficialFree

Build AI-powered applications with a unified API.

by vercel26.1k stars on vercel/ai
1 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What AI SDK does

The AI SDK by Vercel is a TypeScript toolkit designed to simplify the development of AI applications. It provides a unified API that integrates with multiple AI model providers, enabling developers to implement features such as text generation, structured output, tool calling, and embeddings seamlessly. This SDK is particularly useful for those looking to create chatbots, AI agents, or systems that require advanced text manipulation capabilities.

One of the key strengths of the AI SDK is its ability to adapt to changes in AI models and APIs. Given the rapid evolution of AI technologies, the SDK includes built-in mechanisms to ensure that developers are always working with the most current APIs and patterns. This is crucial, as relying on outdated information can lead to errors and inefficiencies in development. The SDK encourages developers to use the bundled documentation that comes with the package, ensuring that the information is version-matched and accurate.

For those new to AI development, the AI Gateway provides a streamlined way to access various models without the need to manage multiple API keys. This feature significantly reduces the complexity involved in getting started with AI applications. Additionally, the SDK’s DevTools allow developers to monitor and debug their AI interactions effectively, capturing requests, responses, and tool calls for thorough analysis during development.

Overall, the AI SDK is ideal for developers and designers looking to incorporate AI functionalities into their applications without the overhead of managing multiple dependencies or outdated information. Its focus on current practices and ease of use makes it a valuable resource for building sophisticated AI-driven features.

When to use it

Use the AI SDK when you need to build AI applications that require text generation, chatbots, or other AI-powered features.

When not to use it

This SDK may not be suitable for projects that do not require AI functionalities or for those who prefer a more manual approach to API integration.

What you can build with it

Integrating Chatbots

Use the AI SDK to quickly integrate a chatbot into your application, leveraging its text generation capabilities and unified API.

Building AI Agents

Create sophisticated AI agents with the SDK’s built-in abstractions, allowing for streamlined tool calling and type safety.

Debugging AI Interactions

Utilize the AI SDK DevTools to capture and inspect AI interactions, making it easier to debug and refine your AI features.

How to install AI SDK

View source

1. Install with the skills CLI

npx skills add vercel/ai/use-ai-sdk --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by vercel

What the AI SDK Is

The AI SDK by Vercel (the ai package on npm) is a TypeScript toolkit for building AI applications. It provides a unified API across model providers for text generation, structured output, tool calling, agents, embeddings, and framework UI integrations.

Critical: Do Not Trust Your Own Memory

Whatever you remember about the AI SDK is likely outdated. The SDK changes frequently across versions - APIs are renamed, removed, and added. Your training data almost certainly contains obsolete APIs, deprecated patterns, and model IDs that no longer exist. UI hooks like useChat are among the most frequently changed APIs, so be especially careful with client code.

Never write AI SDK code from memory. Always verify every API, option, and pattern against the documentation and source code for the version that is actually installed in the project.

Use the Bundled, Version-Matched Docs

The ai package ships its full documentation and source code inside node_modules. These always match the installed version, so trust them over anything you remember.

  1. Ensure ai is installed. If node_modules/ai/ does not exist, install only the ai package using the project's package manager (e.g. pnpm add ai). Install provider packages (e.g. @ai-sdk/openai) and framework packages (e.g. @ai-sdk/react) later, when the task requires them.
  2. Read and grep the bundled docs at node_modules/ai/docs/ and the source at node_modules/ai/src/.
  3. Provider and framework packages bundle their own docs at node_modules/@ai-sdk/<name>/docs/.
  4. If something isn't in the bundled docs, search https://ai-sdk.dev/docs. You can append .md to any docs page URL to get its markdown, and search via https://ai-sdk.dev/api/search-docs?q=your_query.
  5. If you cannot find support for an answer in the docs or source, say so explicitly — do not guess.

AI Gateway: The Fastest Way to Start

The Vercel AI Gateway is the fastest way to get started with the AI SDK. It provides access to models from OpenAI, Anthropic, Google, and other providers through a single API, without installing provider packages or managing multiple API keys.

To set it up:

  1. Authenticate with OIDC (for Vercel deployments) or get an AI Gateway API key.
  2. Provide it to your app via the AI_GATEWAY_API_KEY environment variable.
  3. Reference models with provider/model strings.

For exact setup, authentication, and usage, read the bundled guide and the AI Gateway docs.

Choosing a Model

Never use model IDs from memory — models are released and retired frequently. Fetch the current list before writing code that references a model. Do not truncate the list (e.g. with head) so you can find the newest models:

# All available models
curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '.data[].id'

# Filter by provider (e.g. anthropic, openai, google)
curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '[.data[] | select(.id | startswith("anthropic/")) | .id] | reverse | .[]'

When multiple versions of a model exist, prefer the one with the highest version number.

Building and Consuming Agents

Use the SDK's built-in agent abstraction (such as ToolLoopAgent) rather than hand-rolling tool-calling loops. For end-to-end type safety, infer the UI message type from your agent definition when consuming it on the client (e.g. with useChat). Consuming an agent is framework-specific: check package.json to detect the stack, then follow the matching quickstart.

Look up the current agent, tool, and type-safety APIs in the bundled docs (node_modules/ai/docs/, especially the agents section) or at https://ai-sdk.dev/docs.

DevTools

AI SDK DevTools captures your AI SDK calls - requests, responses, tool calls, token usage, and multi-step runs - so you can inspect exactly what your agents do. Use it while developing to debug generations. It is a separate package and is intended for local development only.

For setup instructions, read the bundled DevTools documentation.

Keep the SDK Current

Outdated installs are the most common source of errors. Compare the installed version against the latest:

  • Installed: the version field in node_modules/ai/package.json.
  • Latest: run npm view ai version.

If the installed version is a major version (or more) behind the latest, tell the user they are on an old release, and recommend upgrading before continuing. Migration guides are at https://ai-sdk.dev/docs/migration-guides.

After Making Changes

Run the project's type checker. Be minimal — only set options that differ from the defaults, checking docs or source for the defaults rather than over-specifying. Most type errors come from remembered, now-changed APIs; re-check the current docs and source when they occur.

Frequently asked questions about AI SDK

Similar skills