AI SDK
Provider-agnostic TypeScript toolkit for building AI apps and agents with any LLM.
Repository Health
Technical Analysis
The AI SDK is Vercel’s open-source TypeScript toolkit for building AI-powered applications and agents. It provides a single, unified API for text generation, structured output, image/speech/video generation, embeddings, and reranking across dozens of model providers (OpenAI, Anthropic, Google, xAI, and more), so switching providers or models is a one-line change rather than a rewrite.
Beyond the core generation functions, the SDK ships framework-agnostic UI hooks (@ai-sdk/react, @ai-sdk/vue, @ai-sdk/svelte, @ai-sdk/angular) for building chat and generative interfaces, a ToolLoopAgent abstraction for building tool-using agents, and first-class support for streaming, tool calling, and the Model Context Protocol (MCP). It is maintained by the Next.js/Vercel team and used across a large ecosystem of provider and framework integration packages published under the @ai-sdk/* namespace.
What You Get
- Unified
generateText/streamText/generateObjectAPIs that work identically across OpenAI, Anthropic, Google, xAI, Groq, Mistral, and dozens of other providers - A
ToolLoopAgentclass for building tool-calling agents with structured tool definitions, approval flows, and streaming UI message output - Framework-agnostic UI hooks (
@ai-sdk/react,@ai-sdk/vue,@ai-sdk/svelte,@ai-sdk/angular) for wiring chat and generative UI into any frontend - Built-in Model Context Protocol (MCP) client support for connecting agents to external tool servers
- First-class Zod/Valibot schema integration for structured output and typed tool inputs/outputs
- Access to the Vercel AI Gateway by default, or direct provider SDKs installed independently (
@ai-sdk/openai,@ai-sdk/anthropic, etc.)
Common Use Cases
- Building a chatbot or conversational UI with streaming responses in a Next.js, React, Vue, or Svelte app
- Generating structured JSON output (e.g. extracting data, generating recipes/forms) validated against a Zod schema
- Building tool-using agents that call external APIs, run code in a sandbox, or query internal systems
- Swapping between LLM providers (OpenAI, Anthropic, Google) without rewriting application logic
- Adding AI image, speech, or video generation to a product using a consistent API across providers
Under The Hood
Architecture: The repo is a pnpm/Turborepo monorepo with the ai core package (packages/ai/src) built around directory-scoped modules — generate-text, generate-object, generate-image, generate-speech, generate-video, embed, rerank, agent, middleware, registry, ui, ui-message-stream, realtime, and telemetry. Every generation function resolves a caller-supplied model string or instance through model/resolve-model.ts into a versioned LanguageModelV3/V4 (or embedding/image/speech/video equivalent) contract defined in the separate @ai-sdk/provider package, then normalizes provider-specific quirks via adapter functions like as-language-model-v4.ts. This adapter-and-versioned-contract layering is what lets generateText({ model: 'openai/gpt-5.4' }) and generateText({ model: anthropic('claude-opus-4-6') }) share identical downstream logic. The agent/tool-loop-agent.ts module builds a stateful tool-calling loop on top of generate-text, and ui-message-stream bridges that loop to framework hooks (@ai-sdk/react’s useChat) over a typed streaming protocol.
Tech Stack: Pure TypeScript (81% of the codebase) built with tsup, type-checked via tsc --build project references, and tested with Vitest across separate Node and edge-runtime configs (vitest.node.config.js / vitest.edge.config.js) to guarantee edge-runtime compatibility. The workspace uses pnpm workspaces plus Turborepo for task orchestration across ~80 packages, Changesets for versioned releases, and oxlint/ultracite for linting. Zod (with Valibot as an alternative) is a peer dependency used throughout for schema validation of structured output and tool I/O.
Code Quality: The ai package alone has 127 *.test.ts/*.test-d.ts files (colocated with source, including type-level tests via test-d.ts and snapshot tests), covering tool execution, streaming, schema resolution, and error paths explicitly — errors are modeled as typed classes under src/error/ rather than thrown generically. Naming is consistent (generate-*, stream-*, as-*-model-v*) and modules are small and single-purpose, which keeps the large surface area navigable despite the monorepo’s size.
API Design: The public API is deliberately minimal at the entry point — a handful of verbs (generateText, streamText, generateObject, embed, tool) cover the majority of use cases, with provider selection reduced to a model string or a one-line import { anthropic } from '@ai-sdk/anthropic'. Getting started requires only npm install ai plus one provider package; the README’s own quickstart is under 10 lines of code. Consistent naming conventions across sibling functions (generateImage/generateSpeech/generateVideo mirroring generateText) minimize the learning curve for anyone who has used one function in the family.
Used by 101 apps in this directory
Activepieces
Automation · AI Assistants
Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.
Agent Lightning
AI Development
A Microsoft-built training framework that optimizes AI agents with reinforcement learning, automatic prompt optimization, or supervised fine-tuning — with near-zero code changes to your existing agent, in any framework.
agenta
Developer Tools · Devops · AI Development
The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.
agentic-inbox
AI Agents · Productivity
A self-hosted email client with an AI agent that reads your inbox, drafts replies automatically, and exposes full email operations over MCP — running entirely on Cloudflare Workers.
Amical
Note Taking · AI Assistants
Local-first AI dictation that understands your active app — private, offline, and built for speed.
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
AutoGPT
Automation · Productivity · AI Assistants
Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.
Blinko
Knowledge Management · Note Taking
A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.
BrowserOS
Browser · AI Assistants
The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.