Full-Code · Agent SDKsactive

Vercel AI SDK

Type: full-code  ·  Vendor: Vercel  ·  Language: TypeScript  ·  License: Apache-2.0  ·  Status: active  ·  Status in practice: mature  ·  First released: 2023-05-23

Links: homepage docs repo

Provide a free, TypeScript-first toolkit that standardises calls to any model provider with a single API for text generation, structured-object generation, streaming UIs, tool-calling, and multi-step agent loops in TypeScript/JavaScript runtimes including browser, Node.js, and Vercel Edge.

Description. The Vercel AI SDK is the Apache-2.0 TypeScript toolkit from Vercel split into AI SDK Core ('A unified API for generating text, structured objects, tool calls, and building agents with LLMs') and AI SDK UI ('A set of framework-agnostic hooks for quickly building chat and generative user interface'). Core exposes generateText, streamText, and the structured-output siblings generateObject / streamObject driven by Zod, Valibot, or JSON Schema. The agent loop is opt-in via stopWhen (default stepCountIs(20)). UI layer ships useChat and useCompletion hooks for React (plus Vue/Svelte equivalents). Designed for edge runtimes alongside Node.js.

Agent loop shape. Imperative TypeScript loop. Caller invokes generateText({ model, tools, stopWhen, ... }) or streamText(...). In each step the model either generates text (loop ends) or calls a tool (executed in-process, observation feeds back in for another generation). Loop terminates when stopWhen is satisfied; default cap stepCountIs(20). No graph DSL, no class hierarchy — just async functions, plain objects, and AbortSignal.

Primary use cases

  • TypeScript agents over multiple LLM providers behind one API
  • streaming chat UIs via useChat / streamText
  • Zod-typed structured outputs
  • MCP tool integration in TypeScript

Key concepts

  • generateText / streamText (docs)Core agent-loop entry points; streamText returns a token stream.
  • tools tool-use (docs)A tool consists of three properties: description, inputSchema (Zod or JSON schema), and execute.
  • stopWhen / stepCountIs step-budget (docs)Loop-termination predicate; stepCountIs(20) is the default safety cap.
  • generateObject + Zod structured-output (docs)Structured-output generation with schema validation.
  • Providers (language model spec) (docs)Standardised interface abstracting provider differences (OpenAI / Anthropic / Google / xAI / Bedrock / Vertex / Gateway).
  • useChat hook (docs)React UI hook for conversational interfaces (framework-agnostic equivalents for Vue/Svelte).
  • AbortSignal / onAbort stop-cancel (docs)Cancellation lifecycle — onAbort fires when streams are aborted via AbortSignal; onFinish is skipped.

Patterns this full-code implements

Neighbourhood

Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.

Instantiates

Anti-patterns avoided

Alternatives & relatives

Listed as alternative by (6)

References

Provenance

  • Last analyzed:
  • Last updated:
  • Verification status: verified