AI Gateway 现已支持类型安全客户端以及针对 Jev 的 HTTP API。
在 Vercel AI Gateway 上体验 Jev
让你的应用更快地决定下一步该做什么。用 Jev 来路由请求、标记内容和评估优先级。
立即上手
现在,除了 AI SDK 之外,你还可以通过现有的 TypeSafe 客户端或 HTTP API,在 AI Gateway 上调用 Jev from TypeSafe AI。
TypeSafe 客户端:把现有的 TypeSafe 客户端指向 AI Gateway,无需改动任何评估调用代码。
HTTP API:直接用任意语言或框架调用 Jev。
AI SDK:在 TypeScript 应用中通过 AI SDK 调用 Jev。
Jev 是一个面向软件的概率决策模型。输入状态,输出带概率的类型化答案,无需解析任何生成的文本。三种调用方式的请求都通过 AI Gateway 计费,会在用量统计和可观测性面板中与其他模型调用并列显示。
Copy link to heading迁移现有的 TypeSafe 客户端
只需修改 base URL 和 API key。systemOne 调用、noul 问题以及响应结构都保持原样。
1import { TypeSafeClient } from '@typesafe-ai/sdk';2
3const client = new TypeSafeClient({4 apiKey: process.env.AI_GATEWAY_API_KEY,5 baseURL: 'https://ai-gateway.vercel.sh/typesafe',6});7
8const result = await client.systemOne({9 state: 'The agent fixed the checkout bug and all tests pass.',10 questions: {11 continueWorking: {12 type: 'noul',13 instructions: 'Should the agent take another step?',14 },15 },16});17
18const shouldContinue = result.answers.continueWorking.noul >= 0.8;把现有的 TypeSafe 客户端接入 AI Gateway,评估调用一行都不用改。
Copy link to heading开始新的集成
新集成将模型命名为 typesafe-ai/jev,并支持三种问题类型:boolean 返回 0 到 1 之间的概率,choice 从你指定的选项集中选出一个,score 按你定义的量表打分。下面的示例是询问 agent 在修复 bug 并通过测试后是否继续工作。
使用 HTTP API,向 /v1/evaluate 发送 POST 请求:
1curl https://ai-gateway.vercel.sh/v1/evaluate \2 -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "typesafe-ai/jev",6 "state": "The agent fixed the checkout bug and all tests pass.",7 "questions": {8 "continueWorking": {9 "type": "boolean",10 "instructions": "Should the agent take another step?"11 }12 }13 }'
通过原生 HTTP API 询问 Jev,判断智能体是否应继续工作。
使用 AI SDK,通过 evaluate 执行相同的评估:
1import { experimental_evaluate as evaluate } from 'ai';2
3const result = await evaluate({4 model: 'typesafe-ai/jev',5 state: 'The agent fixed the checkout bug and all tests pass.',6 questions: {7 continueWorking: {8 type: 'boolean',9 instructions: 'Should the agent take another step?',10 },11 },12});13
14const shouldContinue =15 result.answers.continueWorking.probability >= 0.8;
在 TypeScript 应用程序中使用 AI SDK 执行相同的评估。
你也可以通过 eve 使用 Jev。这是一个用于构建和部署智能体的框架,内置了沙箱计算、人工审批和评估功能。eve 将 Jev 作为默认评估模型,用于自动模型选择、类型化评估和自动工具审批。
请参阅TypeSafe 兼容 API 指南以迁移客户端,或查看评估指南了解 HTTP API 或AI SDK。