ai

A provider-agnostic TypeScript toolkit for building AI-powered applications and agents across any model provider and UI framework.

TypeScriptNOASSERTIONFramework
โญ GitHubhttps://github.com/vercel/ai
25,892
Stars
+0
Star growth
Jul 30, 2026
Last updated
0
Clicks

1. Project Overview

The AI SDK (vercel/ai) is a provider-agnostic TypeScript toolkit, created by Vercel and the Next.js team, for building AI-powered applications and agents โ€” giving developers a single unified API to generate text, structured data, and agentic workflows across dozens of model providers and UI frameworks.

2. Background & Positioning

The AI SDK was created to solve a recurring pain point in AI application development: every model provider (OpenAI, Anthropic, Google, and dozens more) ships its own SDK, request format, and streaming protocol, forcing developers to rewrite integration code every time they switch models or add a fallback provider. The AI SDK's core mission is to abstract that variance behind one consistent interface โ€” generateText, streamText, generateObject, and agent primitives all work the same way regardless of which model is behind them.

Compared to similar projects, the AI SDK differentiates itself by:

  • Being framework-agnostic on the client (Next.js, React, Svelte, Vue, Angular) while remaining runtime-agnostic on the server (Node.js, edge runtimes, serverless functions).
  • Shipping a built-in gateway (Vercel AI Gateway) that gives access to 100+ models across 16+ providers via a single model string, with no separate provider package required to get started.
  • Treating agents as a first-class concept (ToolLoopAgent) rather than a thin wrapper around chat completions, with native support for tool calling, durable long-running workflows, and sandboxed code execution.
  • Maintaining a strict separation between Core (server/edge logic), UI (client hooks), and RSC (streaming React Server Components), so teams can adopt only the layers they need.

3. Feature Categories

  • ๐Ÿค– Model Providers (40+ packages) โ€” Adapters connecting the unified API to specific LLM vendors and inference platforms.

    • @ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/google โ€” the three most widely used providers.
    • @ai-sdk/xai, @ai-sdk/mistral, @ai-sdk/groq, @ai-sdk/cohere โ€” additional major hosted-model providers.
    • @ai-sdk/amazon-bedrock, @ai-sdk/azure, @ai-sdk/google-vertex โ€” cloud-platform-native model access.
    • @ai-sdk/openai-compatible โ€” a generic adapter for any OpenAI-compatible inference endpoint (self-hosted or third-party).
  • ๐ŸŽ™๏ธ Speech & Audio (7 packages) โ€” Providers for transcription and voice generation.

    • @ai-sdk/deepgram, @ai-sdk/assemblyai, @ai-sdk/revai, @ai-sdk/gladia โ€” speech-to-text transcription.
    • @ai-sdk/elevenlabs, @ai-sdk/cartesia, @ai-sdk/lmnt, @ai-sdk/hume โ€” text-to-speech and voice synthesis.
  • ๐ŸŽจ Image & Video Generation (6 packages) โ€” Providers for visual media generation.

    • @ai-sdk/replicate, @ai-sdk/fal, @ai-sdk/black-forest-labs โ€” image generation and hosted model inference.
    • @ai-sdk/luma, @ai-sdk/klingai, @ai-sdk/minimax โ€” video and multimodal generation.
  • ๐Ÿ–ผ๏ธ UI Framework Integrations (5 packages) โ€” Client-side hooks for building chat and generative interfaces.

    • @ai-sdk/react, @ai-sdk/vue, @ai-sdk/svelte, @ai-sdk/angular โ€” framework-specific chat/completion hooks.
    • @ai-sdk/rsc โ€” streaming React Server Components support for generative UI.
  • ๐Ÿงฉ Agent Infrastructure (10+ packages) โ€” Building blocks for autonomous and durable agents.

    • ai (core ToolLoopAgent) โ€” the tool-calling agent loop at the heart of the SDK.
    • @ai-sdk/mcp โ€” Model Context Protocol client/server support for tool interoperability.
    • @ai-sdk/workflow, @ai-sdk/workflow-harness โ€” durable, long-running agent workflows.
    • @ai-sdk/sandbox-vercel, @ai-sdk/sandbox-just-bash โ€” sandboxed code execution environments for agents.
    • @ai-sdk/harness-claude-code, @ai-sdk/harness-codex, @ai-sdk/harness-opencode โ€” integrations with popular coding-agent harnesses.
  • ๐Ÿ› ๏ธ Developer Tooling (6 packages) โ€” Supporting infrastructure for building and operating AI SDK apps.

    • @ai-sdk/gateway โ€” unified routing to the Vercel AI Gateway.
    • @ai-sdk/otel โ€” OpenTelemetry instrumentation for observability.
    • @ai-sdk/devtools, @ai-sdk/tui โ€” debugging and terminal UI utilities.
    • @ai-sdk/provider, @ai-sdk/provider-utils โ€” the low-level contracts new provider packages implement against.

4. Key Highlights

  • Unified model API โ€” Swap between OpenAI, Anthropic, Google, and 100+ other models by changing a single string, with no rewrite of application logic.
  • Vercel AI Gateway by default โ€” Out-of-the-box access to major providers without installing separate provider SDKs, plus centralized rate limiting and fallback routing.
  • ToolLoopAgent primitive โ€” A first-class agent abstraction with reasoning control, tool calling, and runtime context, rather than a manual chat-completion loop.
  • Structured output generation โ€” generateObject/Output.object produce schema-validated JSON via Zod (or Valibot), eliminating brittle prompt-based JSON parsing.
  • Durable Workflows and Sandbox โ€” Long-running agent workflows that survive restarts, paired with sandboxed execution environments for agents that need to run code safely.
  • Framework-agnostic streaming UI โ€” The same streaming chat/generative-UI hooks work across Next.js, React, Svelte, Vue, and Angular.

5. Use Cases by Role

  • General developers โ€” Build chatbots, copilots, and generative UI features in Next.js/React/Vue/Svelte apps using a consistent API regardless of the underlying model.
  • DevOps/SRE โ€” Use @ai-sdk/otel for observability and the Vercel AI Gateway for centralized rate limiting, fallback, and cost tracking across model providers.
  • Data/research scientists โ€” Prototype structured-data extraction and multi-step reasoning pipelines with generateObject and ToolLoopAgent without hand-rolling provider-specific request formats.
  • Project managers โ€” Evaluate the project's maturity via its large contributor base, weekly download volume, and active release cadence (AI SDK 6/7) as a signal of long-term maintenance.

6. Getting Started

Find what you need โ€” browse the provider directory and API reference to identify the provider package or primitive (generateText, streamText, ToolLoopAgent) that matches your use case.

Install and integrate

npm install ai
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
import { generateText } from 'ai';

const { text } = await generateText({
  model: 'openai/gpt-5.4', // routed through the Vercel AI Gateway
  prompt: 'What is an agent?',
});

Coding-agent users can also add the AI SDK skill directly to a repository with npx skills add vercel/ai.

Contribute โ€” read CONTRIBUTING.md; the project now prioritizes high-quality issues (clear reproductions, failing tests) over unsolicited large pull requests, so check the issue tracker before starting substantial work.

7. Project Structure

ai/
โ”œโ”€โ”€ packages/              # All published packages (core, providers, UI, agents)
โ”‚   โ”œโ”€โ”€ ai/                 # Core SDK: generateText, streamText, ToolLoopAgent
โ”‚   โ”œโ”€โ”€ openai/ anthropic/ google/ ...  # Model provider adapters
โ”‚   โ”œโ”€โ”€ react/ vue/ svelte/ angular/ rsc/  # UI framework integrations
โ”‚   โ”œโ”€โ”€ mcp/ workflow/ sandbox-vercel/     # Agent infrastructure
โ”‚   โ””โ”€โ”€ provider/ provider-utils/          # Contracts for building new providers
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ docs/               # ai-sdk.dev documentation site
โ”œโ”€โ”€ content/                # Documentation source content
โ”œโ”€โ”€ examples/               # Runnable example applications
โ”œโ”€โ”€ skills/                 # Coding-agent skill definitions
โ”œโ”€โ”€ tools/                  # Internal build/dev utilities
โ””โ”€โ”€ CONTRIBUTING.md

Each folder under packages/ is an independently versioned npm package; provider packages implement the shared contract defined in packages/provider so they plug into the same generateText/streamText API.

8. Related Ecosystem

  • Next.js โ€” the framework the AI SDK is built alongside and most commonly deployed with.
  • Vercel AI Gateway โ€” the default routing layer giving access to 100+ models without per-provider setup.
  • Vercel Sandbox โ€” the secure execution environment used by @ai-sdk/sandbox-vercel for agent code execution.
  • Zod / Valibot โ€” schema validation libraries used for structured output generation.
  • Model Context Protocol (MCP) โ€” the open protocol @ai-sdk/mcp implements for tool interoperability across agent ecosystems.
  • LangChain / LlamaIndex โ€” supported as optional orchestration layers via dedicated adapter packages.

9. License

The project is distributed under the Apache License 2.0.

  • โœ… Free to use, modify, and distribute, including in commercial and closed-source products.
  • โœ… Includes an explicit patent grant from contributors.
  • โŒ Comes with no warranty; contributors are not liable for damages arising from its use.
  • โ„น๏ธ Modified files must carry a notice stating changes were made, and the license/copyright notice must be preserved in distributions.

10. FAQ

Q: Do I need a separate API key for every model provider?
A: No โ€” by default the AI SDK routes requests through the Vercel AI Gateway using a single model string (e.g. 'anthropic/claude-opus-4.6'), though you can also install a specific provider package like @ai-sdk/anthropic to connect directly.

Q: Can I get structured, schema-validated output instead of raw text?
A: Yes โ€” use generateText with Output.object (or generateObject) and a Zod schema to get typed, validated JSON back from the model.

Q: Which frontend frameworks does the AI SDK support?
A: Next.js, React, Svelte, Vue, and Angular all have dedicated UI hook packages, and the core streaming primitives are framework-agnostic.

Q: How do I build an agent that can run code or use tools?
A: Use ToolLoopAgent from the core ai package, defining tools directly or via @ai-sdk/mcp for Model Context Protocol tool servers; pair it with @ai-sdk/sandbox-vercel for sandboxed code execution.

Q: What's the best way to contribute?
A: Check CONTRIBUTING.md first โ€” the maintainers currently prioritize clear bug reports, minimal reproductions, and failing tests over unsolicited full-implementation pull requests.

11. Quick Links

12. Summary

The AI SDK gives TypeScript developers one consistent way to call any major LLM, generate structured data, and build tool-using agents โ€” backed by a large provider ecosystem, native framework integrations, and Vercel's gateway/sandbox infrastructure. It is best suited for teams building production AI features who want to avoid vendor lock-in, swap models with a one-line change, and scale from a simple chatbot to durable, sandboxed agent workflows without switching toolkits.