项目介绍
Agent 开发框架 · 2026-11-09 更新 · 本站尚未实测
AI SDK 是 Vercel 提供的、与模型提供商无关的 TypeScript 工具包,用于构建 AI 应用与 Agent,并可与 Next.js、React、Svelte、Vue、Angular 等界面框架以及 Node.js 运行时配合使用。根据仓库描述,它是由 Next.js 团队推出的自由开源库,仓库当前未被归档。
需要说明的是:它是一个开发库/框架,并非可直接下载运行的 Agent 成品,也不是 MCP 服务器或工作流文件。所谓“Agent”能力,是指开发者用库中提供的 ToolLoopAgent 等接口自行编写实现。仓库 README 中出现的模型名称属于示例代码,请以官方文档和实际账户可用的模型为准。
核心能力
点击能力名称查看输入、输出和原文依据。
- 统一提供商接口:通过一个 API 与 OpenAI、Anthropic、Google 等提供商交互,也可以直接安装并使用各家的独立 SDK 包(如
@ai-sdk/openai、@ai-sdk/anthropic、@ai-sdk/google)。 - 默认使用 Vercel AI Gateway:README 说明默认经由 Vercel AI Gateway 访问主要提供商,传入模型字符串即可调用。
- 文本生成与结构化输出:提供
generateText等接口,可配合Output.object与 Zod schema 生成结构化数据。 - 工具调用与 Agent 循环:提供
ToolLoopAgent,可把本地 shell、图像生成等工具挂载到 Agent 上。 - 前端集成:AI SDK UI 模块提供一套与框架无关的 hooks,可用来构建聊天机器人和生成式界面,例如
@ai-sdk/react。 - 面向编码 Agent 的 Skill:可通过
npx skills add vercel/ai为 Claude Code、Cursor 等编码工具补充 AI SDK 使用知识(该 Skill 仅是辅助编码的资料,并非 Agent 本体)。 - 模板:官方提供覆盖不同用例、提供商与框架的集成模板。
实际应用场景
适用场景
适合需要在 TypeScript/JavaScript 项目中统一接入多家大模型、把工具调用组织成 Agent 循环、或为网页构建流式聊天与生成式界面的开发者。也适合已经使用 Next.js 或 React 技术栈、希望参考官方模板快速起步的团队。若目标只是“找一个开箱即用的 Agent 助手”,本项目并不直接满足需求。
安装与接入
前置条件(原文要求):本地开发机安装 Node.js 22+ 以及 npm 或其他包管理器。
安装核心包:
npm install ai
按需安装提供商包:
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
按需安装界面包(示例为 React):
npm install @ai-sdk/react
为编码 Agent 添加 Skill:
npx skills add vercel/ai
使用条件与限制
- 是否需要部署
- 需自行准备运行环境,具体要求见正文
- 是否需要注册
- 账号和认证要求见正文;未明确说明的项目仍待核验
- 是否需要 API Key
- 待核验
- 费用与额度
- 费用边界见正文,项目许可不代表模型或托管服务免费
- 所需权限
- 待核验
- 许可证与服务条款
- 待核验
权限费用与限制
- 库本身以 Apache-2.0 许可发布(见仓库 LICENSE),但公开源码不等于模型调用免费。
- README 说明默认使用 Vercel AI Gateway,这属于 Vercel 的托管服务,其可用性、计费方式、额度与所在区域均未在资料中说明,需向官方核验。
- 直接对接 OpenAI、Anthropic、Google 等提供商同样需要各自的 API Key 与账户余额,费用规则由各提供商决定,本资料未给出价格。
- 示例中的 shell 工具依赖 Vercel Sandbox 等外部环境,实际部署时需要自行准备,README 未给出完整安全边界说明。
- 对延迟、并发、数据留存和合规等方面的承诺,资料未涉及,待核验。
国内使用情况
网友核验 用户经验分享
与站长实测独立,不代表官方认证或本站已实测。
最近核验:暂无有效核验。参与人数按当前项目有效身份去重;不同核验项分别统计,不合并成用户总结果。仅统计审核通过且未过期的记录。
分项统计、有效期与样本量
| 核验项目 | 有效人数 | 成功 / 部分 / 失败 / 无法判断 | 成功率 | 最近核验 / 有效期 |
|---|---|---|---|---|
| 官方网站访问 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| GitHub 仓库访问 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| 安装与运行 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 官方服务国内连接 / MCP 连接 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 国内网络情况 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| 国内模型兼容性 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 自定义 API | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 海外服务依赖 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 海外账号要求 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 中文界面 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 客户端兼容性 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 账号及费用信息 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
成功率 = 成功 ÷(成功 + 部分成功 + 失败);无法判断不计入分母。至少 5 份可判断结果才显示成功率。账号、费用、海外依赖与语言等事实项,成功表示核查结论与资料吻合,具体观察另行统计;不表示免费或没有海外依赖。不同网络、客户端和版本的结果不能直接等同。
最近有效核验
暂无审核通过且未过期的网友核验。欢迎提交真实使用记录。
查看全部有效核验 →国内实测状态:国内可用性待核验。协议兼容和官方资料说明不等于国内网络可用。
- 官方网站访问
- 尚未实测 待核验
- GitHub 仓库访问
- 尚未实测 待核验
- 官方服务国内连接
- 尚未实测 待核验
- 国内网络情况
- 尚未实测 待核验
- 国内模型兼容性
- 尚未实测 待核验
- 自定义 API
- 尚未实测 待核验
- 海外服务依赖
- 尚未实测 待核验
- 海外账号要求
- 尚未实测 待核验
- 中文界面
- 尚未实测 待核验
- 国内最后核验时间
- 尚未实测
许可与国内使用
仓库代码依据 LICENSE 文件以 Apache License 2.0 授权,允许在遵守许可条款的前提下使用与再分发。商业托管服务(如 Vercel AI Gateway)、第三方模型服务与模板资产是否采用不同条款,需分别核验,不能一概视为开源免费。
关于国内网络可用性、境内访问稳定性以及是否支持国内模型提供商,本次提供的 README 仅列出 OpenAI、Anthropic、Google 等,并未提及任何国内模型,也未说明在中国大陆的可用性,以上均待核验。不要据此推断其可直接在国内合规使用。
项目资料与来源
字段依据与待核验事项
access:来源确认 · npm install ai
project_type:来源确认 · is a provider-agnostic TypeScript toolkit designed to help you build AI-powered applications and agents
原始 README(折叠技术参考)

# AI SDK
The [AI SDK](https://ai-sdk.dev/docs) is a provider-agnostic TypeScript toolkit designed to help you build AI-powered applications and agents using popular UI frameworks like Next.js, React, Svelte, Vue, Angular, and runtimes like Node.js.
To learn more about how to use the AI SDK, check out our [API Reference](https://ai-sdk.dev/docs/reference) and [Documentation](https://ai-sdk.dev/docs).
## Installation
You will need Node.js 22+ and npm (or another package manager) installed on your local development machine.
```shell
npm install ai
```
## Skill for Coding Agents
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
```shell
npx skills add vercel/ai
```
## Unified Provider Architecture
The AI SDK provides a [unified API](https://ai-sdk.dev/docs/foundations/providers-and-models) to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google), and [more](https://ai-sdk.dev/providers/ai-sdk-providers).
By default, the AI SDK uses the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) to give you access to all major providers out of the box. Just pass a model string for any supported model:
```ts
const result = await generateText({
model: 'anthropic/claude-opus-5.5', // or 'openai/gpt-6-astra', 'google/gemini-3.8-flash', etc.
prompt: 'Hello!',
});
```
You can also connect to providers directly using their SDK packages:
```shell
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
```
```ts
import { anthropic } from '@ai-sdk/anthropic';
const result = await generateText({
model: anthropic('claude-opus-5-5'), // or openai('gpt-6-astra'), google('gemini-3.8-flash'), etc.
prompt: 'Hello!',
});
```
## Usage
### Generating Text
```ts
import { generateText } from 'ai';
const { text } = await generateText({
model: 'openai/gpt-6-astra', // use Vercel AI Gateway
prompt: 'What is an agent?',
});
```
### Generating Structured Data
```ts
import { generateText, Output } from 'ai';
import { z } from 'zod';
const { output } = await generateText({
model: 'openai/gpt-6-astra',
output: Output.object({
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(
z.object({ name: z.string(), amount: z.string() }),
),
steps: z.array(z.string()),
}),
}),
}),
prompt: 'Generate a lasagna recipe.',
});
```
### Agents
```ts
import { ToolLoopAgent } from 'ai';
const sandboxAgent = new ToolLoopAgent({
model: 'openai/gpt-6-astra',
system: 'You are an agent with access to a shell environment.',
tools: {
shell: openai.tools.localShell({
execute: async ({ action }) => {
const [cmd, ...args] = action.command;
const sandbox = await getSandbox(); // Vercel Sandbox
const command = await sandbox.runCommand({ cmd, args });
return { output: await command.stdout() };
},
}),
},
});
```
### UI Integration
The [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, and Vue.
You need to install the package for your framework, e.g.:
```shell
npm install @ai-sdk/react
```
#### Agent @/agent/image-generation-agent.ts
```ts
import { openai } from '@ai-sdk/openai';
import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
export const imageGenerationAgent = new ToolLoopAgent({
model: 'openai/gpt-6-astra',
tools: {
generateImage: openai.tools.imageGeneration({
partialImages: 3,
}),
},
});
export type ImageGenerationAgentMessage = InferAgentUIMessage<
typeof imageGenerationAgent
>;
```
#### Route (Next.js App Router) @/app/api/chat/route.ts
```tsx
import { imageGenerationAgent } from '@/agent/image-generation-agent';
import { createAgentUIStreamResponse } from 'ai';
export async function POST(req: Request) {
const { messages } = await req.json();
return createAgentUIStreamResponse({
agent: imageGenerationAgent,
messages,
});
}
```
#### UI Component for Tool @/component/image-generation-view.tsx
```tsx
import { openai } from '@ai-sdk/openai';
import { UIToolInvocation } from 'ai';
export default function ImageGenerationView({
invocation,
}: {
invocation: UIToolInvocation<ReturnType<typeof openai.tools.imageGeneration>>;
}) {
switch (invocation.state) {
case 'input-available':
return <div>Generating image...</div>;
case 'output-available':
return <img src={`data:image/png;base64,${invocation.output.result}`} />;
}
}
```
#### Page @/app/page.tsx
```tsx
'use client';
import { ImageGenerationAgentMessage } from '@/agent/image-generation-agent';
import ImageGenerationView from '@/component/image-generation-view';
import { useChat } from '@ai-sdk/react';
export default function Page() {
const { messages, status, sendMessage } =
useChat<ImageGenerationAgentMessage>();
const [input, setInput] = useState('');
const handleSubmit = e => {
e.preventDefault();
sendMessage({ text: input });
setInput('');
};
return (
<div>
{messages.map(message => (
<div key={message.id}>
<strong>{`${message.role}: `}</strong>
{message.parts.map((part, index) => {
switch (part.type) {
case 'text':
return <div key={index}>{part.text}</div>;
case 'tool-generateImage':
return <ImageGenerationView key={index} invocation={part} />;
}
})}
</div>
))}
<form onSubmit={handleSubmit}>
<input
value={input}
onChange={e => setInput(e.target.value)}
disabled={status !== 'ready'}
/>
</form>
</div>
);
}
```
## Templates
We've built [templates](https://ai-sdk.dev/docs/introduction#templates) that include AI SDK integrations for different use cases, providers, and frameworks. You can use these templates to get started with your AI-powered application.
## Community
The AI SDK community can be found on [the Vercel Community](https://community.vercel.com/c/ai-sdk/62) where you can ask questions, voice ideas, and share your projects with other people.
## Contributing
Contributions to the AI SDK are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](https://github.com/vercel/ai/blob/main/CONTRIBUTING.md) to make sure you have smooth experience contributing to AI SDK.
## Authors
This library is created by [Vercel](https://vercel.com) and [Next.js](https://nextjs.org) team members, with contributions from the [Open Source Community](https://github.com/vercel/ai/graphs/contributors).
历史前置条件说明(补充参考)
Node.js 22+ 与 npm 或其他包管理器;需要模型提供商 API Key 或经由 Vercel AI Gateway 访问(默认路径),具体凭据配置待核验;模型调用与托管网关费用未在资料中给出,需向官方核验;是否依赖境外服务及境内可用性待核验。
项目来源与清单版权许可
https://vercel.com/blog/introducing-the-vercel-ai-sdk
https://github.com/vercel/ai/tree/main/examples
整理来源:https://github.com/slavakurilyak/awesome-ai-agents
清单版权与许可:
MIT License
Copyright (c) 2024 Slava Kurilyak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.