เฟรมเวิร์ก · Vercel
ภาพรวม Vercel AI SDK
ชุดเครื่องมือ TypeScript ที่ไม่ผูกกับ provider ของ Vercel โดย ToolLoopAgent เป็นคลาสเอเจนต์หลักตั้งแต่ AI SDK 7 ชุดเครื่องมือนี้เชื่อม tool loop เข้ากับตัวช่วยสร้าง UI แบบ streaming ส่วน WorkflowAgent เพิ่มการรันงานที่ทำต่อได้หลังรีสตาร์ต
เหมาะสำหรับ: นักพัฒนา Next.js และเว็บที่ต้องการเชื่อมเอเจนต์แบบ tool loop เข้ากับ UI แบบ streaming อย่างใกล้ชิด
ข้อมูลสำคัญ
- ผู้ดูแล
- Vercel
- ภาษา
- TypeScript
- ไลเซนส์
- Apache-2.0
- เวอร์ชันล่าสุด
ai 7.0.126· 30 กันยายน 2569- Repository
- vercel/ai
- ตัวเลือกแบบโฮสต์
- Vercel Functions + Vercel Workflow
Quickstart
ติดตั้งแพ็กเกจ ตั้งค่าข้อมูลรับรอง แล้วเรียกใช้ agent ตัวอย่างที่เล็กที่สุดจากเอกสารทางการ Model ID เป็นค่าที่เอกสารใช้ และอาจยังไม่ได้เปิดใช้งานในบัญชีของคุณ
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 agentฟีเจอร์
| ใช้ได้กับทุกโมเดล | ใช่ | ใช้แพ็กเกจของ provider ใดก็ได้ หรือระบุ string ของ AI Gateway เช่น anthropic/claude-sonnet-5.5 |
|---|---|---|
| MCP client | ใช่ | ไคลเอนต์ @ai-sdk/mcp |
| MCP server | ยังไม่ยืนยัน | |
| หลาย agent | ใช่ | Subagent; HarnessAgent เรียกใช้ Claude Code, Codex หรือ Pi |
| การทำงานต่อเนื่องแบบทนทาน | ใช่ | WorkflowAgent ซึ่งต้องใช้ Workflow 5 beta |
| การอนุมัติโดยมนุษย์ | ใช่ | toolApproval พร้อมการอนุมัติที่ลงนามด้วย HMAC และนโยบาย OPA |
| Tracing | ยังไม่ยืนยัน | |
| Evals | ยังไม่ยืนยัน |
การเปลี่ยนแปลงล่าสุด
- AI SDK 7 กำหนดให้ ToolLoopAgent เป็นคลาส agent ที่แนะนำ
- HarnessAgent ใช้ Claude Code, Codex หรือ Pi เป็น agent
- WorkflowAgent (@ai-sdk/workflow) มาแทน DurableAgent ของ Workflow DevKit
- runtimeContext และ toolsContext มาแทน experimental_context