AI SDK

Provider-agnostic TypeScript toolkit for building AI apps and agents with any LLM.

Library
npm
v7.0.137
27,217 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 100
Maintenance 100
Community 76
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
91 /100 Excellent
Architecture 92
Code Quality 90
Innovation 90
Learning Curve 90

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/generateObject APIs that work identically across OpenAI, Anthropic, Google, xAI, Groq, Mistral, and dozens of other providers
  • A ToolLoopAgent class 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 581 apps in this directory

TypeScript
100%
MIT

JobSync

AI Assistants · Productivity

1,329

The self-hosted job search assistant that tracks applications, reviews resumes with AI, and auto-discovers matching roles from Greenhouse, Lever, and Ashby boards — all while keeping your data on your own server.

View details
84
Repo Health
79
Technical
81
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
TypeScript
100%
MIT

JobSync

AI Assistants · Productivity

1,329

The self-hosted job search assistant that tracks applications, reviews resumes with AI, and auto-discovers matching roles from Greenhouse, Lever, and Ashby boards — all while keeping your data on your own server.

View details
84
Repo Health
79
Technical
81
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Karakeep

Bookmarks Archiving

29,321

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,301

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,301

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,603

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
66
Repo Health
85
Technical
72
Dependency
Built with
TypeScript 84%
Updated 4 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,603

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
66
Repo Health
85
Technical
72
Dependency
Built with
TypeScript 84%
Updated 4 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,603

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
66
Repo Health
85
Technical
72
Dependency
Built with
TypeScript 84%
Updated 4 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,603

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
66
Repo Health
85
Technical
72
Dependency
Built with
TypeScript 84%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers