Key takeaways
- The AI SDK offers provider-agnostic functions like streamText and generateObject, plus UI hooks like useChat.
- Install ai with a provider package such as @ai-sdk/openai, and keep keys on the server.
- It is Apache 2.0 open source, first released in June 2023, and TypeScript only.
- Use the AI SDK for TypeScript product UIs, LangChain for broad integrations, and Genkit for Firebase stacks.
- Custom endpoints work through OpenAI-compatible providers or the SDK's stream protocol.
The Vercel AI SDK is an open-source TypeScript toolkit for building AI features: one API to call many model providers, stream responses, generate structured objects, use tools, and connect everything to React and other frontends with hooks such as useChat. I build AI products with Next.js and FastAPI, so this page explains how it works, installation, licence and history, Python support, comparisons with LangChain, Genkit and AG-UI, streaming from custom endpoints, and a short tutorial.
How does the Vercel AI SDK work?
AI SDK Core gives you provider-agnostic functions, such as generateText, streamText and generateObject, that call any supported model through provider packages. AI SDK UI adds framework hooks, such as useChat, that consume streamed responses in the browser.
Also asked as: how does vercel ai sdk work · agui vs vercel ai sdk
On the server, you call streamText with a model from a provider package, such as OpenAI or Anthropic, plus messages and optional tools, and return the result as a streaming response. On the client, useChat sends messages to that route, renders tokens as they arrive, and manages chat state. Tools are defined with Zod schemas, and structured outputs are validated automatically. Switching providers means changing one import, which makes model comparisons and fallbacks easy.
How do you install the Vercel AI SDK?
Install the core package and a provider: npm install ai @ai-sdk/openai, or use the Anthropic or Google provider packages instead. For React hooks, add @ai-sdk/react. Set your provider API key in an environment variable.
Also asked as: how to install vercel ai sdk
In a Next.js app, create an API route that imports streamText and your provider, reads messages from the request, and returns a streaming response; then build a client component using useChat. The SDK works with Next.js, SvelteKit, Nuxt, Node.js servers and edge runtimes. Keep API keys on the server only. Check the documentation for your installed major version, since APIs changed between versions, for example in how streaming responses are returned. Pin versions in package.json to avoid surprises.
Is the Vercel AI SDK open source?
Yes. The AI SDK is open source under the Apache 2.0 licence, developed in the vercel/ai repository on GitHub. You can use it in any project and deploy anywhere, not only on Vercel's platform.
Also asked as: is vercel ai sdk open source
Its providers cover OpenAI, Anthropic, Google, Mistral, Groq, Amazon Bedrock, Azure and many more, plus community providers for others, including OpenAI-compatible endpoints and local models through Ollama community packages. Open source means you can inspect how streaming and tool calls work, contribute fixes, or fork if needed. Vercel offers related paid hosting products, such as an AI gateway, but the SDK itself does not require them. Licence terms of the models you call still apply separately.
When was the Vercel AI SDK released?
Vercel released the AI SDK in June 2023, initially focused on streaming chat responses into React and other frameworks. It has since gone through several major versions adding tools, structured outputs and agents.
Also asked as: when was vercel ai sdk released
Notable milestones include version 3 in 2024, which introduced generative UI ideas with React Server Components, version 4 with improved provider support, and version 5 in 2025, which redesigned the UI message format and transport layer for more flexible streaming and agent workflows. Because APIs evolve, tutorials from 2023 or early 2024 may use outdated functions, such as older stream helpers. Always check the documentation matching your installed major version before copying examples.
Does the Vercel AI SDK support Python?
No. The AI SDK is a TypeScript and JavaScript library. There is no official Python version, but a Python backend can still serve a frontend that uses the AI SDK's React hooks by streaming in a compatible protocol.
Also asked as: does vercel ai sdk support python
For example, a FastAPI backend can call models with Python SDKs and stream responses in the AI SDK's stream protocol, and a Next.js frontend can use useChat pointed at that endpoint. Vercel has published templates combining Next.js with a Python backend in this way. If your stack is fully Python, use Python libraries instead, such as provider SDKs, LangChain, LlamaIndex or PydanticAI, and a Python web framework for streaming.
LangChain vs Vercel AI SDK: which should you use?
Use the AI SDK for TypeScript apps that need clean model calls, streaming, tools and chat UIs with minimal abstraction. Use LangChain or LangGraph when you need many integrations, such as document loaders and vector stores, or complex agent graphs.
The AI SDK is lighter and closer to the provider APIs, with excellent frontend integration, which suits product teams shipping chat and generative UI features in Next.js. LangChain.js offers a broader ecosystem for RAG pipelines and agent orchestration, plus LangSmith tracing. They can be combined: use LangChain for retrieval and the AI SDK for streaming responses to the UI. For Python backends, LangChain is the more natural choice, since the AI SDK is TypeScript only.
Genkit vs Vercel AI SDK: what is the difference?
Genkit is Google's open-source framework for building AI features, with flows, a local developer UI for testing and tracing, and strong Firebase and Google Cloud integration. The AI SDK focuses on provider-agnostic model calls and frontend streaming hooks.
Genkit supports TypeScript and Go, with Python support emerging, and offers plugins for many models, including Gemini, plus evaluation and observability tooling. The AI SDK excels in React and Next.js user interfaces, with useChat and structured streaming. Choose Genkit if you build on Firebase or Google Cloud and want built-in flow tooling; choose the AI SDK for frontend-heavy web apps with many providers. Both are open source, so trying each on a small feature is easy.
AG-UI vs Vercel AI SDK: how do they differ?
AG-UI, the Agent-User Interaction protocol introduced by CopilotKit in 2025, is an open protocol standardising the events streamed between agent backends and user interfaces. The AI SDK is a library with its own streaming protocol and UI hooks.
AG-UI defines event types such as text messages, tool calls, state updates and lifecycle events, so frontends can work with agents built in different frameworks, including LangGraph, CrewAI and others. The AI SDK provides a complete toolkit, from model calls to UI hooks, within its own ecosystem. If you connect a frontend to several agent frameworks, a shared protocol like AG-UI helps; if you build the whole stack in TypeScript, the AI SDK alone is simpler.
Can you use Vercel AI SDK streaming with a custom endpoint?
Yes. Point useChat at your own API route, through its endpoint or transport option, and return a response in the SDK's stream protocol, or a plain text stream. Any backend language can produce this format.
Also asked as: is it possible to use vercel ai sdk streaming with a custom endpoint
For a model server with an OpenAI-compatible API, such as a self-hosted model or proxy, create a provider with a custom baseURL using the OpenAI-compatible provider package, then use streamText as usual. For a fully custom backend, implement the documented stream protocol events for text, tool calls and finish signals. Test with network tools to check that chunks arrive incrementally, and disable proxy buffering, since some servers buffer responses and break streaming.
What is a good Vercel AI SDK tutorial?
Start with the official getting-started guides on the AI SDK website for your framework, such as the Next.js App Router, which walk through a streaming chatbot in a few files. Then follow guides on tools, structured outputs and RAG.
A practical path: build a chat route with streamText and a page with useChat; add a weather or calculator tool to learn tool calling; use generateObject with a Zod schema to extract structured data; then add retrieval over your documents with embeddings and a vector store. Vercel's templates and examples repository provide complete starter apps. Deploy early, add rate limiting and logging, and test providers side by side by swapping one import.




