{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/quorum-dog/json-schema/quorum-dog-chat-completion-schema.json",
  "title": "ChatCompletion",
  "description": "OpenAI's shape, plus an additive `quorum` block. Nothing in the OpenAI-shaped part was renamed.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/quorum-dog-openapi.json#/components/schemas/ChatCompletion",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "object": {
      "type": "string",
      "const": "chat.completion"
    },
    "created": {
      "type": "integer",
      "description": "Unix seconds."
    },
    "model": {
      "type": "string"
    },
    "choices": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "message": {
            "$ref": "#/$defs/Message"
          },
          "finish_reason": {
            "type": "string",
            "enum": [
              "stop",
              "length"
            ],
            "description": "`stop` means the answer is complete. The cost ceiling never stops a deliberation: it clamps the bill after the fact, and that is reported as `quorum.capped`, not here. (`cost_cap` was emitted for a clamped bill until 2026-10-02 and is no longer returned.) `length` ADDED 2026-09-17, ADDITIVE: the answer was CUT OFF by the model's output limit and is incomplete — the same value api.openai.com uses, so an SDK already handles it. It is MEASURED, never inferred: it is set from the field the provider itself used to report the cut (Google `MAX_TOKENS`, Bedrock and Anthropic `max_tokens`, OpenAI and Groq `length`), never from the answer's length or its shape. It describes THE CALL THAT PRODUCED THE TEXT YOU RECEIVED — the synthesis on a panel run, the winning seat when no synthesis ran — so a losing seat that was cut does not set it. ON AN IDEMPOTENT REPLAY (`replayed: true`) this value is READ FROM THE STORED REQUEST, so a retry reports what the first call reported — that was not true before 2026-09-17, when a replay always said `stop`. A replayed request made before that date recorded no truncation measurement and reports `stop` as this endpoint's default rather than as a verified fact; it says so in `quorum.note` and omits `quorum.answer_truncated` entirely, which is how you tell the two apart."
          }
        }
      }
    },
    "usage": {
      "type": "object",
      "properties": {
        "prompt_tokens": {
          "type": "integer"
        },
        "completion_tokens": {
          "type": "integer"
        },
        "total_tokens": {
          "type": "integer"
        }
      }
    },
    "quorum": {
      "type": "object",
      "description": "What the OpenAI shape has no field for.",
      "properties": {
        "request_id": {
          "type": "string",
          "description": "Pass to /v1/receipts/{request_id}."
        },
        "mode": {
          "type": [
            "string",
            "null"
          ],
          "description": "The Mode, by its ticker in COMPANY:MODE form (e.g. `QRUM:STAN`), the same name `model` takes. `null` when the Mode has no ticker or the name lookup fails; the call itself is unaffected."
        },
        "mode_config_hash": {
          "type": "string",
          "description": "Short hash of the mode's engine and deliberation config. A change here means the panel itself changed, as opposed to ordinary prompt-to-prompt variance."
        },
        "rounds": {
          "type": "integer",
          "description": "How many deliberation rounds actually ran. Most calls resolve in one; a second round means the panel disagreed enough to warrant it."
        },
        "seats": {
          "type": "integer",
          "description": "How many seats CONVENED for this request. Unchanged: it counts every seat the panel sat, including one that then produced nothing."
        },
        "seats_answered": {
          "type": [
            "integer",
            "null"
          ],
          "description": "How many of those seats actually produced an answer. ADDED 2026-09-17, additive only. `seats_answered < seats` means the deliberation you paid panel price for was smaller than the panel that convened — a three-engine run can quietly become two, or none, and until now nothing in the response said so. A seat whose first attempt was cut and then RETRIED still counts here: the retry answered, so the seat contributed, and the discarded attempt is wasted cost rather than a missing panellist. `null` only when the run reported no seat array at all, which is not the same claim as zero. ON AN IDEMPOTENT REPLAY (`replayed: true`) this field is read from the stored request and is ABSENT — not null — when that request predates 2026-09-17 and never recorded it; absence there means \"not recorded\", while `0` still means no seat answered."
        },
        "answer_truncated": {
          "type": "boolean",
          "description": "ADDED 2026-09-17, ADDITIVE. Present ONLY on an idempotent replay (`replayed: true`), where it is the truncation fact read from the stored request: `true` means the answer you are being handed was cut off by the model's output limit, `false` means it was not. It is the same measurement that set `finish_reason` on the original call, so a retry reports what the first call reported instead of a hardcoded `stop`. On a first (non-replayed) call the equivalent fact is `finish_reason` itself, which is why the field does not appear there. IT IS ABSENT WHEN THE STORED REQUEST NEVER RECORDED IT — requests made before 2026-09-17 could not measure it — and absence is deliberate: those runs are unknown, not known-clean, and publishing `false` would state a measurement nobody took. A caller that must be certain the answer is whole should branch on `'answer_truncated' in response.quorum` before trusting a replayed `finish_reason` of `stop`."
        },
        "converged": {
          "type": "boolean",
          "description": "Whether the seats agreed. `false` is information, not failure — it is the signal that the question is genuinely contested."
        },
        "capped": {
          "type": "boolean"
        },
        "pricing_rule": {
          "type": "string",
          "enum": [
            "per_mtok"
          ],
          "description": "`per_mtok`: engines at actual cost, the platform fee, the Mode's fee."
        },
        "gateway_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "What the engines cost, billed at actual. A pass-through. `null` only when no figure is available."
        },
        "token_charge_usd": {
          "type": "number",
          "description": "The engines' part of the bill. It equals `gateway_usd`."
        },
        "surcharge_usd": {
          "type": "number",
          "description": "The Mode's fee. The field keeps its earlier name."
        },
        "platform_fee_usd": {
          "type": "number",
          "description": "The platform fee on this call: the sum of each seat's fee on its source's real cost. Never charged on the Mode's fee. Per-seat lines are on the receipt."
        },
        "billed_net": {
          "type": "object",
          "description": "The parts of the bill net of `cap_credit_usd`; they sum to `billed_usd`. Absent on an idempotent replay.",
          "properties": {
            "gateway_usd": {
              "type": [
                "number",
                "null"
              ]
            },
            "token_charge_usd": {
              "type": [
                "number",
                "null"
              ]
            },
            "platform_fee_usd": {
              "type": [
                "number",
                "null"
              ]
            },
            "mode_fee_usd": {
              "type": [
                "number",
                "null"
              ]
            }
          }
        },
        "cap_credit_usd": {
          "type": "number",
          "description": "The amount by which this call went over its per-call ceiling, credited back to you. The call is charged whole (the engines, `platform_fee_usd` and `surcharge_usd` as reported here), then this credit is applied, so `billed_usd` is that sum minus `cap_credit_usd`. `0` when the call stayed under the ceiling; `capped` is `true` whenever it is above `0`. Absent on an idempotent replay (`replayed: true`), like every money field on this block: the replay is not re-billed, and `/v1/receipts/{request_id}` carries the recorded figure."
        },
        "billed_usd": {
          "type": "number"
        },
        "payer": {
          "type": "string",
          "enum": [
            "org",
            "plan",
            "turbo",
            "plan+turbo",
            "unbilled"
          ],
          "description": "Who paid for this call, the same value `/v1/receipts/{request_id}` returns. `org`: billed to the organisation's API account, which is every API-key call. A connected app (OAuth) bills the person's plan at real cost with no Mode fee: `plan`, `turbo`, `plan+turbo` or `unbilled` (the charge could not be written). Absent on an idempotent replay (`replayed: true`)."
        },
        "latency_ms": {
          "type": "integer"
        },
        "engines": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The provider families that actually answered. May differ from the mode's declared design when a seat fell back."
        },
        "persisted": {
          "type": "boolean"
        },
        "replayed": {
          "type": "boolean",
          "description": "Present and `true` only on an idempotent replay: the original answer, not re-run and not re-billed."
        }
      }
    }
  },
  "$defs": {
    "Message": {
      "type": "object",
      "required": [
        "role",
        "content"
      ],
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "system",
            "user",
            "assistant"
          ]
        },
        "content": {
          "type": "string"
        }
      }
    }
  }
}