Google Decisions API
curl --request POST \
--url https://api.mixroute.ai/v1beta/decisionsimport requests
url = "https://api.mixroute.ai/v1beta/decisions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1beta/decisions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1beta/decisions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1beta/decisions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1beta/decisions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1beta/decisions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body決策模型
Google Decisions API
透過 MixRoute 呼叫 Google Decisions:具名的 noul、choice、score 問題、機率映射、多模態輸入結構與錯誤處理。
Google Decisions API
curl --request POST \
--url https://api.mixroute.ai/v1beta/decisionsimport requests
url = "https://api.mixroute.ai/v1beta/decisions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1beta/decisions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1beta/decisions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1beta/decisions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1beta/decisions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1beta/decisions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body使用 Gemini Decision 1 評估共用輸入,為每個具名問題回傳具型別的答案。本頁介紹 Google Decisions 協定,與 OpenAI Decisions 和 Jev System One 不同。
每個問題獨立評估共用輸入,無法看到其他答案。請在 instructions 中寫完整問題,再由應用程式碼組合結果。
選項 ID 為 1-128 個字元、最多 512 UTF-8 位元組;允許內部 ASCII 空格,不允許非 ASCII 空白字元。
機率不保證答案一定正確。請用有標註的代表性資料設定操作門檻;信心程度低或沒有合適選項時應允許複核。
輸出 token 為 0 是正常行為:模型回傳具型別的決策,不生成文字 token。輸入仍會計費。讀取
POST https://api.mixroute.ai/v1beta/decisions
傳送 Authorization: Bearer $MIXROUTE_API_KEY 和 Content-Type: application/json。使用 MixRoute Key,並儲存在伺服器端;不要將它傳送到 Google 的 API 網域。
Google 的 questions 是以問題 ID 為鍵的物件,answers 也使用對應鍵。真假判斷用 noul,選項或等級用 criteria。不要混用 OpenAI 的 questions 陣列、predicate、choices、levels,或 Jev 的 state 欄位。
請求參數
| 欄位 | 說明 |
|---|---|
model | 必填,使用 gemini-decision-1。 |
input | 必填的共用材料:非空字串、單一內容區塊或內容區塊陣列。 |
questions | 必填,包含 1-1,000 個問題的物件。鍵為 1-64 個符合 [A-Za-z0-9_-]+ 的 ASCII 字元,答案使用相同的鍵。 |
| 欄位 | 說明 |
|---|---|
questions.<id>.type | 必填: noul / choice / score |
questions.<id>.instructions | 必填的完整問題或評分準則,可用字串、文字內容區塊或其陣列。僅接受文字。模型看不到問題 ID。 |
questions.<id>.criteria | noul: 可選物件,包含 true_description 和/或 false_description 字串;問題已清楚定義兩種結果時可以省略。 |
questions.<id>.criteria | choice: 必填,包含 2-255 個選項 ID 到說明字串的映射,說明可為空字串。選項 ID 不能為空,不能有首尾空格或控制字元。 |
questions.<id>.criteria | score: 必填,包含 2-255 個非空等級說明的有序陣列。等級值是從 0 開始的陣列索引,不是任意數字標籤。 |
請求示例
設定 MIXROUTE_API_KEY。Python 示例使用 requests,JavaScript 示例使用 Node.js fetch。- cURL
- Python
- JavaScript
curl --request POST "https://api.mixroute.ai/v1beta/decisions" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gemini-decision-1",
"input": "CSV export fails on every attempt. The customer needs the file today and asks for a human agent.",
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this ticket?",
"criteria": {
"engineering": "Software defects",
"billing": "Payments and refunds"
}
},
"urgency": {
"type": "score",
"instructions": "How soon does the customer need help?",
"criteria": [
"No deadline is specified.",
"Help is needed within a week.",
"Help is explicitly required today."
]
},
"needs_human": {
"type": "noul",
"instructions": "Does the customer request a human agent?"
}
}
}'
import json
import os
import requests
payload = json.loads(r'''{
"model": "gemini-decision-1",
"input": "CSV export fails on every attempt. The customer needs the file today and asks for a human agent.",
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this ticket?",
"criteria": {
"engineering": "Software defects",
"billing": "Payments and refunds"
}
},
"urgency": {
"type": "score",
"instructions": "How soon does the customer need help?",
"criteria": [
"No deadline is specified.",
"Help is needed within a week.",
"Help is explicitly required today."
]
},
"needs_human": {
"type": "noul",
"instructions": "Does the customer request a human agent?"
}
}
}''')
response = requests.post(
"https://api.mixroute.ai/v1beta/decisions",
headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
json=payload,
timeout=60,
allow_redirects=False,
)
response.raise_for_status()
result = response.json()
if "error" in result:
raise RuntimeError(result["error"])
answers = result.get("answers")
if not isinstance(answers, dict):
raise ValueError("Expected an answers object")
fields = {"noul": "noul", "choice": "choice", "score": "score"}
for name, question in payload["questions"].items():
answer = answers.get(name)
if not isinstance(answer, dict) or answer.get("type") != question["type"]:
raise ValueError("Missing or unexpected answer type: " + name)
print(name, answer[fields[question["type"]]], answer["confidence"])
print(result.get("usage", {}))
const apiKey = process.env.MIXROUTE_API_KEY;
if (!apiKey) throw new Error("Set MIXROUTE_API_KEY");
const payload = {
"model": "gemini-decision-1",
"input": "CSV export fails on every attempt. The customer needs the file today and asks for a human agent.",
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this ticket?",
"criteria": {
"engineering": "Software defects",
"billing": "Payments and refunds"
}
},
"urgency": {
"type": "score",
"instructions": "How soon does the customer need help?",
"criteria": [
"No deadline is specified.",
"Help is needed within a week.",
"Help is explicitly required today."
]
},
"needs_human": {
"type": "noul",
"instructions": "Does the customer request a human agent?"
}
}
};
const response = await fetch("https://api.mixroute.ai/v1beta/decisions", {
method: "POST",
headers: {Authorization: "Bearer " + apiKey, "Content-Type": "application/json"},
body: JSON.stringify(payload),
redirect: "error",
signal: AbortSignal.timeout(60000),
});
const result = await response.json();
if (!response.ok || result.error) {
throw new Error("HTTP " + response.status + ": " + JSON.stringify(result.error ?? result));
}
if (!result.answers || Array.isArray(result.answers) || typeof result.answers !== "object") {
throw new Error("Expected an answers object");
}
const fields = {noul: "noul", choice: "choice", score: "score"};
for (const [name, question] of Object.entries(payload.questions)) {
const answer = result.answers[name];
if (!answer || answer.type !== question.type) {
throw new Error("Missing or unexpected answer type: " + name);
}
console.log(name, answer[fields[question.type]], answer.confidence);
}
console.log(result.usage ?? {});
答案與用量
| 欄位 | 說明 |
|---|---|
noul | noul 是 P(true),範圍為 0.01-0.99,不是布林值。confidence 等於 max(noul, 1 - noul)。 |
choice | choice 是獲選的選項 ID,probabilities 為每個選項的機率映射,confidence 為獲選機率。機率完全相同時,依選項鍵的 UTF-8 位元組字典序選擇最前者。 |
score | score 是等級索引的機率加權平均值,可以是小數。probabilities 將字串索引映射為機率,legend 將其映射為等級說明。confidence 是最大的等級機率,不是正規化後的 score。 |
{
"answers": {
"team": {
"confidence": 0.9980277470061801,
"choice": "engineering",
"probabilities": {
"billing": 0.0019722529938198032,
"engineering": 0.9980277470061801
},
"type": "choice"
},
"urgency": {
"confidence": 0.9833902224118356,
"score": 1.9825588708050947,
"probabilities": {
"0": 0.0008313516067408738,
"1": 0.015778425981423486,
"2": 0.9833902224118356
},
"legend": {
"0": "No deadline is specified.",
"1": "Help is needed within a week.",
"2": "Help is explicitly required today."
},
"type": "score"
},
"needs_human": {
"confidence": 0.99,
"noul": 0.99,
"type": "noul"
}
},
"usage": {
"total_tokens": 230,
"total_input_tokens": 230,
"input_tokens_by_modality": [
{
"modality": "text",
"tokens": 230
}
],
"total_output_tokens": 0
}
}
usage.total_input_tokens、usage.total_output_tokens 和 usage.total_tokens;實際扣費以控制台消費紀錄為準。
限制與輸入格式
共用輸入與所有問題合計不得超過 262,144 tokens;JSON 巢狀深度上限為 100 層。 文字區塊使用{"type":"text","text":"..."}。圖片、音訊、影片和 PDF document 區塊使用 type、mime_type,以及內嵌 Base64 data 或 uri。應用程式自身的 JSON 應序列化為文字字串,不要直接作為內容區塊傳送。
Google 公布的內嵌資料上限為每次 100 MB(PDF 為 50 MB),外部 HTTPS URL 為每個 15 MB。Files API URI、公開 URL 和簽署的 HTTPS URL 屬於廠商格式;經 MixRoute 上傳或取得媒體的能力取決於路由。Decisions 不支援 YouTube URL 或直接使用 gs:// URI。
相鄰文字區塊串接時不會自動加入分隔符,請自行加入空格或換行。不要傳對話訊息、思考或工具呼叫內容區塊,應將這些上下文序列化為文字。本介面不提供上下文快取、Batch API、Flex 或 Priority 推理。路由限制可能低於廠商上限。