Vercel AI Gateway

TypeSafe Jev 的 Gateway 最短路径

让 AI Gateway 成为唯一网络跳。不要为 Jev 自建代理或「中继」API。评估需要 AI SDK evaluate API(AI SDK 7+)。

  1. 在 Vercel 控制台(AI Gateway)创建密钥,存为 AI_GATEWAY_API_KEY(或 SDK 要求的环境变量名)。
  2. 在应用中安装 AI SDK 7+(生产密钥仅服务端):
    npm install ai @ai-sdk/gateway
  3. 用共享 state 与类型化 questions 调用 typesafe-ai/jev。
  4. 在代码中应用阈值 — 高置信 → 自动建议;低 → 人工队列。用标注样例校准。不承诺准确率。

最小 Choice 示例(直播)

import { experimental_evaluate as evaluate } from 'ai';

const result = await evaluate({
  model: 'typesafe-ai/jev',
  state: 'In stock? Can you ship to the US?',
  questions: {
    label: {
      type: 'choice',
      instructions: 'Label this livestream comment for the host team.',
      criteria: {
        buy_intent: 'Purchase intent, stock availability, or shipping destination questions tied to buying',
        price_question: 'Asking about price, discounts, bundles, or deal terms',
        after_sales: 'Post-purchase support, returns, defects, delivery problems after buying',
        spam: 'Bots, ads, scams, harassment, or irrelevant promotional noise',
        other: 'Does not fit the above',
      },
    },
  },
});

// result.answers.label.choice → e.g. "buy_intent"
// high confidence → auto-suggest; low → human queue

工单路由示例

const result = await evaluate({
  model: 'typesafe-ai/jev',
  state: 'API returns 500 on checkout',
  questions: {
    route: {
      type: 'choice',
      instructions: 'Route this support ticket to the right queue.',
      criteria: {
        tech: 'Bugs, outages, errors, API failures, integrations, or product not working as designed',
        sales: 'Pricing, plans, upgrades, demos, or new-purchase intent before becoming a customer',
        billing: 'Charges, invoices, receipts, subscriptions, payment method, or invoice questions',
        human: 'Ambiguous, multi-issue, sensitive, legal, account takeover, or otherwise needs a person',
      },
    },
  },
});

// → tech
若已使用 @ai-sdk/gateway,优先用 Gateway 提供方助手:gateway.evaluationModel("typesafe-ai/jev")。

不要做什么

不要自建中继

跳过自定义「Jev 代理」。让应用或 serverless 直接指向 Gateway。

不要金钱自动化

仅建议。退款与收款仍由人负责 — 本包范围外。