Hands-on guide to calling Jev through Vercel AI Gateway
The author spent $0.00074 on 45 test calls and shares how to get a key, use experimental_evaluate to write boolean, choice and score decision questions, and three pitfalls to avoid.
不用等,Jev 已经上了 Vercel AI Gateway,我这几天的实测全是这么跑通的。 ① 拿 key Vercel 控制台 → AI Gateway → API Keys → Create API Key 顺手设个 budget 上限,我设的1刀。这东西便宜得离谱,我45条测试一共花了0.00074刀。 key 长这样 vck_xxxx,存进 .env 里叫 AI_GATEWAY_API_KEY,SDK 自己会读。 ② npm i ai,然后就这么几行: import { experimental_evaluate as evaluate } from 'ai' const r = await evaluate({ model: 'typesafe-ai/jev', state: '客户这周发了两次邮件说退款失败,第二封写「这不可接受,我要求升级处理」', questions: { refund: { type: 'boolean', instructions: '客户是否在要求退款?' }, team: { type: 'choice', instructions: '该转给哪个团队?', criteria: { billing: '扣费、发票、退款相关', technical: '报错、功能故障', sales: '询价、升级套餐', }, }, }, }) console.log(r.answers) 它不是 chat 接口,没有 messages。state 放状态,questions 放你要它判的题,三种题型 boolean / choice / score,返回的是类型化答案加每个选项的概率。 ③ 三个坑替你踩了 · choice 的选项是 map 不是数组,每个选项都得写判据,写成数组直接报错;score 反过来是数组,从低到高排。这俩别搞反。 · confidence 不在 answers 里,藏在 r.providerMetadata.typesafe.confidence 底下,我找了半天。 · 免费额度卡得死,并发几十次就限流,充点钱就行,真花不了几个。 价格 $0.042/1M 输入 token,输出不计费。服务端延迟我实测中位数159ms,跟官方说的70-500ms对得上;但从国内调,端到端中位数557ms,剩下那三百多毫秒全在太平洋底下😢 官方 changelog: https://vercel.com/changelog/typesafe-ai-jev-now-available-on-ai-gateway