Framework · Vercel
Tổng quan về Vercel AI SDK
Bộ công cụ TypeScript không phụ thuộc nhà cung cấp của Vercel, trong đó ToolLoopAgent là lớp agent chính kể từ AI SDK 7. Bộ công cụ này kết hợp vòng lặp tool với các helper giao diện streaming; WorkflowAgent bổ sung các lượt chạy có thể tiếp tục sau khi khởi động lại.
Phù hợp nhất với: Nhà phát triển Next.js và web muốn dùng agent vòng lặp tool tích hợp chặt chẽ với giao diện streaming.
Thông tin chính
- Đơn vị duy trì
- Vercel
- Ngôn ngữ
- TypeScript
- Giấy phép
- Apache-2.0
- Phiên bản mới nhất
ai 7.0.126· 30 tháng 9, 2026- Repository
- vercel/ai
- Tùy chọn chạy trên nền tảng lưu trữ
- Vercel Functions + Vercel Workflow
Bắt đầu nhanh
Cài package, thiết lập thông tin xác thực, rồi chạy agent đơn giản nhất theo tài liệu chính thức. ID model sử dụng trong tài liệu có thể chưa được bật cho tài khoản của bạn.
npm install ai zod (inferred; not copied from docs)import { ToolLoopAgent, tool } from 'ai';
import { z } from 'zod';
const weatherAgent = new ToolLoopAgent({
model: "anthropic/claude-sonnet-5.5",
tools: {
weather: tool({
description: 'Get the weather in a location (in Fahrenheit)',
inputSchema: z.object({
location: z.string().describe('The location to get the weather for'),
}),
execute: async ({ location }) => ({
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
}),
}),
convertFahrenheitToCelsius: tool({
description: 'Convert temperature from Fahrenheit to Celsius',
inputSchema: z.object({
temperature: z.number().describe('Temperature in Fahrenheit'),
}),
execute: async ({ temperature }) => {
const celsius = Math.round((temperature - 32) * (5 / 9));
return { celsius };
},
}),
},
});
const result = await weatherAgent.generate({
prompt: 'What is the weather in San Francisco in celsius?',
});
console.log(result.text); // agent's final answer
console.log(result.steps); // steps taken by the agentTính năng
| Mọi model | Có | Dùng bất kỳ package provider nào hoặc chuỗi AI Gateway như anthropic/claude-sonnet-5.5 |
|---|---|---|
| MCP client | Có | client @ai-sdk/mcp |
| MCP server | Chưa xác nhận | |
| Đa agent | Có | Subagent; HarnessAgent chạy Claude Code, Codex hoặc Pi |
| Lượt chạy bền vững | Có | WorkflowAgent, cần bản beta Workflow 5 |
| Phê duyệt của con người | Có | toolApproval với phê duyệt ký bằng HMAC và chính sách OPA |
| Tracing | Chưa xác nhận | |
| Evals | Chưa xác nhận |
Các thay đổi gần đây
- AI SDK 7 chọn ToolLoopAgent làm lớp agent được khuyến nghị.
- HarnessAgent chạy Claude Code, Codex hoặc Pi làm agent.
- WorkflowAgent (@ai-sdk/workflow) thay thế DurableAgent của Workflow DevKit.
- runtimeContext và toolsContext thay thế experimental_context.