AI SDK
The AI SDK is the TypeScript toolkit designed to help developers build AI-powered applications with Next.js, Vue, Svelte, Node.js, and more. Integrating LLMs into applications is complicated and heavily dependent on the specific model provider you use.
The AI SDK abstracts away the differences between model providers, eliminates boilerplate code for building chatbots, and allows you to go beyond text output to generate rich, interactive components.
At the center of the AI SDK is AI SDK Core, which provides a unified API to call any LLM.
The following example shows how to generate text with the AI SDK using OpenAI's GPT-5:
The unified interface means that you can easily switch between providers by changing just two lines of code. For example, to use Anthropic's Claude Sonnet 3.7:
While text generation can be useful, you might want to generate structured JSON data. For example, you might want to extract information from text, classify data, or generate synthetic data. AI SDK Core provides two functions ( and ) to generate structured data, allowing you to constrain model outputs to a specific schema.
The following example shows how to generate a type-safe recipe that conforms to a zod schema:
The AI SDK supports tool calling out of the box, allowing it to interact with external systems and perform discrete tasks. The following example shows how to use tool calling with the AI SDK:
The AI SDK is available as a package. To install it, run the following command:
See the AI SDK Getting Started guide for more information on how to get started with the AI SDK.
Was this helpful?