Decisions
針對一段文字、資料或圖片中具名問題的型別化答案
Decisions 模型會讀取 state,並以固定的答案型別回答你指定的每個問題,適用於工單路由、內容評分、是非檢查與評分。Decisions 模型僅依輸入 詞元 計費,沒有輸出價格。現行價格請見 服務。
| 模型 | 輸入 |
|---|---|
gemini-decision-1 | 文字、圖片、音訊、影片與檔案 |
gpt-6-luna-decisions | 文字與圖片 |
typesafe-jev-1.14 | 文字與圖片 |
請求
向 /v1/decisions 發送 POST 請求,並在 Authorization 標頭中附上你的 API 金鑰。
| 欄位 | 類型 | 描述 |
|---|---|---|
model | string | Decisions 模型。預設為 gemini-decision-1。 |
state | 字串、物件或陣列 | 必填。問題所針對的文字、資料或媒體。圖片以陣列形式作為 image_url 部分傳入。 |
questions | object | 1 至 50 個問題,各以 1 至 64 個字母、數字、底線或連字號命名。除非傳送 options,否則為必填。 |
options | array | 選填。2 至 255 個待排序選項,可以是文字,或含 value 與 description 的物件。詳見 排序選項。 |
instructions | string | 選填,針對這些選項所提出的問題,預設為「Which option fits the state best?」 |
question_name | string | 選填。排序問題在 answers 中的名稱。預設為 ranking。 |
top_k | integer | 選填。要回傳的排序選項數量,1 至 255。預設回傳全部。 |
assets | object | 選填。具名 PNG 或 JPEG 圖片,state 可依名稱參照。 |
問題型別
每個問題都有 type、選填的 instructions,以及描述可能答案的 criteria。
| 類型 | 條件 | 答案 |
|---|---|---|
noul | 含 true 與 false 描述的物件 | noul、答案為真的機率,多數模型另有 confidence |
choice | 2 至 255 個具名選項的物件 | choice,以及每個選項的 probabilities 和 confidence |
score | 2 至 10 個由低至高的等級清單 | score(從 0 到最後一個等級索引),為各等級的機率加權平均值,可落在等級之間,另含 legend、各等級的 probabilities 與 confidence |
box | 無,請在 instructions 中描述目標,僅 typesafe-jev-1.14 會回答方框問題。 | box,其中 top、bottom、left 和 right 為圖片的比例,另含 confidence |
模型可拒答某個問題。該答案會以 { "type": "refusal" } 回傳,表示問題未被回答,而非答案為否。並非所有模型都接受各種媒體部分,若模型無法處理請求,會以狀態 400 回傳失敗。
排序選項
傳送 options 來排序清單。SilentAPI 會提出一個 choice 問題,並在 ranking 中回傳由最可能至最不可能排序的選項,排名最高的選項放在 choice。你可在同一請求中同時傳送 options 與其他 questions。
curl https://api.silentapi.com/v1/decisions \
-H "Authorization: Bearer $SILENTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": "Order 1042 arrived two weeks late and the box was crushed. The customer wants it fixed today.",
"instructions": "What should support do first?",
"options": [
"apologize",
{ "value": "refund", "description": "Return the full payment." },
{ "value": "replace", "description": "Ship a new item by express." }
],
"top_k": 2
}'
{
"object": "decision",
"model": "gemini-decision-1",
"answers": { "ranking": { "type": "choice", "choice": "replace", "probabilities": { "replace": 0.62, "refund": 0.31, "apologize": 0.07 }, "confidence": 0.62 } },
"choice": "replace",
"confidence": 0.62,
"ranking": [
{ "rank": 1, "value": "replace", "probability": 0.62 },
{ "rank": 2, "value": "refund", "probability": 0.31 }
],
"usage": { "input_tokens": 96 },
"silentapi": {
"cost": 0.0000121,
"fallback": null,
"model": "gemini-decision-1",
"model_name": "Gemini Decision 1"
},
"cost": 0.0000121
}
範例
curl https://api.silentapi.com/v1/decisions \
-H "Authorization: Bearer $SILENTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-decision-1",
"state": { "tier": "business", "ticket": "Checkout shows a blank page after I click Pay." },
"questions": {
"is_bug": { "type": "noul", "instructions": "Is the customer reporting a defect?", "criteria": { "true": "Something is broken.", "false": "A question or a feature request." } },
"team": { "type": "choice", "instructions": "Which team owns this ticket?", "criteria": { "payments": "Checkout and billing.", "frontend": "Layout and rendering.", "account": "Login and profile." } },
"urgency": { "type": "score", "instructions": "How urgent is this ticket?", "criteria": ["Can wait", "This week", "Blocking sales now"] }
}
}'
回應包含每個問題名稱各一個答案、輸入 詞元 數量,以及以額度計的費用。
{
"object": "decision",
"model": "gemini-decision-1",
"answers": {
"is_bug": { "type": "noul", "noul": 0.94, "confidence": 0.94 },
"team": {
"type": "choice",
"choice": "payments",
"probabilities": { "payments": 0.88, "frontend": 0.1, "account": 0.02 },
"confidence": 0.88
},
"urgency": {
"type": "score",
"score": 1.72,
"legend": { "0": "Can wait", "1": "This week", "2": "Blocking sales now" },
"probabilities": { "0": 0.04, "1": 0.2, "2": 0.76 },
"confidence": 0.76
}
},
"usage": { "input_tokens": 212 },
"silentapi": {
"cost": 0.0000265,
"fallback": null,
"model": "gemini-decision-1",
"model_name": "Gemini Decision 1"
},
"cost": 0.0000265
}
若所選模型無法使用,且你已開啟 Decisions 備援,請求會轉至另一個 Decisions 模型。