> ## Documentation Index
> Fetch the complete documentation index at: https://mixroute.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Decisions API

> 通过 MixRoute 调用 Google Decisions：具名的 noul、choice、score 问题、概率映射、多模态输入结构与错误处理。

使用 Gemini Decision 1 评估共享输入，为每个具名问题返回类型化答案。本页介绍 Google Decisions 协议，与 OpenAI Decisions 和 Jev System One 不同。

`POST https://api.mixroute.ai/v1beta/decisions`

发送 Authorization: Bearer \$MIXROUTE\_API\_KEY 和 Content-Type: application/json。使用 MixRoute Key，并保存在服务端；不要将它发送到 Google 的 API 域名。

> [!WARNING]
>
> 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 开始的数组索引，不是任意数字标签。 |

每个问题独立评估共享输入，无法看到其他答案。请在 instructions 中写完整问题，再由应用代码组合结果。

选项 ID 为 1-128 个字符、最多 512 UTF-8 字节；允许内部 ASCII 空格，不允许非 ASCII 空白字符。

## 请求示例

设置 MIXROUTE\_API\_KEY。Python 示例使用 requests，JavaScript 示例使用 Node.js fetch。

> [tab] cURL
>
> ```bash theme={null}
> 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?"
>     }
>   }
> }'
> ```

> [tab] Python
>
> ```python theme={null}
> 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", {}))
> ```

> [tab] JavaScript
>
> ```javascript theme={null}
> 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。 |

概率不保证答案一定正确。请用有标注的代表性数据设定操作阈值；置信度低或没有合适选项时应允许复核。

```json theme={null}
{
  "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
  }
}
```

输出 token 为 0 是正常行为：模型返回类型化决策，不生成文本 token。输入仍会计费。读取 `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 推理。路由限制可能低于厂商上限。

## 错误处理

读取 answers 前先检查 HTTP 状态和 JSON error 对象。参数或限制错误可返回 HTTP 400；Google 安全拦截返回错误而不是 answers，不能照搬 OpenAI 的逐问题 refusal 处理。也应拒绝缺少答案或答案类型不符合请求的响应。

超时不代表请求未执行，不要盲目重试 POST。遇到限流或临时服务错误时，保留请求 ID，并按应用需要控制重试与退避。

## 相关协议

[Gemini Decision 1](https://mixroute.ai/docs/zh-Hans/model-api/google/gemini-decision-1.md) · [OpenAI Decisions](https://mixroute.ai/docs/zh-Hans/api-reference/endpoint/decisions.md) · [Jev System One](https://mixroute.ai/docs/zh-Hans/api-reference/endpoint/jev.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.