> ## 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 のキーをサーバー側で保持し、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 問のマップ。キーは `[A-Za-z0-9_-]+` に一致する 1-64 文字の ASCII 文字列で、回答にも同じキーが使われます。 |

| フィールド | 説明 |
| - | - |
| `questions.<id>.type` | 必須: `noul` / `choice` / `score` |
| `questions.<id>.instructions` | 必須の完全な質問または評価基準。文字列、テキストブロック、またはその配列を指定します。テキストのみ対応し、モデルには質問 ID は渡されません。 |
| `questions.<id>.criteria` | `noul`: 任意のオブジェクト。`true_description` と `false_description` のいずれか、または両方を文字列で指定します。instructions で両方の結果が明確なら省略できます。 |
| `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 は各 ID の確率マップ、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
  }
}
```

出力トークンが 0 なのは正常です。型付きの判定結果を返し、テキストトークンは生成しません。入力には課金されます。`usage.total_input_tokens`、`usage.total_output_tokens`、`usage.total_tokens` を確認し、実際の料金はコンソールの消費ログで照合してください。

## 制限と入力形式

共有入力と全質問の合計は 262,144 トークン以内、JSON のネストは 100 階層以内に収めてください。

テキストブロックは `{"type":"text","text":"..."}` です。画像・音声・動画・PDF document ブロックには type、`mime_type` と、インライン Base64 の data または uri を指定します。アプリケーションの JSON は文字列にシリアライズし、任意のオブジェクトをそのままコンテンツブロックとして送らないでください。

Google が公開するインライン上限は 1 リクエスト 100 MB（PDF は 50 MB）、外部 HTTPS URL は 1 件 15 MB です。Files API URI、公開 URL、署名付き HTTPS URL はプロバイダー側の形式であり、MixRoute 経由でのアップロードやメディア取得はルートに依存します。Decisions は YouTube URL と直接の gs\:// URI に対応しません。

隣接するテキストブロックは区切りなしで連結されるため、空白や改行を含めてください。会話メッセージ、思考、ツール呼び出しのブロックは使わず、テキストにシリアライズします。コンテキストキャッシュ、Batch API、Flex、Priority 推論はこの API の対象外です。ルートの制限がプロバイダー上限より低い場合があります。

## エラー処理

answers を読む前に HTTP ステータスと JSON の error を確認します。フィールドや制限の違反では HTTP 400 が返ることがあります。Google の安全性ブロックは answers ではなくエラーを返すため、OpenAI の質問ごとの refusal 処理を流用しないでください。回答の欠落や型の不一致も検出してください。

タイムアウトしても、リクエストが未実行とは限りません。POST を無条件で再試行しないでください。レート制限や一時的なサービス障害ではリクエスト ID を保持し、アプリケーションに合った再試行とバックオフを制御します。

## 関連プロトコル

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


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