Getting Started with the Vercel AI SDK
The Vercel AI SDK is an open-source library for building AI features in JavaScript and TypeScript applications. It gives you a consistent API for model calls, streaming, embeddings, structured output and tool use across multiple providers.
This series of articles will guide you through the core concepts and features of the SDK, from basic text generation to building complex, autonomous agents.
Core Text Generation (generateText)
The most basic feature of any AI SDK is text generation. The Vercel AI SDK exposes this through generateText, with a unified API for providers like OpenAI, Anthropic and Google.
For a complete guide on how to get the most out of your models with carefully crafted instructions, see our article on Prompt Engineering.
From Text to Meaning: Embeddings (embed)
To build features like semantic search or recommendations, you need to go beyond simple text generation. Embeddings are numerical representations of text that capture semantic meaning. The SDK's embed and embedMany functions handle the model call and return those vectors.
Learn how to convert text into meaning and build a simple semantic search engine in our Embeddings article.
Giving Your AI a Library: RAG
Retrieval-Augmented Generation (RAG) lets your AI retrieve information from your own documents before answering a question. This helps reduce hallucinations and lets the model use private or up-to-date information.
Discover how to build a RAG pipeline from scratch in our guide: RAG: Giving Your AI an Open-Book Exam.
From Answering to Doing: Agents
An AI agent is a system that can reason, plan and use tools to complete a task. The SDK gives you the building blocks for connecting models to functions, APIs and application state.
First, understand the high-level concepts in Agentic AI: The Shift from Answering to Accomplishing, then learn how to implement one in Building AI Agents.
Generating Interactive UI (streamUI)
For React Server Components, AI SDK RSC exposes streamUI, which can stream React components from a server action while a model uses tools. It is experimental, so for production systems it is worth comparing it with structured output patterns using generateObject or streamObject.
See how to turn natural language into user interfaces in our article on UI Generation.
Creating a Specialist: Fine-Tuning
When you need to change the behaviour of a model, for example to teach a specific tone, style or task format, fine-tuning can help. It is not the first tool I would reach for, but it is useful when prompting and retrieval are not enough.
Learn the workflow and best practices in Fine-Tuning: Giving Your AI a PhD.
Ensuring Quality: Evals
How do you know if your changes are making your AI better or worse? Evaluations are like unit tests for your AI systems. They provide a framework for "grading" your model's performance on a standardized set of test cases, ensuring quality and preventing regressions.
Learn how to build your own evaluation suite in AI Evals: Grading Your Model's Homework.