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 推理。路由限制可能低于厂商上限。