# Vercel AI SDK
The Vercel AI SDK is an open-source [[TypeScript]] / [[JavaScript]] toolkit for building AI applications, published by Vercel. Its job is the unglamorous middle layer ; one consistent shape for "talk to a model, get tokens / tool calls / structured output back" across every major provider, with first-class streaming, tool use, and React/Next.js integrations.
It is not an agent harness, not a framework, not a runtime. It is a **provider-neutral, well-typed SDK** that you slot under your own UI or agent loop.
## Why It Won
Three things made it the default in JS-side AI work:
1. **Provider-neutrality** ; one `generateText({ model: anthropic("claude-sonnet-4-6"), prompt: ... })` call works the same against [[OpenAI]], [[Anthropic]], Google, [[Groq]], Cohere, Mistral, [[Vercel AI Gateway]], local Ollama, and dozens more
2. **First-class streaming** ; `streamText`, `streamObject`, and React hooks (`useChat`, `useCompletion`) make token-streaming UIs trivial
3. **Tool use as types** ; declare tools with Zod schemas, get end-to-end typed inputs and outputs, no hand-rolled JSON glue
## Core APIs
- `generateText` ; one-shot completion
- `streamText` ; token-streaming completion
- `generateObject` / `streamObject` ; structured output via Zod schema
- `tool` ; declare a tool the model can call
- `embed` / `embedMany` ; embeddings
- React hooks: `useChat`, `useCompletion`, `useObject`
## Tool Use Pattern
```ts
import { generateText, tool } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";
const result = await generateText({
model: anthropic("claude-sonnet-4-6"),
tools: {
weather: tool({
description: "Get weather for a city",
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => fetchWeather(city),
}),
},
prompt: "What's the weather in Paris?",
});
```
The schema doubles as runtime validation and as the model's tool definition; one source of truth, no drift.
## Where It Shows Up
- **AI-powered web apps**: chat UIs, copilots, content generators on Vercel/Next.js
- **CLI agents and harnesses**: [[Cook AI Agent]] is built on it ; provider neutrality + Bun-friendly bundle made it a natural choice
- **Backends and Edge functions**: same SDK runs on Node, Bun, Deno, [[Cloudflare Workers]], Vercel Edge
## Vercel AI SDK vs Adjacent Tools
- **vs raw [[OpenAI]] / [[Anthropic]] SDKs**: the official SDKs are model-vendor specific; the Vercel AI SDK is the polyglot layer on top
- **vs LangChain / LlamaIndex**: those are *frameworks* ; opinionated, heavyweight, tied to chains/agents. The Vercel AI SDK stays a thin SDK and lets you build the framework yourself if you need one
- **vs [[Claude Code SDK]] / [[GitHub Copilot SDK]]**: those embed an *entire production agent runtime* (plan, tool, edit, exec). The Vercel AI SDK gives you the model layer and you build the runtime
- **vs [[Vercel AI Gateway]]**: the Gateway is a hosted *proxy* that handles auth/rate-limit/cost/observability across providers; the SDK is the *client* that talks to it (or directly to providers)
## License & Repo
MIT-licensed. Source at https://github.com/vercel/ai. Published as `ai` (core) plus per-provider packages like `@ai-sdk/anthropic`, `@ai-sdk/openai`, `@ai-sdk/google`, `@ai-sdk/groq`.
## References
- Documentation: https://sdk.vercel.ai/
- GitHub: https://github.com/vercel/ai
- Provider list: https://sdk.vercel.ai/providers/ai-sdk-providers
## Related
- [[AI SDKs]]
- [[Vercel AI Gateway]]
- [[Anthropic]]
- [[OpenAI]]
- [[Groq]]
- [[Claude Code SDK]]
- [[GitHub Copilot SDK]]
- [[Cook AI Agent]]
- [[TypeScript]]
- [[Bun]]