端點
OpenRouter
本站 Playground 透過 OpenRouter 呼叫固定版本的 Jev。目前的價格與可用性請以模型頁面為準。
- 端點
- POST https://openrouter.ai/api/alpha/decisions
- model
- typesafe/jev-1.13
- API 金鑰
- 在伺服器端以 Bearer token 傳送 API 金鑰。
選擇一個問題,或針對同一情境提出三個不同問題。先選案例,再修改輸入,查看各題的結構化答案。
每次專注測試一種回答類型。 每次執行會用掉一次當日體驗額度。
執行案例後,每個問題都會回傳一份結構化答案:Choice 選出選項,Score 給出分數,Probability 回傳 0 到 1 之間的數值。
表單會將文字作為 state.input,並傳送一個或三個具名問題。每個結果都可在 answers.<question_id> 下找到。
請求中定義要判斷的問題,回應會依問題名稱回傳結果。以下說明範例中用到的 JSON 欄位。
modelstatequestions<question_id>typeinstructionscriteriaanswerschoiceprobabilitiesconfidencescorelegendnoul同一份情境,分別測試 Choice、Score 與 Probability 三個問題。 每次執行會用掉一次當日體驗額度。 結果符合欄位格式,判斷也可能出錯。請用自己的樣本驗證,並依業務風險設定分流門檻。
本站 Playground 透過 OpenRouter 呼叫固定版本的 Jev。目前的價格與可用性請以模型頁面為準。
TypeSafe 提供自己的端點和 API 金鑰。官方快速入門使用 jev-latest,也示範一次傳送多個問題。
// Run on your server. Keep the API key out of browser code.
const apiKey = process.env.OPENROUTER_API_KEY;
if (!apiKey) throw new Error("Set OPENROUTER_API_KEY");
const response = await fetch("https://openrouter.ai/api/alpha/decisions", {
method: "POST",
headers: {
Authorization: "Bearer " + apiKey,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "typesafe/jev-1.13",
state: {input: "A customer reports a duplicate charge."},
questions: {
team: {
type: "choice",
instructions: "Which team should handle this?",
criteria: {
billing: "Payments and refunds",
technical: "Bugs and integrations"
}
},
urgency: {
type: "score",
instructions: "How urgent is the issue?",
criteria: ["Can wait", "Needs attention today", "Immediate action"]
},
escalate: {
type: "noul",
instructions: "Should a human review this first?",
criteria: {false: "No review needed", true: "Review before acting"}
}
}
})
});
if (!response.ok) throw new Error("Decision request failed");
const {answers} = await response.json();
console.log(answers.team.choice, answers.urgency.score, answers.escalate.noul);模型選中的選項鍵,也是機率最高的選項。
依各等級的機率加權得出的位置,可能落在兩個等級之間。
是非問題的 0 到 1 數值;越接近 1 越傾向於「是」。
正式上線前,請用具代表性的客服案件測試、記錄模型版本,並將結果不確定或出錯代價高的情況交由人工審核。範例中的 0.8 只是示意門檻。