Build AI agents
- constagent=newToolLoopAgent({
- getWeather:tool({
- import { z } from'zod';
- temperature:72,
- Generate structured data
- execute:async ({ location }) => ({
- const { text } =awaitagent.generate({
- model:'anthropic/claude-fable-5.1',
- condition:'sunny',
Add models, tools, and streaming
At the center of the AI SDK is AI SDK Core, which provides a unified API to call any LLM.
Generating text
- Unified provider API. Switch between models by changing two lines of code
- Structured outputs. Generate type-safe JSON with generateObject and streamObject
- Tool calling. Let models interact with external systems
- Streaming first. Stream text, objects, and UI to your frontend
- Framework support. Works with React, Next.js, Vue, Svelte, and Node.js
import { generateText } from'ai';
Paid ads
prompt:'Explain the concept of quantum entanglement.',
The following example shows how to generate text with the AI SDK using OpenAI's GPT-6 Astra:
});
import { generateText } from'ai';
const { text } =awaitgenerateText({
The unified interface lets you switch providers by changing the model string. For example, to use Anthropic's Claude Fable 5.1:
model:'openai/gpt-6-astra',
prompt:'How many people will live in the world in 2040?',
Generating structured data
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 ( generateObject and streamObject) to generate structured data, allowing you to constrain model outputs to a specific schema.
});
model:'anthropic/claude-fable-5.1',
const { text } =awaitgenerateText({
The following example shows how to generate a type-safe recipe that conforms to a zod schema:
recipe:z.object({
schema:z.object({
model:'openai/gpt-6-astra',
const { object } =awaitgenerateObject({
import { z } from'zod';
ingredients:z.array(z.object({ name:z.string(), amount:z.string() })),
}),
}),
name:z.string(),
steps:z.array(z.string()),
import { generateObject } from'ai';
prompt:'Generate a lasagna recipe.',
Give agents tools
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:
Our Services
prompt:'What is the weather like today in San Francisco?',
tools: {
location:z.string().describe('The location to get the weather for'),
const { text } =awaitgenerateText({
}),
import { generateText, tool } from'ai';
location,
Brand & Design
}),
model:'openai/gpt-6-astra',
getWeather:tool({
execute:async ({ location }) => ({
description:'Get the weather in a location',
}),
temperature:72+Math.floor(Math.random() *21) -10,
});
inputSchema:z.object({
import { z } from'zod';
},
Getting started with the AI SDK
See the AI SDK Getting Started guide for more information on how to get started with the AI SDK.
Use Vercel Connect with AI SDK
Vercel Connect supplies short-lived OAuth tokens to MCP clients built with AI SDK, so models can call tools from services such as Linear without storing provider credentials in your application. The connectAuthProvider() helper requests credentials and supports user consent flows.
Use Jev with AI SDK
Learn how to classify, route, and score with Jev and AI SDK, or follow Route form submissions with Jev and AI SDK to build a form router with configurable destinations and a fallback model for uncertain decisions.
npm
Follow Build AI agents with AI Gateway and AI SDK to set up authentication, stream responses, and add tools and model fallbacks.
pnpm i ai
Follow the AI SDK and MCP tutorial to configure Vercel Connect, make MCP tools available to an AI SDK application, and handle tool approval.
Build with a template
Jev, an evaluation model from TypeSafe AI, returns typed choices, scores, and boolean probabilities that your application can use to classify requests, route work, and assess proposed actions. Call Jev through AI Gateway with the experimental evaluate API in AI SDK 7 or later.
Integrations
Start with an AI SDK template to build a chatbot or route form submissions with Jev:
Maintenance
You can reach our customer support team by emailing info@yourcompany.example.com, calling +1 555-555-5556, or using the live chat on our website. Our dedicated team is available 24/7 to assist with any inquiries or issues.
We’re committed to providing prompt and effective solutions to ensure your satisfaction.
We offer a 30-day return policy for all products. Items must be in their original condition, unused, and include the receipt or proof of purchase. Refunds are processed within 5-7 business days of receiving the returned item.

