{
  "components": {
    "schemas": {
      "AdminLevel": {
        "anyOf": [
          {
            "const": "off",
            "description": "No admin tools.",
            "type": "string"
          },
          {
            "const": "read_only",
            "description": "Reads lmgw's configuration and state.",
            "type": "string"
          },
          {
            "const": "full",
            "description": "Also changes them.",
            "type": "string"
          }
        ],
        "description": "A level of lmgw's admin tools, written `off`, `read_only` or `full`:\nwhat a device's admin tools may do now (the change feed's\n`hello.self_admin` and `state.self_admin`), the level set on a device\nkey (`KeyRow.self_admin`, and `self_admin` in `key_create` and\n`key_set`), or the gateway's own (`GatewayStatus.self_admin`,\n`SettingsFull.self_admin`).\n\nForward compatible like every enum a client reads: a value a newer\ngateway sends reads as `AdminLevel::Unknown`, as sent, and writes back\nunchanged. The document lists the known values only."
      },
      "AgentBatchShape": {
        "description": "What a `batch` manifest can actually do, for the Run tab.\n\nDerived server-side from the manifest **and the stored config**, because\nboth halves matter and only one of them is in the manifest: the review\ncolumns are the author's, in the author's order, while the values an\neditable field may be set to come from the config field `enum_from` names —\nso widening the taxonomy is a config edit and the table picks it up.\nA client re-deriving this from the manifest text would also lose the column\norder, since a JSON object parses into a sorted map here.",
        "properties": {
          "apply_tools": {
            "description": "The tools Apply reaches, named next to the button so the reviewer knows\nwhat is about to be called.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "apply_tools_are_ceiling": {
            "description": "`apply_tools` is the ceiling the agent's token enforces rather than the\ncalls the step makes — true for a container, whose image decides. The\nRun tab says \"may call\" instead of \"calls\".",
            "type": "boolean"
          },
          "columns": {
            "description": "Review-table columns, in the manifest's order.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "decide": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentDecide"
              },
              {
                "type": "null"
              }
            ],
            "description": "The output can classify through a question set (its `decide`); `None`\nwhen it cannot."
          },
          "editable": {
            "description": "Output fields the reviewer may override, with their allowed values.",
            "items": {
              "$ref": "#/components/schemas/AgentReviewField"
            },
            "type": "array"
          },
          "has_apply": {
            "description": "The manifest declares an apply step, so there is something to write.",
            "type": "boolean"
          },
          "has_classify": {
            "description": "The manifest declares a per-item model call, so \"Dry run\" applies.",
            "type": "boolean"
          }
        },
        "required": [
          "columns",
          "editable",
          "has_classify",
          "has_apply",
          "apply_tools",
          "apply_tools_are_ceiling",
          "decide"
        ],
        "type": "object"
      },
      "AgentBudget": {
        "description": "The visible bounds a turn runs under: one pair from Settings → Agents & tools,\nnever a second one invented per agent.",
        "properties": {
          "max_tool_calls": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "timeout_seconds": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "max_tool_calls",
          "timeout_seconds"
        ],
        "type": "object"
      },
      "AgentDecide": {
        "description": "A batch output that classifies through a Decision lab question set\n(labs-store design §4): the config field holding the set, the set's\nquestion it asks, and how the stored config's set reads.",
        "properties": {
          "enum_from": {
            "description": "The config field the enum comes from without a set (`enum_from`),\nwhich a run with a set does not read.",
            "type": [
              "string",
              "null"
            ]
          },
          "field": {
            "description": "The config field holding the set's id (`QUESTION_SET_FORMAT`).",
            "type": "string"
          },
          "measured": {
            "description": "The threshold was measured on a labelled set run. Only a measured\nthreshold is applied: an answer whose confidence is below it needs\nattention. An unmeasured one is shown, not applied (Decision 10).",
            "type": "boolean"
          },
          "model_field": {
            "description": "The config field the agent's model alias is (`{{config.<field>}}`),\nwhen it is one: a classify needs it or a set, so the Run tab blocks\nClassify while both are empty.",
            "type": [
              "string",
              "null"
            ]
          },
          "problem": {
            "description": "Why the stored config's set cannot classify (gone, no such question,\nnot a choice, no default model); a run refuses with it.",
            "type": [
              "string",
              "null"
            ]
          },
          "question": {
            "description": "The set's question that answers the output field: the output field's\nown name. It must be a `choice` question, whose options are the\nreview's values with the fallback last.",
            "type": "string"
          },
          "set": {
            "description": "The set the stored config names; `None` classifies with the model\ncall, as without `decide`.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "set_name": {
            "description": "That set's name.",
            "type": [
              "string",
              "null"
            ]
          },
          "threshold": {
            "description": "The threshold the set keeps for its question (0 when it has none),\nmeasured or not: see `measured`.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "field",
          "question",
          "enum_from",
          "set",
          "set_name",
          "threshold",
          "measured",
          "model_field",
          "problem"
        ],
        "type": "object"
      },
      "AgentField": {
        "description": "One rendered config field. `ty` is `string | integer | number |\nboolean | array`; `format` is `secret | model_alias | multiline | directory\n| file` or empty, or `QUESTION_SET_FORMAT` on an integer.",
        "properties": {
          "access": {
            "description": "For a `directory` or `file` field: `ro` or `rw`, as the **manifest**\ndeclared it. Empty for every other field — the mode is a\nproperty of the agent, never of the form.",
            "type": "string"
          },
          "default": {},
          "description": {
            "type": "string"
          },
          "enum": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "format": {
            "type": "string"
          },
          "has_value": {
            "description": "For a `secret` field: whether one is stored. Always false otherwise —\nthe value itself is in `config`.",
            "type": "boolean"
          },
          "maximum": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "minimum": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "type",
          "format",
          "title",
          "description",
          "default",
          "enum",
          "minimum",
          "maximum",
          "required",
          "has_value",
          "access"
        ],
        "type": "object"
      },
      "AgentInstallHint": {
        "properties": {
          "kind": {
            "description": "`git`, `image` or `url`.",
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "ref": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "ref",
          "notes"
        ],
        "type": "object"
      },
      "AgentPortability": {
        "description": "Whether the export of this agent lands on another box.\n\nShown before the download, never enforced: exporting to the same box is the\ncommon case, and the wrong answer is a file that looks complete while naming\nan image only the exporter has.",
        "properties": {
          "notes": {
            "description": "What the receiver would have to do, one sentence each. Empty when\n`portable`.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "portable": {
            "description": "Nothing about this agent is local to this machine.",
            "type": "boolean"
          }
        },
        "required": [
          "portable",
          "notes"
        ],
        "type": "object"
      },
      "AgentProvenance": {
        "description": "Where this row's document came from.\n\n`None` on the detail document for a row nobody installed from an image — an\nagent written in the Definition editor has no package and says so by having\nno provenance, rather than by carrying one full of empty strings.\n\n`installed_at` and `pulled_at` are two facts on purpose: the first is when\nthe row was written from the image, the second when the digest was last\nread. `agent_pull` moves only the second.",
        "properties": {
          "digest": {
            "description": "`podman image inspect --format '{{.Digest}}'` at the last read. Absent\nwhen podman could not say — never a placeholder that reads like a digest.",
            "type": "string"
          },
          "image": {
            "description": "The image reference as it was given at install, tag and all.",
            "type": "string"
          },
          "installed_at": {
            "type": "string"
          },
          "manifest_path": {
            "description": "Where in the image the manifest was found (`/lmgw/agent.json`).",
            "type": "string"
          },
          "pulled_at": {
            "type": "string"
          }
        },
        "required": [
          "image",
          "manifest_path",
          "installed_at",
          "pulled_at"
        ],
        "type": "object"
      },
      "AgentRequirement": {
        "description": "One `tools[]` entry measured against what the gateway offers right now.\n\nA gap is a warning, never a refusal: an agent is imported before its server\nis wired, the same way a server is registered before its image is pulled.",
        "properties": {
          "install": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentInstallHint"
              },
              {
                "type": "null"
              }
            ],
            "description": "The manifest's install hint, for prefilling the MCP page. lmgw never\nfetches anything from it."
          },
          "label": {
            "type": "string"
          },
          "missing_tools": {
            "description": "Names in `allowed` the source does not list right now.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "registered": {
            "description": "The label resolves to a registered server or a built-in toolset.",
            "type": "boolean"
          }
        },
        "required": [
          "label",
          "registered",
          "missing_tools",
          "install"
        ],
        "type": "object"
      },
      "AgentReviewField": {
        "description": "One editable output field. An empty `options` means free text: there is no\nenum behind it to offer.",
        "properties": {
          "field": {
            "type": "string"
          },
          "options": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "field",
          "options"
        ],
        "type": "object"
      },
      "AgentRowSet": {
        "description": "The question set that classified a batch row (labs-store design §4),\nstamped on the row as the run read the set: its id, its name and its\n`updated_at`. \"Save as labelled set\" saves a run's rows into the set\nthat classified them; a row the model call classified has none.",
        "properties": {
          "digest": {
            "default": "",
            "description": "A digest of the output question's definition (type, text, options\nwith descriptions, levels) as it was asked. \"Save as labelled set\"\nreports the set changed only when the question's digest differs, not\non any `updated_at` bump (a threshold write). Empty on a row stamped\nwithout one, which reads as unchanged.",
            "type": "string"
          },
          "id": {
            "default": 0,
            "description": "The set's preset id.",
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "default": "",
            "description": "Its name then.",
            "type": "string"
          },
          "updated_at": {
            "default": "",
            "description": "Its `updated_at` then: the version of the set that answered.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "AgentRunCloseBody": {
        "properties": {
          "detail": {
            "type": "string"
          },
          "output": {
            "description": "Any JSON value; carried into the stored result verbatim."
          },
          "status": {
            "description": "Absent defaults to \"done\".",
            "enum": [
              "done",
              "failed",
              "canceled"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "AgentRunEventsBody": {
        "description": "One ledger event object ({row, ...} or {log: \"...\"} or {done: true, ...}) or a JSON array of them. The same events may be sent as application/x-ndjson instead, one object per line; lmgw reads the raw body either way, whatever its Content-Type. A line or entry it cannot parse is skipped and counted in the response's rejected list, and never fails the whole call.",
        "items": {
          "type": "object"
        },
        "type": [
          "object",
          "array"
        ]
      },
      "AgentRunSummary": {
        "description": "One `agent_run` job as the Runs tab lists it.\n\nThe universal job fields plus the run's own `detail`/`result`, whose inner\nshape belongs to the executor rather than to this DTO — the same\nsplit `JobView` already makes for every other job kind.",
        "properties": {
          "agent_id": {
            "type": "string"
          },
          "cost_micro": {
            "description": "What those tokens cost, in micro-units of the gateway's currency.\n`None` is \"nobody could price this\", which is also not zero.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "detail": {},
          "done": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "duration_ms": {
            "description": "Wall clock from claim to finish. `None` while it is still going.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "job_id": {
            "format": "int64",
            "type": "integer"
          },
          "model_calls": {
            "description": "The model calls the run made, from its result: calls answered without\nan error. `None` until it has a result. `Some(0)` with no `cost_micro`\nand no tokens is a run that had nothing to price; `Some(0)` can also\ncome with a cost, from calls that failed or were stopped after their\nrows were priced.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "percent": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "phase": {
            "description": "`list`, `classify`, `rerun` or `apply`.",
            "type": "string"
          },
          "stage": {
            "type": "string"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "`queued | running | done | failed | canceled`.",
            "type": "string"
          },
          "tokens": {
            "description": "Prompt + completion tokens the run spent, from its result.\n`None` until it has one — \"not known yet\", which is not zero.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "total": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "job_id",
          "agent_id",
          "phase",
          "status",
          "done",
          "total",
          "percent",
          "stage",
          "detail",
          "tokens",
          "cost_micro",
          "model_calls",
          "duration_ms",
          "error",
          "created_at",
          "started_at",
          "finished_at"
        ],
        "type": "object"
      },
      "AgentRuntime": {
        "description": "What a `container` agent runs under.\n\nEvery limit is here with its default printed next to it on the Run tab:\na container's bounds are shown, never guessed, like a run's tool-call and\nwall-clock budget. `0` means \"no\nlimit\" everywhere except `stop_grace_seconds`, where it means SIGKILL at\nonce — the page says which.",
        "properties": {
          "cpus": {
            "format": "double",
            "type": "number"
          },
          "deadline_seconds": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "image": {
            "type": "string"
          },
          "memory_mb": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "output_validated": {
            "description": "The phases whose `output` event is validated against a declared schema.\nA phase absent here is unvalidated, which the Run tab says out loud\nrather than leaving the reader to assume a check that is not happening.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "phases": {
            "description": "Which phases the image implements, in declaration order.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "pids": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "podman": {
            "description": "`podman --version` answered on this box.",
            "type": "boolean"
          },
          "podman_note": {
            "description": "Why it did not, when it did not.",
            "type": "string"
          },
          "pull": {
            "description": "`never` | `missing` | `always`.",
            "type": "string"
          },
          "read_only": {
            "type": "boolean"
          },
          "stop_grace_seconds": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "image",
          "pull",
          "phases",
          "memory_mb",
          "cpus",
          "pids",
          "deadline_seconds",
          "stop_grace_seconds",
          "read_only",
          "output_validated",
          "podman",
          "podman_note"
        ],
        "type": "object"
      },
      "AgentService": {
        "description": "Service mode as the App tab describes it.\n\nEverything a bound here is read from is a manifest field with its value\nprinted: the idle window, the start timeout and the health path are the\nmanifest's, and `0` means what it says everywhere else — never idle-stop,\nand wait as long as the start takes.",
        "properties": {
          "container": {
            "type": "string"
          },
          "health_path": {
            "description": "`run.service.health_path`. Empty = a TCP connect instead of an HTTP GET.",
            "type": "string"
          },
          "host_port": {
            "description": "The host port this start published on — ephemeral, per start. `0` when\nnothing is running.",
            "format": "uint16",
            "maximum": 65535,
            "minimum": 0,
            "type": "integer"
          },
          "idle_seconds": {
            "description": "`0` = never idle-stop, exactly as an MCP server's `idle_seconds` means it.",
            "format": "int64",
            "type": "integer"
          },
          "idle_seconds_now": {
            "description": "How long ago the last proxied request finished. `None` when nothing is\nrunning.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "in_flight": {
            "description": "Requests in flight, which is what the idle sweep skips on.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "log_tail": {
            "description": "The container's own log tail, read while it is running. Empty when\nnothing is up — `podman logs` on a container that is gone has nothing to\nsay.",
            "type": "string"
          },
          "log_tail_lines": {
            "description": "How many lines `log_tail` is at most, printed beside\nit so nobody has to guess whether they are seeing all of it.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "mounts": {
            "description": "The host mounts this agent's container holds, in the manifest's field order and\nonly the ones that are bound.\n\nThe App tab lists them. `host` is filled for an `Admin` reader and left\nout for the container reading its own row, which is told\n`/lmgw/mounts/<field>` and nothing else.",
            "items": {
              "$ref": "#/components/schemas/AgentServiceMount"
            },
            "type": "array"
          },
          "origin": {
            "description": "The origin this agent's UI is served on, as a URL with its slash:\n`http://board.localhost:8001/`. The container's\nown `LMGW_APP_ORIGIN` is the same origin *without* the slash — an\norigin to concatenate onto, rather than an `href`.",
            "type": "string"
          },
          "origin_resolves": {
            "description": "`<id>.<suffix>` resolves on the machine lmgw is running on — the server\nasked the resolver when it rendered this. False is not an error: the\nApp tab prints the `/etc/hosts` line that fixes it, and Chrome and\nFirefox resolve `*.localhost` regardless of what the system says.",
            "type": "boolean"
          },
          "port": {
            "description": "The in-container port the manifest declares.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "provides_mcp": {
            "description": "`run.provides.mcp`, when declared: the path inside the container that\nspeaks MCP, registered as the `agent:<id>` server.",
            "type": [
              "string",
              "null"
            ]
          },
          "running": {
            "description": "The container is up and answering.",
            "type": "boolean"
          },
          "start_timeout_seconds": {
            "description": "`0` = wait as long as the container takes.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "started_at": {
            "description": "When the running container was started.",
            "type": [
              "string",
              "null"
            ]
          },
          "starting": {
            "description": "A start is in flight right now.",
            "type": "boolean"
          }
        },
        "required": [
          "port",
          "health_path",
          "idle_seconds",
          "start_timeout_seconds",
          "provides_mcp",
          "origin",
          "origin_resolves",
          "starting",
          "running",
          "host_port",
          "container",
          "started_at",
          "idle_seconds_now",
          "in_flight",
          "log_tail",
          "log_tail_lines",
          "mounts"
        ],
        "type": "object"
      },
      "AgentServiceMount": {
        "description": "One bound mount as a reader is shown it.",
        "properties": {
          "access": {
            "description": "`ro` | `rw`, as the manifest declared it.",
            "type": "string"
          },
          "field": {
            "description": "The config field that names the slot.",
            "type": "string"
          },
          "host": {
            "description": "The canonical host path — **`Admin` only**. `None` is what the agent's\nown view sees, and it is absent from the JSON rather than empty: a\ncontainer is not told there is a path it is not being given.",
            "type": "string"
          },
          "inside": {
            "description": "`/lmgw/mounts/<field>` — what the container sees, for every reader.",
            "type": "string"
          },
          "kind": {
            "description": "`directory` | `file`, from the field's `format`.",
            "type": "string"
          }
        },
        "required": [
          "field",
          "inside",
          "kind",
          "access"
        ],
        "type": "object"
      },
      "AgentToken": {
        "description": "The agent's credential as the detail page describes it.",
        "properties": {
          "has_value": {
            "description": "A token has been minted. `false` until the first run or the first Copy\ntoken: an agent that is never run never mints a credential.",
            "type": "boolean"
          },
          "name": {
            "description": "`agent:<id>` — the name Logs and the usage page print.",
            "type": "string"
          },
          "scope_note": {
            "description": "The derived scope in words — \"token: any model\", or the aliases it is\nfenced to. Shown next to Copy token so the scope is never invisible.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "has_value",
          "scope_note"
        ],
        "type": "object"
      },
      "AgentWarning": {
        "description": "One warning that is not a tool gap.\n\nBeside `requires`, of the same shape and rendered in the same place. The\nStart gate is `requires_ok` **and** no warning with `blocks_start`.",
        "properties": {
          "blocks_start": {
            "type": "boolean"
          },
          "code": {
            "description": "A stable identifier — `container_without_image`, `podman_unavailable`,\n`image_absent_pull_never`, `local_image_on_import`,\n`secrets_dir_fallback`, `install_image_mismatch`, `dev_url_active`.",
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message",
          "blocks_start"
        ],
        "type": "object"
      },
      "AlignedWord": {
        "description": "One aligned word.",
        "properties": {
          "char_end": {
            "description": "One past the word's last matched letter or digit in `text`, in the\nsame units as `char_start`: the span is `[char_start, char_end)`.",
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "char_start": {
            "description": "Where the word starts in `text`, counted in Unicode scalar values\n(not bytes, not UTF-16 units). The span is matched on letters and\ndigits only, case-insensitively, in order: `Nuova,` and `Nuova` both\ncover the five letters of `Nuova` in the transcript. Absent, with\n`char_end`, for a word that could not be found in the transcript.",
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "confidence": {
            "description": "How sure the model is, when it says (several families send `0`\nfor every word, which means \"not computed\", not \"unsure\").",
            "format": "float",
            "type": [
              "number",
              "null"
            ]
          },
          "end": {
            "description": "Where the word ends in the clip, in seconds; as `start`.",
            "format": "double",
            "type": "number"
          },
          "end_sample": {
            "description": "`end` in samples; as `start_sample`.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "start": {
            "description": "Where the word starts in the clip, in seconds. Taken from the model,\nor computed from `start_sample` and `sample_rate` when it sends only\nsamples.",
            "format": "double",
            "type": "number"
          },
          "start_sample": {
            "description": "`start` in samples of `sample_rate`: as the model answered, or\ncomputed from the seconds when the rate is known. Absent when the\nmodel sends none and the rate is unknown.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "word": {
            "description": "The word as the model reported it, punctuation and all (CrisperWhisper\nkeeps the comma on `Nuova,`, Qwen3's aligner strips it).",
            "type": "string"
          }
        },
        "required": [
          "word",
          "start",
          "end"
        ],
        "type": "object"
      },
      "AnthropicCompaction": {
        "description": "`compaction`: on-demand compaction (the top-level `compaction`), and\nwhich of its types work.",
        "properties": {
          "summarize": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`context_editing.compaction` names `summarize`."
          },
          "supported": {
            "description": "An Anthropic route (lmgw's `context_editing` is present) whose\ncatalog names an on-demand compaction type for the model\n(`context_editing.compaction`): the field goes out as written and\nthe `compaction` block comes back as it came. Unpublished is `false`.",
            "type": "boolean"
          }
        },
        "required": [
          "supported",
          "summarize"
        ],
        "type": "object"
      },
      "AnthropicContextManagement": {
        "description": "`context_management`: whether a request's `context_management` reaches\nthe model, and which of its edit types work.",
        "properties": {
          "clear_thinking_20251015": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`context_management.edits` names `clear_thinking_20251015`."
          },
          "clear_tool_uses_20250919": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`context_management.edits` names `clear_tool_uses_20250919`."
          },
          "compact_20260112": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`context_management.edits` names `compact_20260112`: the edit goes\nout as written and the `compaction` block Anthropic answers with\ncomes back as it came."
          },
          "supported": {
            "description": "An Anthropic route, which sends `context_management` on as written\n(lmgw's `context_editing` is present), whose catalog says the model\ntakes it (`context_editing.supported` is `true`); unpublished is\n`false`.",
            "type": "boolean"
          }
        },
        "required": [
          "supported",
          "clear_thinking_20251015",
          "clear_tool_uses_20250919",
          "compact_20260112"
        ],
        "type": "object"
      },
      "AnthropicCountTokensRequest": {
        "additionalProperties": true,
        "properties": {
          "messages": {
            "items": {
              "properties": {
                "content": {
                  "description": "A string, or an array of blocks: {type:text,text}, {type:image,source:{type:base64,media_type,data} | {type:url,url}}, {type:tool_use,id,name,input} (the id as lmgw gave it: a Gemini model's carries its thought signature and runs to hundreds of characters; echo it exactly, and do not send it to another provider directly), {type:tool_result,tool_use_id,content,is_error}, {type:thinking,thinking,signature} (replayed; unsigned when lmgw itself produced it). Every other block type (redacted_thinking, the provider's own tool blocks, a type newer than lmgw) goes to an Anthropic upstream as written; any other upstream is sent none of it, and x-lmgw-params-ignored names it as content.<type>. A block without a type is refused with 400. A custom tool without input_schema (a server tool) is refused with 400."
                },
                "role": {
                  "enum": [
                    "user",
                    "assistant"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          },
          "output_config": {
            "additionalProperties": true,
            "type": "object"
          },
          "system": {
            "description": "A string, or an array of {type:text,text} blocks."
          },
          "thinking": {
            "additionalProperties": true,
            "type": "object"
          },
          "tool_choice": {
            "description": "{type:auto|any|none|tool}."
          },
          "tools": {
            "items": {
              "properties": {
                "description": {
                  "type": "string"
                },
                "input_schema": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "input_schema"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "AnthropicCountTokensResponse": {
        "properties": {
          "context_management": {
            "additionalProperties": true,
            "description": "Anthropic's own count of the input before the request's context edits ({original_input_tokens}), as it reported it. Only on an Anthropic model's count of a request with context_management.",
            "type": "object"
          },
          "input_tokens": {
            "type": "integer"
          }
        },
        "required": [
          "input_tokens"
        ],
        "type": "object"
      },
      "AnthropicEffort": {
        "description": "`effort`: whether `output_config.effort` reaches the model, and which\nlevels it takes.",
        "properties": {
          "high": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`reasoning.levels` contains `high`."
          },
          "low": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`reasoning.levels` contains `low`."
          },
          "max": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`reasoning.levels` contains `max`."
          },
          "medium": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`reasoning.levels` contains `medium`."
          },
          "supported": {
            "description": "The model has selectable effort levels (`reasoning.kind` is\n`levels`): a request's `output_config.effort` reaches it.",
            "type": "boolean"
          },
          "xhigh": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`reasoning.levels` contains `xhigh`."
          }
        },
        "required": [
          "supported",
          "low",
          "medium",
          "high",
          "xhigh",
          "max"
        ],
        "type": "object"
      },
      "AnthropicError": {
        "properties": {
          "error": {
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "description": "e.g. invalid_request_error, not_found_error, permission_error, overloaded_error, api_error.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "message"
            ],
            "type": "object"
          },
          "type": {
            "enum": [
              "error"
            ],
            "type": "string"
          }
        },
        "required": [
          "type",
          "error"
        ],
        "type": "object"
      },
      "AnthropicMessage": {
        "properties": {
          "content": {
            "items": {
              "additionalProperties": true,
              "description": "{type:text,text} | {type:tool_use,id,name,input}; a leading {type:thinking,thinking} block when the completion carried reasoning (unsigned: produced by lmgw, not by Anthropic); a leading {type:compaction,content,signature,…} block exactly as an Anthropic model answered a compaction (send it back unchanged).",
              "type": "object"
            },
            "type": "array"
          },
          "context_management": {
            "additionalProperties": true,
            "description": "The context management an Anthropic model applied ({applied_edits: [...]}), as Anthropic reported it; a stream carries it on its closing message_delta. Absent from every other model's answer.",
            "type": "object"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "role": {
            "enum": [
              "assistant"
            ],
            "type": "string"
          },
          "stop_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "stop_sequence": {
            "type": "null"
          },
          "type": {
            "enum": [
              "message"
            ],
            "type": "string"
          },
          "usage": {
            "properties": {
              "cache_creation_input_tokens": {
                "description": "Present only when the upstream reported cache writes.",
                "type": "integer"
              },
              "cache_read_input_tokens": {
                "description": "Present only when the upstream reported a cache read.",
                "type": "integer"
              },
              "input_tokens": {
                "type": "integer"
              },
              "iterations": {
                "description": "An Anthropic model's per-iteration usage, as it reported it (a compaction entry for a compaction it ran, which the top-level counts leave out). Present only when the upstream reported it.",
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              "output_tokens": {
                "type": "integer"
              }
            },
            "required": [
              "input_tokens",
              "output_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "type",
          "role",
          "model",
          "content",
          "stop_reason",
          "stop_sequence",
          "usage"
        ],
        "type": "object"
      },
      "AnthropicMessagesRequest": {
        "additionalProperties": true,
        "properties": {
          "compaction": {
            "additionalProperties": true,
            "description": "Anthropic's on-demand compaction ({type: summarize}; send its beta flag in anthropic-beta). To an Anthropic model it goes as written, and the compaction block Anthropic answers with comes back as it wrote it (stop_reason compaction). Every other model's provider has no equivalent: it is left out and named in x-lmgw-params-ignored. A model's capabilities.context_editing.compaction says which types it takes.",
            "type": "object"
          },
          "context_management": {
            "additionalProperties": true,
            "description": "Anthropic's context management ({edits: [...]}; send its beta flag in anthropic-beta). To an Anthropic model it goes as written, and Anthropic answers for it; a compaction edit (compact_…) included, whose compaction block comes back as Anthropic wrote it. Every other model's provider has no equivalent: it is left out and named in x-lmgw-params-ignored. A model's capabilities.context_editing on GET /v1/models says what it takes.",
            "type": "object"
          },
          "max_tokens": {
            "type": "integer"
          },
          "messages": {
            "items": {
              "properties": {
                "content": {
                  "description": "A string, or an array of blocks: {type:text,text}, {type:image,source:{type:base64,media_type,data} | {type:url,url}}, {type:tool_use,id,name,input} (the id as lmgw gave it: a Gemini model's carries its thought signature and runs to hundreds of characters; echo it exactly, and do not send it to another provider directly), {type:tool_result,tool_use_id,content,is_error}, {type:thinking,thinking,signature} (replayed; unsigned when lmgw itself produced it). Every other block type (redacted_thinking, the provider's own tool blocks, a type newer than lmgw) goes to an Anthropic upstream as written; any other upstream is sent none of it, and x-lmgw-params-ignored names it as content.<type>. A block without a type is refused with 400. A custom tool without input_schema (a server tool) is refused with 400."
                },
                "role": {
                  "enum": [
                    "user",
                    "assistant"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          },
          "output_config": {
            "description": "lmgw reads output_config.effort as the same reasoning tier x-lmgw-reasoning-effort sets, and output_config.format ({type:json_schema, schema}; the deprecated top-level output_format too) as the structured output every upstream gets in its own spelling. Its refusals are 400 invalid_request_error with the upstream's message. To an OpenAI model the schema goes with strict: true (this format guarantees the schema), so OpenAI's strict-mode rules apply — every property in required, additionalProperties false — and a schema that breaks them comes back as OpenAI's invalid_json_schema refusal, its message kept.",
            "properties": {
              "effort": {
                "type": "string"
              },
              "format": {
                "additionalProperties": true,
                "type": "object"
              }
            },
            "type": "object"
          },
          "stop_sequences": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "stream": {
            "default": false,
            "type": "boolean"
          },
          "system": {
            "description": "A string, or an array of {type:text,text} blocks, joined with blank lines."
          },
          "temperature": {
            "type": "number"
          },
          "thinking": {
            "additionalProperties": true,
            "description": "{type:enabled,budget_tokens} | {type:disabled} | {type:adaptive} (enabled, no budget — \"think as much as judged necessary\") | {type:between_tools} (no up-front thinking: an off that goes to an Anthropic model as written; every other model gets its own off, and x-lmgw-reasoning-ignored names between_tools). Any other type is refused with 400. display goes to an Anthropic model inside adaptive and enabled; beside an off, and to every other model, it is left out and x-lmgw-params-ignored names thinking.display.",
            "type": "object"
          },
          "tool_choice": {
            "description": "{type:auto|any|none|tool} (tool also carries name)."
          },
          "tools": {
            "description": "Custom tools only (input_schema required); a server tool (web_search, computer use, …) is refused with 400.",
            "items": {
              "properties": {
                "description": {
                  "type": "string"
                },
                "input_schema": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "input_schema"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "top_k": {
            "type": "integer"
          },
          "top_p": {
            "type": "number"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "AnthropicModel": {
        "properties": {
          "capabilities": {
            "$ref": "#/components/schemas/AnthropicModelCapabilities"
          },
          "context_window": {
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "lifecycle": {
            "description": "Always active: a model lmgw lists is one it serves.",
            "enum": [
              "active"
            ],
            "type": "string"
          },
          "max_input_tokens": {
            "description": "Alias of context_window, under the name the Anthropic SDK types it by.",
            "type": "integer"
          },
          "max_output_tokens": {
            "type": "integer"
          },
          "max_tokens": {
            "description": "Alias of max_output_tokens.",
            "type": "integer"
          },
          "notes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "pricing": {
            "properties": {
              "completion": {
                "type": "string"
              },
              "prompt": {
                "description": "USD per prompt token, as a decimal string; \"0\" for a local model.",
                "type": "string"
              }
            },
            "required": [
              "prompt",
              "completion"
            ],
            "type": "object"
          },
          "type": {
            "enum": [
              "model"
            ],
            "type": "string"
          }
        },
        "required": [
          "type",
          "id",
          "display_name",
          "created_at",
          "lifecycle"
        ],
        "type": "object"
      },
      "AnthropicModelCapabilities": {
        "description": "lmgw's own capabilities object (as on the OpenAI shape, where an absent field means unknown) plus Anthropic's ten capability blocks. In the blocks, supported: true means a /v1/messages request using the feature works on this model through lmgw; false means lmgw does not serve it yet or does not know — Anthropic's schema has no unknown.",
        "properties": {
          "batch": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "Always `false` yet: lmgw serves no `/v1/messages/batches` yet."
          },
          "citations": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "Always `false` yet. A `document` or `search_result` block reaches an\nAnthropic-protocol route as the client wrote it and an answer's\ncitations come back to a Messages client (gateway design §6.1,\n\"Citations\", 2026-11-06), but lmgw does not read the catalog's\n`citations` block yet, so it cannot say per model."
          },
          "code_execution": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "Always `false` yet: the code execution tool is a server tool, which\nthe Messages ingress refuses."
          },
          "compaction": {
            "$ref": "#/components/schemas/AnthropicCompaction"
          },
          "context_editing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ContextEditingCaps"
              },
              {
                "type": "null"
              }
            ],
            "description": "Anthropic's context management (`context_management` on\n`/v1/messages`: context editing and threshold compaction, and the\ntop-level on-demand `compaction`), under a name of its\nown because the Anthropic-shaped model entry puts Anthropic's\n`context_management` block beside lmgw's object. Present only on an\nAnthropic-protocol route, the one route that sends a request's\n`context_management` on as written; every other route leaves it out\nand names it in `x-lmgw-params-ignored`."
          },
          "context_management": {
            "$ref": "#/components/schemas/AnthropicContextManagement"
          },
          "effort": {
            "$ref": "#/components/schemas/AnthropicEffort"
          },
          "endpoints": {
            "description": "The lmgw routes that accept this model id.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "image_input": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`vision` is `true` and the model is served on `/v1/messages`, whose\ningress takes `image` blocks (base64 and URL sources)."
          },
          "input_modalities": {
            "description": "Subset of `text`, `image`, `audio`, `video`, `file`, `pdf`,\n`embedding`. `pdf` is a catalog's word (Anthropic's `pdf_input`,\nKilo's and OpenRouter's modality).\nAbsent = unknown, never \"none\".",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "languages": {
            "description": "ISO 639-1 codes (a few three-letter ones, `yue`) of the languages a\nlocal audio model works in, whatever its task: speech, recognition,\nalignment. A request's `language` takes them (lmgw sends each in the\nmodel's own spelling). Absent when the model's package names none\nas codes; see `multilingual` for a family that says only that it\ncovers many.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "multilingual": {
            "description": "The model's family says it is multilingual without listing codes\n(\"multilingual\", \"80+ languages\"): it works in more languages than\n`languages` names, which then holds few or none. Absent otherwise;\nabsent along with `languages` means unknown, never \"one language\".",
            "type": [
              "boolean",
              "null"
            ]
          },
          "output_modalities": {
            "description": "The same vocabulary, plus `decisions`: what a decision model answers\nwith (llama.cpp's and OpenRouter's word). A client that checks\nllama.cpp's `architecture.output_modalities` for `decisions` reads\nthis list instead. Absent = unknown.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "pdf_input": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "An Anthropic-protocol route (`context_editing` present) to a model\nwhose catalog says `pdf_input` (`input_modalities` holds `pdf`): a\n`document` block reaches it as the client wrote it, base64, URL or\nFiles API source (gateway design §6.1, \"Anthropic blocks lmgw does\nnot model\"). `false` on every other route, which is sent no\n`document` block."
          },
          "reasoning": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ReasoningCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "server_tools": {
            "$ref": "#/components/schemas/AnthropicServerTools"
          },
          "source": {
            "description": "Where the facts came from: `gguf+config`, `catalog`, `config`, or\n`owner` (an alias's capabilities override).",
            "type": "string"
          },
          "speech": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SpeechCaps"
              },
              {
                "type": "null"
              }
            ],
            "description": "A text-to-speech model's expressive controls — what `instructions`,\ninline tags, `language` and `stream_format` do on it\n(the speech capabilities object). A local audio model's is derived; a\ncloud alias has one only through an alias's capabilities override."
          },
          "structured_output": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/StructuredOutputCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "structured_outputs": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`structured_output.json_schema` is `true`: the ingress reads\n`output_config.format` (and the older `output_format`) of type\n`json_schema`."
          },
          "task": {
            "description": "`chat` | `embedding` | `rerank` | `decision` (a decision model,\nanswering on `/v1/systemone`) | `tts` | `asr` | an audio.cpp task\nname | an image task | `realtime` (an OpenAI Realtime model, no lmgw\nroute). Determines `endpoints`.",
            "type": "string"
          },
          "thinking": {
            "$ref": "#/components/schemas/AnthropicThinking"
          },
          "tool_calls": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ToolCallCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "vision": {
            "description": "`input_modalities` contains `image`. Redundant with the list on\npurpose: a client can read this one boolean to decide whether to\nsend images, e.g. whether a session gets a screenshot tool. Absent\nexactly when `input_modalities` is absent.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "task",
          "endpoints",
          "source",
          "batch",
          "citations",
          "code_execution",
          "compaction",
          "context_management",
          "effort",
          "image_input",
          "pdf_input",
          "server_tools",
          "structured_outputs",
          "thinking"
        ],
        "type": "object"
      },
      "AnthropicServerTools": {
        "description": "`server_tools`: Anthropic's server-run tools.",
        "properties": {
          "code_execution": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "The code execution server tool; `false` yet, as `supported`."
          },
          "supported": {
            "description": "Always `false` yet: the Messages ingress refuses every tool without an\n`input_schema` (a server tool) before any upstream sees it.",
            "type": "boolean"
          },
          "web_search": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "The web search server tool; `false` yet, as `supported`."
          }
        },
        "required": [
          "supported",
          "code_execution",
          "web_search"
        ],
        "type": "object"
      },
      "AnthropicStreamEvent": {
        "additionalProperties": true,
        "description": "SSE event: <type>, data: <this object>, one per line of the sequence above.",
        "properties": {
          "type": {
            "enum": [
              "message_start",
              "content_block_start",
              "content_block_delta",
              "content_block_stop",
              "message_delta",
              "message_stop",
              "error"
            ],
            "type": "string"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "AnthropicSupport": {
        "description": "One Anthropic capability: `{\"supported\": bool}`.",
        "properties": {
          "supported": {
            "description": "`true` only when a `/v1/messages` request using this feature works on\nthis model through lmgw; `false` when lmgw does not serve it yet or\ndoes not know.",
            "type": "boolean"
          }
        },
        "required": [
          "supported"
        ],
        "type": "object"
      },
      "AnthropicThinking": {
        "description": "`thinking`.",
        "properties": {
          "supported": {
            "description": "The model reasons: `reasoning.kind` is `toggle` or `levels`, or\n`fixed` with `enabled: true`.",
            "type": "boolean"
          },
          "types": {
            "$ref": "#/components/schemas/AnthropicThinkingTypes",
            "description": "Which `thinking` types work; all `false` when `supported` is."
          }
        },
        "required": [
          "supported",
          "types"
        ],
        "type": "object"
      },
      "AnthropicThinkingTypes": {
        "description": "`thinking.types`: which of Messages' `thinking` types work.",
        "properties": {
          "adaptive": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`{\"type\": \"adaptive\"}` (lmgw's bare \"on\") makes the model think. On\nan Anthropic route, which sends it as thinking type adaptive: the\nmodel's catalog names the type (`reasoning.thinking_types`). Elsewhere:\nits default is on, or \"on\" reaches it (the template's\n`enable_thinking` on a local row)."
          },
          "between_tools": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`{\"type\": \"between_tools\"}` (no up-front thinking) reaches a model\nthat takes it: on an Anthropic route, which sends the type as\nwritten, the model's catalog names it (`reasoning.thinking_types`).\nElsewhere `false`: those routes send their own off instead, and say\nso in `x-lmgw-reasoning-ignored`."
          },
          "disabled": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`{\"type\": \"disabled\"}` switches thinking off\n(`reasoning.can_disable` is `true`; on an Anthropic route, the\ncatalog's `thinking.types.disabled`)."
          },
          "enabled": {
            "$ref": "#/components/schemas/AnthropicSupport",
            "description": "`{\"type\": \"enabled\", \"budget_tokens\": n}`: the budget reaches the\nmodel. On an Anthropic route, which forwards the budget form as\nwritten: the model's catalog names the type\n(`reasoning.thinking_types`). Elsewhere: `reasoning.control` names\n`x-lmgw-reasoning-budget`."
          }
        },
        "required": [
          "adaptive",
          "between_tools",
          "disabled",
          "enabled"
        ],
        "type": "object"
      },
      "ApiError": {
        "description": "Uniform error body for every non-2xx `/api` response.",
        "properties": {
          "code": {
            "description": "Stable machine-readable code, e.g. `not_found`, `invalid_input`.",
            "type": "string"
          },
          "message": {
            "description": "Human-readable description, shown verbatim in the UI.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "AppliedToCurrent": {
        "description": "What a folder patch applied to the folder's current thread (`applied`\nin the patch's answer): the thread and the settings it changed, as the\nthread settings name them (`temperature`, `voice.tts_alias`).",
        "properties": {
          "fields": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "thread_id",
          "fields"
        ],
        "type": "object"
      },
      "ApprovalDecision": {
        "description": "One verdict.",
        "properties": {
          "approval_request_id": {
            "type": "string"
          },
          "approve": {
            "type": "boolean"
          },
          "reason": {
            "description": "Why, for a declined call: the model reads \"The user declined this\ntool call: <reason>\".",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "approval_request_id",
          "approve"
        ],
        "type": "object"
      },
      "ApprovalRequest": {
        "description": "One call that waits for an approval.",
        "properties": {
          "approval_request_id": {
            "description": "The id a decision quotes (`mcpr_…`), unique in the gateway.",
            "type": "string"
          },
          "arguments": {
            "description": "The arguments as the model wrote them: a JSON string.",
            "type": "string"
          },
          "call_id": {
            "description": "The call's id, as its `ready` and `result` frames carry it\n(`mcp_apps::ToolReadyFrame::call_id`). Absent from an lmgw\nbefore 2026-10-09, and from an `ApprovalRequest` read off a bound\nsession's `mcp_approval_request` item (OpenAI's shape has none):\nthere the `lmgw.chat.frame` relaying the `approval` frame has it.",
            "type": "string"
          },
          "name": {
            "description": "The tool's own name: the name the model called, without its\nlabel's `<prefix>__`.",
            "type": "string"
          },
          "server_label": {
            "description": "The thread's label the tool came from.",
            "type": "string"
          }
        },
        "required": [
          "approval_request_id",
          "server_label",
          "name",
          "arguments"
        ],
        "type": "object"
      },
      "ApprovalRequested": {
        "description": "`approval.requested`: a turn in the thread stopped on a call that waits\nfor an approval (client-apps design §6.5). Rendered from the reply's\npending state at delivery; a reply gone by then (deleted, regenerated),\nor a call decided by then (its `approval.decided` follows),\nis not delivered. With `thread_title`, `server_label`, `name` and\n`arguments` a client shows it, or a notification, without a fetch. Also\nthe shape of `Hello::open_approvals`' entries.",
        "properties": {
          "approval_request_id": {
            "type": "string"
          },
          "arguments": {
            "description": "A JSON string.",
            "type": "string"
          },
          "call_id": {
            "description": "The call's id, as the turn's `ready`, `approval` and `result` frames\ncarry it. Absent from an lmgw before 2026-10-09.",
            "type": "string"
          },
          "message_id": {
            "description": "The reply that waits.",
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "description": "The tool's own name, as `chat_approvals::ApprovalRequest`.",
            "type": "string"
          },
          "server_label": {
            "type": "string"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          },
          "thread_title": {
            "description": "The thread's title at delivery (in `hello`, at the head it read).",
            "type": "string"
          }
        },
        "required": [
          "thread_id",
          "thread_title",
          "message_id",
          "approval_request_id",
          "server_label",
          "name",
          "arguments"
        ],
        "type": "object"
      },
      "AttachmentFacts": {
        "additionalProperties": true,
        "description": "What extraction found in an attachment (`AttachmentMeta::meta`): which\nkeys are there depends on the kind. A key a gateway version adds is kept\nbeside these, so a reader never loses it.",
        "properties": {
          "class": {
            "description": "A PDF's class: `text`, `scanned` or `hybrid`.",
            "enum": [
              "text",
              "scanned",
              "hybrid"
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "format": {
            "description": "An office file's or audio clip's format, as sniffed (`docx`, `wav`, ...).",
            "type": [
              "string",
              "null"
            ]
          },
          "media": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MediaFacts"
              },
              {
                "type": "null"
              }
            ],
            "description": "A file an image or audio tool made: the model, its parameters and\ntimes (chat-media-tools design §9)."
          },
          "pages": {
            "description": "A PDF's page count.",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "parts": {
            "description": "How many parts an office file has.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "sheets": {
            "description": "A spreadsheet's sheet names.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "textless": {
            "description": "A PDF's pages without a text layer, numbered from 1.",
            "items": {
              "format": "uint32",
              "minimum": 0,
              "type": "integer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "tokens": {
            "description": "The extracted text's token estimate (text, PDF, office files and\ntranscribed audio).",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "transcript_alias": {
            "description": "The speech-to-text alias that wrote an audio clip's transcript.",
            "type": [
              "string",
              "null"
            ]
          },
          "transcript_error": {
            "description": "Why an audio clip's transcription failed, until a retry succeeds.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "AttachmentMeta": {
        "description": "One attachment's metadata, never its bytes.",
        "properties": {
          "blockers": {
            "description": "For a draft: why it cannot be sent to the thread's current model.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "call_id": {
            "description": "The tool call that made a `tool` file, or the card action that made\nan `action` file (its `act-<boot>-<n>` id, the one its stream's\nframes carried); absent for an upload.",
            "type": "string"
          },
          "extracted_tokens": {
            "description": "The extracted text's token estimate; `null` when there is none.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "hints": {
            "description": "For a draft: what it becomes on the way, sent all the same (an image\nas a placeholder, a PDF's pages as its text) under a fallback that\ncannot see.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "kind": {
            "description": "`image`, `pdf`, `text`, `audio`, ... as the upload was classified.",
            "type": "string"
          },
          "meta": {
            "$ref": "#/components/schemas/AttachmentFacts",
            "description": "What extraction found: pages, text-less pages, class, sheets,\ntranscript alias or error, tokens. `{}` for an image."
          },
          "mime": {
            "type": "string"
          },
          "mode": {
            "description": "A text-class PDF's choice, `text` or `images`; `null` when it does\nnot apply or is not chosen yet.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "size": {
            "description": "Size in bytes.",
            "format": "int64",
            "type": "integer"
          },
          "source": {
            "description": "Where the file came from: `upload` (the user sent it), `tool` (an\nimage or audio tool of a turn made it) or `action` (an image card's\naction made it).",
            "enum": [
              "upload",
              "tool",
              "action"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "kind",
          "name",
          "mime",
          "size",
          "mode",
          "meta",
          "extracted_tokens",
          "source"
        ],
        "type": "object"
      },
      "AudioAlignmentsRequest": {
        "description": "multipart/form-data only — lmgw's own route (for models whose row has task \"align\"), not an OpenAI shape.",
        "properties": {
          "file": {
            "format": "binary",
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "file",
          "model",
          "text"
        ],
        "type": "object"
      },
      "AudioInputMode": {
        "anyOf": [
          {
            "const": "off",
            "description": "The chat model reads the transcript.",
            "type": "string"
          },
          {
            "const": "on",
            "description": "A chat model that takes audio hears the turn; the transcript is\nmade beside it.",
            "type": "string"
          }
        ],
        "description": "Whether a voice turn may reach the chat model as audio."
      },
      "AudioInputShown": {
        "description": "`audio_input`: the setting, the level it came from, and the verdict.",
        "properties": {
          "blocked": {
            "$ref": "#/components/schemas/AudioInputVerdict",
            "description": "The verdict a GPU block would bring: its fallback's, or the refusal\nwhen there is none. Absent unless no block is live now and one would\nhand the turn elsewhere."
          },
          "lead": {
            "description": "What handed the turn to `model` when the resolve swapped (\"under the\nGPU hold\"). Absent when nothing did.",
            "type": "string"
          },
          "model": {
            "description": "The model the turn goes to: the thread's, or the fallback a block hands\nit to.",
            "type": "string"
          },
          "path": {
            "$ref": "#/components/schemas/InputPath",
            "description": "`audio` when the model hears the turn, `transcript` otherwise."
          },
          "source": {
            "$ref": "#/components/schemas/VoiceSource",
            "description": "The level `value` came from."
          },
          "value": {
            "$ref": "#/components/schemas/AudioInputMode",
            "description": "The setting in effect."
          },
          "why": {
            "description": "Why the transcript, in the page's words; `null` on the audio path.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "value",
          "source",
          "path",
          "model",
          "why"
        ],
        "type": "object"
      },
      "AudioInputVerdict": {
        "description": "Where a voice turn's words go: as audio, or as the transcript and why.",
        "properties": {
          "blocked": {
            "$ref": "#/components/schemas/AudioInputVerdict",
            "description": "The verdict a GPU block would bring: its fallback's, or the refusal\nwhen there is none. Absent unless no block is live now and one would\nhand the turn elsewhere."
          },
          "lead": {
            "description": "What handed the turn to `model` when the resolve swapped (\"under the\nGPU hold\"). Absent when nothing did.",
            "type": "string"
          },
          "model": {
            "description": "The model the turn goes to: the thread's, or the fallback a block hands\nit to.",
            "type": "string"
          },
          "path": {
            "$ref": "#/components/schemas/InputPath",
            "description": "`audio` when the model hears the turn, `transcript` otherwise."
          },
          "why": {
            "description": "Why the transcript, in the page's words; `null` on the audio path.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "path",
          "model",
          "why"
        ],
        "type": "object"
      },
      "AudioSpeechRequest": {
        "additionalProperties": true,
        "description": "OpenAI's TTS shape plus audio.cpp's own request options, forwarded with model rewritten to the upstream's own id; a row's configured voice presets apply on top. input may carry inline tags ([laughs], or a stage direction such as (sighs)): rendered by a model whose capabilities.speech.inline_tags says so, stripped everywhere else — never read out. An input of nothing but tags is 400 empty_input, refused before any model is started.",
        "properties": {
          "input": {
            "description": "The text. A local model whose engine refuses a character its package lacks (Supertonic) is sent an equivalent it has in its place, or nothing; the x-lmgw-speech response header names each one. An input left with nothing to say (a lone emoji) is 400 empty_input, refused before any model is started.",
            "type": "string"
          },
          "instructions": {
            "description": "A speaking style, or the description a voice-design model builds its voice from (required there: 400 instructions_required without one, unless the row has a default). Dropped for a model that reads none: capabilities.speech.instructions says which, and the x-lmgw-speech response header says when.",
            "type": "string"
          },
          "language": {
            "description": "An ISO 639-1 code or BCP-47 tag; a local model gets it in its own vocabulary.",
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "response_format": {
            "type": "string"
          },
          "speed": {
            "type": "number"
          },
          "stream_format": {
            "description": "Streams PCM16 (with response_format pcm) as speech.audio.delta events (sse) or as raw chunked PCM (audio). A local model streams only when its row runs in streaming mode; an offline row is 400 streaming_unsupported before anything starts (capabilities.speech.streaming says which). The x-lmgw-sample-rate response header states the PCM's rate.",
            "enum": [
              "sse",
              "audio"
            ],
            "type": "string"
          },
          "voice": {
            "description": "A row's own voice preset id, when it defines any (GET /v1/audio/voices). A voice-library clip with no transcript, for a model that cannot clone one without, is 400 voice_needs_transcript before anything starts (lmgw.needs_transcript in the voice list); send reference_text, or transcribe the clip in the dashboard's Audio lab. A local model whose audio.cpp image lacks eSpeak NG is 400 audio_image_lacks_espeak.",
            "type": "string"
          }
        },
        "required": [
          "model",
          "input"
        ],
        "type": "object"
      },
      "AudioTiming": {
        "description": "The engine's own account of one inference. Each figure is absent when the\nengine leaves it out.",
        "properties": {
          "audio_duration_ms": {
            "description": "Milliseconds of audio the engine processed.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "rtf": {
            "description": "Real-time factor: `wall_ms` over `audio_duration_ms`; below 1 is\nfaster than real time.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "wall_ms": {
            "description": "Wall-clock milliseconds of the inference.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "AudioTranscription": {
        "additionalProperties": true,
        "properties": {
          "text": {
            "type": "string"
          }
        },
        "required": [
          "text"
        ],
        "type": "object"
      },
      "AudioTranscriptionDetails": {
        "additionalProperties": true,
        "description": "The same transcription, plus the detail arrays the plain route leaves out.",
        "properties": {
          "segments": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "speaker_turns": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "text": {
            "type": "string"
          },
          "words": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "text"
        ],
        "type": "object"
      },
      "AudioTranscriptionsRequest": {
        "description": "multipart/form-data (also accepted as application/json with the same fields but no upload: instead of file, audio names a clip by its path on the model server's own filesystem, e.g. /models/clip.wav, and the body is relayed with model rewritten; the multipart form is what real clients send).",
        "properties": {
          "file": {
            "format": "binary",
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "response_format": {
            "type": "string"
          },
          "temperature": {
            "type": "number"
          }
        },
        "required": [
          "file",
          "model"
        ],
        "type": "object"
      },
      "AudioVoices": {
        "additionalProperties": true,
        "description": "lmgw's own route. A local audio model is answered from lmgw's catalog without starting it (?probe=engine asks its own server, starting it); a remote one is asked.",
        "properties": {
          "lmgw": {
            "description": "Only on a local audio model answered from lmgw's catalog (x-lmgw-voices-source: config).",
            "properties": {
              "default": {
                "description": "What speaks when a request names no voice.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "engine_asked": {
                "type": "boolean"
              },
              "entries": {
                "items": {
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "enum": [
                        "preset",
                        "library",
                        "native",
                        "embedding"
                      ],
                      "type": "string"
                    },
                    "send": {
                      "description": "Where lmgw puts the name in the engine's request; clients always send it as `voice`.",
                      "enum": [
                        "voice",
                        "options.voice_id"
                      ],
                      "type": "string"
                    },
                    "transcript": {
                      "description": "A library clip's transcript is recorded.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "send"
                  ],
                  "type": "object"
                },
                "type": "array"
              },
              "held": {
                "description": "The GPU hold (or a benchmark run) holds the card and the model has no fallback: the list stands, its speech is refused (503 gpu_hold) until the hold is released.",
                "type": "boolean"
              },
              "missing": {
                "description": "Voices the spec names whose file the package lacks.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "needs_transcript": {
                "description": "The model cannot clone a library clip without its transcript: speech with an entry whose `transcript` is false is refused (400 voice_needs_transcript) until it has one (the dashboard's Audio lab, Transcribe).",
                "type": "boolean"
              },
              "source": {
                "enum": [
                  "config"
                ],
                "type": "string"
              }
            },
            "required": [
              "source",
              "engine_asked",
              "held",
              "entries",
              "default",
              "missing",
              "needs_transcript"
            ],
            "type": "object"
          },
          "voices": {
            "description": "Every name the model answers to as `voice`, sorted; for a probe of the engine or of a remote upstream, as that source sent it.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "voices"
        ],
        "type": "object"
      },
      "CancelKind": {
        "description": "What cancelling a running image job does (design §5.4).",
        "oneOf": [
          {
            "const": "native",
            "description": "The image server's own cancel: the job is dropped, the model stays.",
            "type": "string"
          },
          {
            "const": "restart",
            "description": "The image server cannot stop a running picture, and this call is the\nmodel's only request: lmgw stops its container, and the next picture\nloads it again.",
            "type": "string"
          },
          {
            "const": "abandon",
            "description": "The image server cannot stop a running picture, and another request\nuses the model: the call stops waiting, the picture finishes in the\nbackground and is thrown away.",
            "type": "string"
          }
        ]
      },
      "ChatCompletion": {
        "properties": {
          "choices": {
            "items": {
              "properties": {
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "index": {
                  "type": "integer"
                },
                "logprobs": {
                  "description": "Always null: lmgw relays no log probabilities yet. Present because OpenAI's schema requires the field.",
                  "type": "null"
                },
                "message": {
                  "properties": {
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_content": {
                      "type": "string"
                    },
                    "role": {
                      "enum": [
                        "assistant"
                      ],
                      "type": "string"
                    },
                    "tool_calls": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "role",
                    "content"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "index",
                "message",
                "finish_reason"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "chat.completion"
            ],
            "type": "string"
          },
          "usage": {
            "properties": {
              "completion_tokens": {
                "type": "integer"
              },
              "completion_tokens_details": {
                "description": "Present only when the upstream reported reasoning tokens.",
                "properties": {
                  "reasoning_tokens": {
                    "type": "integer"
                  }
                },
                "required": [
                  "reasoning_tokens"
                ],
                "type": "object"
              },
              "prompt_tokens": {
                "type": "integer"
              },
              "prompt_tokens_details": {
                "description": "Present only when the upstream reported prompt-cache counts, and each field only when reported: cached_tokens read from the cache, cache_write_tokens written to it. Both are part of prompt_tokens.",
                "properties": {
                  "cache_write_tokens": {
                    "type": "integer"
                  },
                  "cached_tokens": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "total_tokens": {
                "type": "integer"
              }
            },
            "required": [
              "prompt_tokens",
              "completion_tokens",
              "total_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices",
          "usage"
        ],
        "type": "object"
      },
      "ChatCompletionChunk": {
        "description": "One frame: `data: <this object>`, repeated, ending with the literal `data: [DONE]`.",
        "properties": {
          "choices": {
            "items": {
              "properties": {
                "delta": {
                  "properties": {
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_content": {
                      "type": "string"
                    },
                    "role": {
                      "enum": [
                        "assistant"
                      ],
                      "type": "string"
                    },
                    "tool_calls": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "index": {
                  "type": "integer"
                }
              },
              "required": [
                "index",
                "delta",
                "finish_reason"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "chat.completion.chunk"
            ],
            "type": "string"
          },
          "usage": {
            "description": "Only with stream_options.include_usage: null on every frame but the last, whose choices is [] and which carries the request's usage.",
            "properties": {
              "completion_tokens": {
                "type": "integer"
              },
              "completion_tokens_details": {
                "description": "Present only when the upstream reported reasoning tokens.",
                "properties": {
                  "reasoning_tokens": {
                    "type": "integer"
                  }
                },
                "required": [
                  "reasoning_tokens"
                ],
                "type": "object"
              },
              "prompt_tokens": {
                "type": "integer"
              },
              "prompt_tokens_details": {
                "description": "Present only when the upstream reported prompt-cache counts, and each field only when reported: cached_tokens read from the cache, cache_write_tokens written to it. Both are part of prompt_tokens.",
                "properties": {
                  "cache_write_tokens": {
                    "type": "integer"
                  },
                  "cached_tokens": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "total_tokens": {
                "type": "integer"
              }
            },
            "required": [
              "prompt_tokens",
              "completion_tokens",
              "total_tokens"
            ],
            "type": [
              "object",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "type": "object"
      },
      "ChatCompletionRequest": {
        "additionalProperties": true,
        "properties": {
          "chat_template_kwargs": {
            "additionalProperties": true,
            "description": "Only enable_thinking is read (llama-server's own template toggle, distinct from the protocol-neutral reasoning controls above); every key is forwarded verbatim.",
            "type": "object"
          },
          "frequency_penalty": {
            "type": "number"
          },
          "json_schema": {
            "additionalProperties": true,
            "description": "llama.cpp's own top-level schema; without a response_format, or next to a {type:text} one, it is read as response_format {type:json_schema} and sent in that spelling. Next to a grammar it is 400 bad_request, as llama-server refuses the pair.",
            "type": "object"
          },
          "max_completion_tokens": {
            "description": "Wins over max_tokens when both are sent.",
            "type": "integer"
          },
          "max_tokens": {
            "type": "integer"
          },
          "messages": {
            "items": {
              "additionalProperties": true,
              "properties": {
                "content": {
                  "description": "A string, or an array of parts: {type:text,text}, {type:image_url,image_url:{url}} (a plain URL or a data: URI), {type:input_audio,input_audio:{data,format}} (data: URI, or raw base64 with format required). A tool message keeps only its text, as OpenAI defines it; any other part is dropped with a WARN naming it."
                },
                "name": {
                  "description": "role: tool only. Forwarded as the tool result's name.",
                  "type": "string"
                },
                "reasoning_content": {
                  "description": "role: assistant only. Replayed as the leading reasoning part (also accepted spelled 'reasoning', as OpenRouter spells it; DeepSeek and llama.cpp use reasoning_content).",
                  "type": "string"
                },
                "role": {
                  "description": "system and developer are both treated as a system message; tool and function are both treated as a tool-result message.",
                  "enum": [
                    "system",
                    "developer",
                    "user",
                    "assistant",
                    "tool",
                    "function"
                  ],
                  "type": "string"
                },
                "tool_call_id": {
                  "description": "role: tool only.",
                  "type": "string"
                },
                "tool_calls": {
                  "description": "role: assistant only: [{id, type:function, function:{name, arguments: <JSON string>}}]. Send each id back as lmgw gave it: a Gemini model's call id carries the model's thought signature, which Gemini 3 refuses a replayed call without. Such ids run to hundreds of characters; echo them exactly, and do not send them to another provider directly (lmgw strips the signature there).",
                  "items": {
                    "additionalProperties": true,
                    "type": "object"
                  },
                  "type": "array"
                }
              },
              "required": [
                "role"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "description": "An alias, a local model id, a candidate alias, or 'prefix/…' to pass through to an exposed upstream.",
            "type": "string"
          },
          "presence_penalty": {
            "type": "number"
          },
          "reasoning": {
            "additionalProperties": true,
            "description": "lmgw extension, OpenRouter's shape: {effort, max_tokens, enabled, exclude}. Read for the reasoning tier and forwarded verbatim.",
            "type": "object"
          },
          "reasoning_budget_tokens": {
            "description": "lmgw extension: a thinking-token budget (also x-lmgw-reasoning-budget). Forwarded verbatim alongside thinking_budget_tokens — whichever spelling a llama-server version reads.",
            "type": "integer"
          },
          "reasoning_effort": {
            "description": "lmgw extension: an effort level, or 'none' for off — one spelling of the reasoning control (also x-lmgw-reasoning-effort, and reasoning.effort below); the header wins when both are sent.",
            "type": "string"
          },
          "response_format": {
            "additionalProperties": true,
            "description": "{type:text} | {type:json_object} | {type:json_schema, json_schema:{name, description, schema, strict}} — translated for every upstream: Anthropic output_config.format (json_schema only; json_object is refused with response_format_unsupported), Gemini responseMimeType + responseJsonSchema. A type the model's capabilities.structured_output flag says false is refused before any upstream call (400 response_format_unsupported, param response_format); a schema the upstream rejects is 400 invalid_json_schema with its message. Another type goes verbatim to OpenAI-compatible upstreams. Keys lmgw does not model, on the object and on json_schema, reach OpenAI-compatible and llama.cpp upstreams as sent.",
            "type": "object"
          },
          "seed": {
            "type": "integer"
          },
          "service_tier": {
            "description": "OpenAI's processing tier (auto, default, flex, priority, fast, scale, ultrafast), forwarded as sent; on an OpenAI platform row lmgw sends auto when it is unset, and prices the answer at the tier the answer reports. A request by a caller with a budget (its key's, or the gateway's) on a cloud model with no price on file for what it is billed in is refused before the send: 403 budget_unpriced, naming the model and the missing price. A flex request needs a flex price: no other tier's price bounds a flex answer's spend, which is cheaper.",
            "type": "string"
          },
          "stop": {
            "description": "A string, or an array of strings."
          },
          "stream": {
            "default": false,
            "type": "boolean"
          },
          "stream_options": {
            "description": "With stream: true, include_usage ends the stream with a chunk whose choices is [] and that carries usage; every other chunk then has usage: null. Without it no chunk carries usage. Not forwarded: lmgw asks the upstream for usage itself, for its request log.",
            "properties": {
              "include_usage": {
                "default": false,
                "type": "boolean"
              }
            },
            "type": "object"
          },
          "temperature": {
            "type": "number"
          },
          "thinking_budget_tokens": {
            "description": "Same as reasoning_budget_tokens; both are read and both stay in the forwarded body.",
            "type": "integer"
          },
          "tool_choice": {
            "description": "\"auto\" | \"none\" | \"required\" | {type:function,function:{name}}."
          },
          "tools": {
            "items": {
              "properties": {
                "function": {
                  "properties": {
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "parameters": {
                      "additionalProperties": true,
                      "type": "object"
                    }
                  },
                  "required": [
                    "name"
                  ],
                  "type": "object"
                },
                "type": {
                  "enum": [
                    "function"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "type",
                "function"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "top_k": {
            "description": "Not part of the OpenAI API, but accepted; llama.cpp supports it.",
            "type": "integer"
          },
          "top_p": {
            "type": "number"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "ChatCompletionStreamError": {
        "description": "The frame a stream carries instead of a chunk when the upstream fails after the first byte was sent.",
        "properties": {
          "error": {
            "properties": {
              "code": {
                "enum": [
                  "upstream"
                ],
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "type": {
                "enum": [
                  "api_error"
                ],
                "type": "string"
              }
            },
            "required": [
              "message",
              "type",
              "code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ChatKnowledgeBase": {
        "description": "One knowledge base, as the Chat shows it.",
        "properties": {
          "embed_resolvable": {
            "description": "Whether a model on the gateway still resolves to the base's pinned\nembedding model; without one a search is by keyword only.",
            "type": "boolean"
          },
          "files": {
            "description": "Its files, in any state.",
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "description": "Unique across the bases.",
            "type": "string"
          },
          "ready": {
            "description": "The files ingested and searchable.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "name",
          "files",
          "ready",
          "embed_resolvable"
        ],
        "type": "object"
      },
      "ChatKnowledgeFile": {
        "description": "The file a `ChatKnowledgeSource` shows.",
        "properties": {
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "kind": {
            "description": "What the bytes were sniffed as.",
            "type": "string"
          },
          "name": {
            "description": "The name it was uploaded under (a label, never a path).",
            "type": "string"
          },
          "pages": {
            "description": "Pages, slides or sheets, when the file has them.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "description": "`pending`, `ingesting`, `ready` or `failed`.",
            "enum": [
              "pending",
              "ingesting",
              "ready",
              "failed"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "status",
          "pages"
        ],
        "type": "object"
      },
      "ChatTool": {
        "description": "One tool a thread may tick.",
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "The exposed name (`docs__query`): what a thread's `allowed_tools`\nand `require_approval` name.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "description"
        ],
        "type": "object"
      },
      "ChatToolSource": {
        "description": "One toolset a thread may attach.",
        "properties": {
          "description": {
            "description": "A toolset's purpose in one line; empty for a server.",
            "type": "string"
          },
          "kind": {
            "description": "`builtin` (one of lmgw's own toolsets), `server` (a registered MCP\nserver) or `agent` (a service agent's tools).",
            "enum": [
              "builtin",
              "server",
              "agent"
            ],
            "type": "string"
          },
          "name": {
            "description": "A server's configured name; a toolset's label.",
            "type": "string"
          },
          "reason": {
            "description": "Why it offers nothing now, when it does not.",
            "type": [
              "string",
              "null"
            ]
          },
          "server_label": {
            "description": "What a thread's `mcp_tools` entry names: a toolset's own label, a\nserver's tool prefix, else its name.",
            "type": "string"
          },
          "status": {
            "description": "A server's connection now: `ready`, `connecting`, `error` or\n`stopped`. A built-in toolset is `ready` when it offers tools and\n`unavailable` when it offers none (`reason` says why).",
            "enum": [
              "ready",
              "connecting",
              "error",
              "stopped",
              "unavailable"
            ],
            "type": "string"
          },
          "tool_count": {
            "description": "The tools of it the caller may tick now: a built-in toolset's\n`tools`; a server's tools as last listed, the owner's\nswitched-off ones and those outside the caller's tool scope left out\n(`0` before it was first listed).",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "tools": {
            "description": "A built-in toolset's tools. Empty for a server:\n`GET /chat/api/tools/{label}` lists those, connecting it.",
            "items": {
              "$ref": "#/components/schemas/ChatTool"
            },
            "type": "array"
          }
        },
        "required": [
          "server_label",
          "kind",
          "name",
          "description",
          "status",
          "tool_count",
          "reason",
          "tools"
        ],
        "type": "object"
      },
      "ChoiceAnswer": {
        "properties": {
          "choice": {
            "description": "The most probable option.",
            "type": "string"
          },
          "confidence": {
            "description": "How certain the model is, derived from the probabilities.",
            "format": "double",
            "type": "number"
          },
          "probabilities": {
            "additionalProperties": {
              "format": "double",
              "type": "number"
            },
            "description": "Every option with its probability; they sum to 1.",
            "type": "object"
          }
        },
        "required": [
          "choice",
          "probabilities",
          "confidence"
        ],
        "type": "object"
      },
      "ChoiceQuestion": {
        "properties": {
          "criteria": {
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Each option with its description, or `null` when it needs none, in\nthe order the options are offered. TypeSafe takes up to 255; llama.cpp\nnames its own per-type limit when a request crosses it.",
            "type": "object"
          },
          "instructions": {
            "description": "The question: a string, an object or an array."
          }
        },
        "required": [
          "instructions",
          "criteria"
        ],
        "type": "object"
      },
      "ChunkSpan": {
        "description": "Where a chunk sits in its file, without its text.",
        "properties": {
          "heading_path": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "page": {
            "description": "1-based page, slide or sheet, when the file has them.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "seq": {
            "description": "The chunk's position in the file.",
            "format": "int64",
            "type": "integer"
          },
          "span_end": {
            "format": "int64",
            "type": "integer"
          },
          "span_start": {
            "description": "Byte range in the file's extracted text.",
            "format": "int64",
            "type": "integer"
          },
          "tokens": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "seq",
          "page",
          "heading_path",
          "span_start",
          "span_end",
          "tokens"
        ],
        "type": "object"
      },
      "CompletionRequest": {
        "additionalProperties": true,
        "description": "Forwarded to an OpenAI-protocol upstream verbatim (a llama.cpp row's response_format excepted, see there): this route refuses anything else (an Anthropic or Gemini alias gets 400 rather than a request its upstream cannot answer).",
        "properties": {
          "max_completion_tokens": {
            "type": "integer"
          },
          "max_tokens": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "n_predict": {
            "description": "llama.cpp spelling of max_tokens; folded into it for local models with a guard or a ladder.",
            "type": "integer"
          },
          "prompt": {
            "description": "A string, an array of strings, an array of token ids, or a mix of both."
          },
          "response_format": {
            "additionalProperties": true,
            "description": "As on /v1/chat/completions. llama.cpp's own /v1/completions reads no response_format, so for a llama.cpp row it is sent as the top-level json_schema that route reads; a type with no such spelling is 400 response_format_unsupported, and a JSON type next to a grammar 400 bad_request, with nothing sent.",
            "type": "object"
          },
          "stream": {
            "default": false,
            "type": "boolean"
          }
        },
        "required": [
          "model",
          "prompt"
        ],
        "type": "object"
      },
      "ContextEditingCaps": {
        "additionalProperties": false,
        "description": "The `context_editing` object of a model on an Anthropic route: what\nits provider's catalog says about Anthropic's context management\n(`capabilities.context_management` on Anthropic's own `/v1/models`).",
        "properties": {
          "compaction": {
            "description": "The top-level `compaction.type` values (on-demand compaction) the\nprovider says the model takes (`summarize`, …), sorted: its catalog's\n`capabilities.compaction`. lmgw sends the field on as written, and\nthe `compaction` block Anthropic answers with comes back as it came.\nOmitted when the provider names none.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "edits": {
            "description": "The `context_management.edits[].type` values the provider says the\nmodel takes, all of which lmgw sends on (`clear_thinking_20251015`,\n`clear_tool_uses_20250919`, `compact_20260112`, …), sorted. A\ncompaction edit's `compaction` answer block comes back as Anthropic\nsent it. Omitted when the provider names none.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "supported": {
            "description": "The provider says whether the model takes `context_management` at\nall. Absent when its catalog says nothing.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ContextExcerpt": {
        "description": "One retrieved excerpt, as a user message stores it.",
        "properties": {
          "chunk_id": {
            "type": "string"
          },
          "file": {
            "description": "The file's name when it was retrieved.",
            "type": "string"
          },
          "file_id": {
            "format": "int64",
            "type": "integer"
          },
          "file_sha": {
            "description": "The sha256 of the file version the chunk was cut from; empty for a\ncontext stored before it was kept.",
            "type": "string"
          },
          "heading_path": {
            "type": "string"
          },
          "kb": {
            "description": "The base's name when it was retrieved.",
            "type": "string"
          },
          "kb_id": {
            "format": "int64",
            "type": "integer"
          },
          "page": {
            "description": "1-based PDF page; `null` for other files.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "score": {
            "format": "float",
            "type": "number"
          },
          "span_end": {
            "format": "int64",
            "type": "integer"
          },
          "span_start": {
            "description": "Byte range in the file's extracted text.",
            "format": "int64",
            "type": "integer"
          },
          "text": {
            "description": "The chunk's text, verbatim.",
            "type": "string"
          },
          "tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "kb_id",
          "kb",
          "file_id",
          "file",
          "page",
          "chunk_id",
          "heading_path",
          "text",
          "score",
          "tokens",
          "span_start",
          "span_end",
          "file_sha"
        ],
        "type": "object"
      },
      "ContinueState": {
        "description": "Whether a thread's last reply can be continued, and why not.",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "ok",
          "reason"
        ],
        "type": "object"
      },
      "CountTokensRequest": {
        "description": "Routed by model exactly like the chat endpoints, so counting a cold local model's tokens starts its container. The key's alias scope applies: a refused count answers 403 key_scope and is logged; a successful count is not logged. No budget applies, neither the key's nor the gateway's: a count costs nothing.",
        "properties": {
          "input": {
            "type": "string"
          },
          "model": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "input"
        ],
        "type": "object"
      },
      "CountTokensResponse": {
        "properties": {
          "model": {
            "type": "string"
          },
          "tokens": {
            "type": "integer"
          }
        },
        "required": [
          "model",
          "tokens"
        ],
        "type": "object"
      },
      "CurrentReason": {
        "description": "Why `current` answered with a new thread.",
        "oneOf": [
          {
            "const": "first",
            "description": "The folder had no current thread (for a device key: none it can\nreach).",
            "type": "string"
          },
          {
            "const": "gone",
            "description": "Its current thread can no longer be continued in the folder. Only\nthe dashboard and admin keys are given this reason.",
            "type": "string"
          },
          {
            "const": "idle",
            "description": "Its current thread had no message for the folder's idle minutes.",
            "type": "string"
          },
          {
            "const": "requested",
            "description": "The caller asked for a new thread (`new: true`).",
            "type": "string"
          }
        ]
      },
      "DictatedVoice": {
        "additionalProperties": false,
        "description": "How a dictated message says it was dictated (`voice` of a send): the\nfacts of the transcribe answer, nothing a reply carries. Unknown fields\nare refused.",
        "properties": {
          "asr": {
            "description": "The speech-to-text alias that was asked.",
            "type": [
              "string",
              "null"
            ]
          },
          "asr_answered_by": {
            "description": "The alias that answered in its place, when a fallback did.",
            "type": [
              "string",
              "null"
            ]
          },
          "asr_ms": {
            "description": "How long the transcription took.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "audio_ms": {
            "description": "The recording's length.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "via": {
            "description": "Must be `dictation`: a realtime turn is written by the bound session\nand cannot be sent.",
            "type": "string"
          }
        },
        "required": [
          "via"
        ],
        "type": "object"
      },
      "EmbeddingsRequest": {
        "properties": {
          "dimensions": {
            "description": "Forwarded (Gemini: outputDimensionality). A route that answers with another length — llama-server has no such parameter — is refused with 400 rather than served full-length vectors.",
            "minimum": 1,
            "type": "integer"
          },
          "encoding_format": {
            "description": "Encoded by the gateway, whatever the upstream: base64 is the little-endian float32 bytes, as OpenAI serves it.",
            "enum": [
              "float",
              "base64"
            ],
            "type": "string"
          },
          "input": {
            "description": "A string, or an array of strings. Token-id arrays are refused with 400: an alias can route to a model with another tokenizer."
          },
          "model": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "input"
        ],
        "type": "object"
      },
      "EmbeddingsResponse": {
        "properties": {
          "data": {
            "items": {
              "properties": {
                "embedding": {
                  "description": "Floats, or a base64 string when encoding_format was base64.",
                  "oneOf": [
                    {
                      "items": {
                        "type": "number"
                      },
                      "type": "array"
                    },
                    {
                      "type": "string"
                    }
                  ]
                },
                "index": {
                  "type": "integer"
                },
                "object": {
                  "enum": [
                    "embedding"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "object",
                "index",
                "embedding"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "list"
            ],
            "type": "string"
          },
          "usage": {
            "properties": {
              "prompt_tokens": {
                "description": "What the model reported; 0 when it reported nothing.",
                "minimum": 0,
                "type": "integer"
              },
              "total_tokens": {
                "description": "The same number: embedding generates nothing.",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "prompt_tokens",
              "total_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "object",
          "model",
          "data",
          "usage"
        ],
        "type": "object"
      },
      "EnrolledDevice": {
        "description": "`Enrolment::device`.",
        "properties": {
          "id": {
            "description": "The device row's `api_keys.id`; re-pairing keeps it.",
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "description": "The device's name as lmgw gave it, without `device:`.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "type": "object"
      },
      "Example": {
        "additionalProperties": false,
        "description": "One static example exchange: what the user says, and how the model\nreplies. Both sides are non-empty.",
        "properties": {
          "reply": {
            "type": "string"
          },
          "user": {
            "type": "string"
          }
        },
        "required": [
          "user",
          "reply"
        ],
        "type": "object"
      },
      "ExportAttachment": {
        "description": "An attachment as the export carries it: its metadata, position and bytes.",
        "properties": {
          "blockers": {
            "description": "For a draft: why it cannot be sent to the thread's current model.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "call_id": {
            "description": "The tool call that made a `tool` file, or the card action that made\nan `action` file (its `act-<boot>-<n>` id, the one its stream's\nframes carried); absent for an upload.",
            "type": "string"
          },
          "created_at": {
            "description": "When it was uploaded.",
            "type": "string"
          },
          "data": {
            "description": "The file's bytes, base64 (standard alphabet, padded).",
            "type": "string"
          },
          "extracted": {
            "description": "The text extracted from it (a PDF's pages, an office file, an audio\nfile's transcript); `null` when there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "extracted_tokens": {
            "description": "The extracted text's token estimate; `null` when there is none.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "hints": {
            "description": "For a draft: what it becomes on the way, sent all the same (an image\nas a placeholder, a PDF's pages as its text) under a fallback that\ncannot see.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "kind": {
            "description": "`image`, `pdf`, `text`, `audio`, ... as the upload was classified.",
            "type": "string"
          },
          "meta": {
            "$ref": "#/components/schemas/AttachmentFacts",
            "description": "What extraction found: pages, text-less pages, class, sheets,\ntranscript alias or error, tokens. `{}` for an image."
          },
          "mime": {
            "type": "string"
          },
          "mode": {
            "description": "A text-class PDF's choice, `text` or `images`; `null` when it does\nnot apply or is not chosen yet.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "ord": {
            "description": "Its position among its message's files.",
            "format": "int64",
            "type": "integer"
          },
          "size": {
            "description": "Size in bytes.",
            "format": "int64",
            "type": "integer"
          },
          "source": {
            "description": "Where the file came from: `upload` (the user sent it), `tool` (an\nimage or audio tool of a turn made it) or `action` (an image card's\naction made it).",
            "enum": [
              "upload",
              "tool",
              "action"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "kind",
          "name",
          "mime",
          "size",
          "mode",
          "meta",
          "extracted_tokens",
          "source",
          "ord",
          "created_at",
          "extracted",
          "data"
        ],
        "type": "object"
      },
      "ExportMessage": {
        "description": "A message as the export carries it: the columns of a stored message with\nits `ir_messages` parsed, and the files sent with it.",
        "properties": {
          "answered_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "attachments": {
            "items": {
              "$ref": "#/components/schemas/ExportAttachment"
            },
            "type": "array"
          },
          "completion_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "content": {
            "type": "string"
          },
          "context": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MessageContext"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "images_note": {
            "type": "string"
          },
          "ir_messages": {
            "description": "An agentic turn's tool calls and results as the JSON value the\nrecord holds; `null` for a plain turn. When the record does not\nparse, its raw text and `ir_messages_unparsed: true`."
          },
          "ir_messages_unparsed": {
            "description": "Set (to `true`) only when `ir_messages` is the raw text of a record\nthat did not parse.",
            "type": "boolean"
          },
          "kb_refs": {
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "origin": {
            "description": "A user message's origin: where its client said the user wrote it.",
            "type": [
              "string",
              "null"
            ]
          },
          "prompt_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning": {
            "type": "string"
          },
          "role": {
            "description": "`user`, `assistant` or `tool`.",
            "type": "string"
          },
          "task": {
            "$ref": "#/components/schemas/MessageTask"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          },
          "voice": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MessageVoice"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "thread_id",
          "role",
          "content",
          "reasoning",
          "prompt_tokens",
          "completion_tokens",
          "ir_messages",
          "kb_refs",
          "context",
          "model",
          "answered_by",
          "voice",
          "origin",
          "created_at",
          "attachments"
        ],
        "type": "object"
      },
      "ExportRef": {
        "description": "A folder or personality profile named in an export.",
        "properties": {
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "type": "object"
      },
      "ExportThread": {
        "description": "A thread as the export carries it: the columns of the thread list's row\n(`ThreadRow`) except the two derived from other rows, `last_message_at`\nand `purge_at`.",
        "properties": {
          "agent_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "archived_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "folder_id": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "frequency_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "id": {
            "description": "Negative for a temporary thread.",
            "format": "int64",
            "type": "integer"
          },
          "kb_budget_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "kb_mode": {
            "$ref": "#/components/schemas/KbMode"
          },
          "kind": {
            "description": "`chat` or `admin`.",
            "type": "string"
          },
          "max_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "items": {
              "$ref": "#/components/schemas/ThreadMcp"
            },
            "type": "array"
          },
          "media_defaults": {
            "$ref": "#/components/schemas/MediaDefaults",
            "description": "The image and audio tools' default models of its own."
          },
          "min_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          },
          "presence_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_budget": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system_prompt": {
            "type": "string"
          },
          "temperature": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "temporary": {
            "description": "The thread was held in memory only (a temporary chat).",
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "top_k": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "updated_at": {
            "type": "string"
          },
          "voice": {
            "$ref": "#/components/schemas/ThreadVoice"
          }
        },
        "required": [
          "id",
          "title",
          "model_alias",
          "system_prompt",
          "temperature",
          "max_tokens",
          "top_p",
          "top_k",
          "min_p",
          "repeat_penalty",
          "presence_penalty",
          "frequency_penalty",
          "seed",
          "stop",
          "kind",
          "mcp_tools",
          "reasoning_enabled",
          "reasoning_effort",
          "reasoning_budget",
          "agent_id",
          "pinned",
          "archived_at",
          "folder_id",
          "profile_id",
          "kb_ids",
          "kb_mode",
          "kb_budget_tokens",
          "voice",
          "media_defaults",
          "created_at",
          "updated_at",
          "temporary"
        ],
        "type": "object"
      },
      "Fallback": {
        "description": "The fallback that answers for a blocked model, and whether it is a local\nmodel: a local one may be a fallback too, and answers where it may run\n(a row on the CPU under the hold).",
        "properties": {
          "alias": {
            "type": "string"
          },
          "local": {
            "type": "boolean"
          }
        },
        "required": [
          "alias",
          "local"
        ],
        "type": "object"
      },
      "FallbackUnusable": {
        "description": "A named hold fallback that cannot answer: `why` is the clause the hold's\nrefusal names it with (\"does not resolve\", \"is itself a candidate alias\").",
        "properties": {
          "alias": {
            "type": "string"
          },
          "why": {
            "type": "string"
          }
        },
        "required": [
          "alias",
          "why"
        ],
        "type": "object"
      },
      "FeedHold": {
        "description": "The GPU hold: whether local models are paused. A held model answers with\nits own fallback, where one is set (each thread's model says which). The\n`hold` event and part of `Hello`.",
        "properties": {
          "active": {
            "description": "The owner's GPU hold is on: models on the graphics card are paused.",
            "type": "boolean"
          },
          "benchmark": {
            "description": "A benchmark run holds the graphics card: every local model waits\nuntil it ends, one on the CPU too, or answers with its fallback\n(chat-plane design D6).",
            "type": "boolean"
          }
        },
        "required": [
          "active",
          "benchmark"
        ],
        "type": "object"
      },
      "FeedPrincipal": {
        "description": "Who the feed is for: its kind and the name it is known by, without the\nkind's prefix. A paired device is kind `device`, named as it was paired\n(\"desktop\", not \"device:desktop\"); the gateway's administrator has the\nother kind: the dashboard (named `dashboard`) or an admin key (named as\nthe key without its prefix).",
        "properties": {
          "kind": {
            "enum": [
              "device",
              "owner"
            ],
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "name"
        ],
        "type": "object"
      },
      "Folder": {
        "description": "A Chat folder as `GET /chat/api/folders` lists it, with its thread\ncounts as the caller may see them.",
        "properties": {
          "archive_days": {
            "description": "Days without activity before one of its threads is archived; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "defaults": {
            "$ref": "#/components/schemas/ThreadDefaults"
          },
          "devices_hidden": {
            "description": "Set when a device deleted this folder while it held threads that\ndevice could not see: the folder stays for them, hidden from every\ndevice, until it is shown to devices again from the dashboard. Always\n`false` for a device key, which never sees such a folder.",
            "type": "boolean"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "description": "Folder names need not be unique.",
            "type": "string"
          },
          "ongoing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FolderOngoing"
              },
              {
                "type": "null"
              }
            ],
            "description": "`null` for a folder that is not one ongoing conversation."
          },
          "purge_days": {
            "description": "Days after archiving before one of its threads is deleted; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "sort": {
            "description": "The folder's place in the list.",
            "format": "int64",
            "type": "integer"
          },
          "threads_active": {
            "format": "int64",
            "type": "integer"
          },
          "threads_archived": {
            "format": "int64",
            "type": "integer"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "sort",
          "defaults",
          "ongoing",
          "archive_days",
          "purge_days",
          "devices_hidden",
          "created_at",
          "updated_at",
          "threads_active",
          "threads_archived"
        ],
        "type": "object"
      },
      "FolderChanged": {
        "description": "`folder.created` / `folder.updated` for a folder that exists at\ndelivery: the folder as `GET /chat/api/folders` lists it now (its counts\nas the reader may see them), with `by` beside its fields.",
        "properties": {
          "archive_days": {
            "description": "Days without activity before one of its threads is archived; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "by": {
            "description": "Who made the change; `null` for the gateway's own.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "defaults": {
            "$ref": "#/components/schemas/ThreadDefaults"
          },
          "devices_hidden": {
            "description": "Set when a device deleted this folder while it held threads that\ndevice could not see: the folder stays for them, hidden from every\ndevice, until it is shown to devices again from the dashboard. Always\n`false` for a device key, which never sees such a folder.",
            "type": "boolean"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "description": "Folder names need not be unique.",
            "type": "string"
          },
          "ongoing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FolderOngoing"
              },
              {
                "type": "null"
              }
            ],
            "description": "`null` for a folder that is not one ongoing conversation."
          },
          "purge_days": {
            "description": "Days after archiving before one of its threads is deleted; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "sort": {
            "description": "The folder's place in the list.",
            "format": "int64",
            "type": "integer"
          },
          "threads_active": {
            "format": "int64",
            "type": "integer"
          },
          "threads_archived": {
            "format": "int64",
            "type": "integer"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "sort",
          "defaults",
          "ongoing",
          "archive_days",
          "purge_days",
          "devices_hidden",
          "created_at",
          "updated_at",
          "threads_active",
          "threads_archived",
          "by"
        ],
        "type": "object"
      },
      "FolderGone": {
        "description": "`folder.deleted`, and `folder.created` / `folder.updated` for a folder\nthat is gone by the time the event is delivered.",
        "properties": {
          "by": {
            "type": [
              "string",
              "null"
            ]
          },
          "deleted": {
            "type": "boolean"
          },
          "folder_id": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "folder_id",
          "deleted",
          "by"
        ],
        "type": "object"
      },
      "FolderOngoing": {
        "description": "The `ongoing` field of a folder: `null` for a folder that is not an\nongoing conversation.",
        "properties": {
          "current_thread_id": {
            "description": "The thread the conversation continues in; `null` until the first\n`current` call, after its thread was deleted, moved out of the\nfolder or archived by hand, and, for a device key, while the thread\nis out of the key's reach.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "idle_minutes": {
            "description": "Minutes without a message after which the next `current` call starts\na new thread. `0`: a new thread only when a client asks for one.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "idle_minutes",
          "current_thread_id"
        ],
        "type": "object"
      },
      "FolderRef": {
        "description": "A folder named by its id and name.",
        "properties": {
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "type": "object"
      },
      "HelloCert": {
        "description": "`Hello::cert`: the device certificate's dates, RFC 3339 UTC.",
        "properties": {
          "not_after": {
            "description": "When the certificate lapses.",
            "type": "string"
          },
          "notice_after": {
            "description": "From when the device says \"this certificate lapses on `<not_after>`;\npair it again before then\" (two thirds of its validity).",
            "type": "string"
          }
        },
        "required": [
          "not_after",
          "notice_after"
        ],
        "type": "object"
      },
      "ImageEditsRequest": {
        "description": "Refused unless the resolved model's row has its edit pipeline enabled.",
        "properties": {
          "image": {
            "description": "One or more image files. lmgw relays every multipart field named image verbatim, with no cardinality check of its own.",
            "items": {
              "format": "binary",
              "type": "string"
            },
            "type": "array"
          },
          "mask": {
            "format": "binary",
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "n": {
            "type": "integer"
          },
          "prompt": {
            "type": "string"
          },
          "size": {
            "type": "string"
          }
        },
        "required": [
          "image",
          "model",
          "prompt"
        ],
        "type": "object"
      },
      "ImageGenerationsRequest": {
        "additionalProperties": true,
        "description": "Other keys are forwarded for a cloud image upstream.",
        "properties": {
          "model": {
            "type": "string"
          },
          "n": {
            "type": "integer"
          },
          "output_compression": {
            "type": "integer"
          },
          "output_format": {
            "type": "string"
          },
          "prompt": {
            "description": "May carry a trailing <sd_cpp_extra_args>{…}</sd_cpp_extra_args> block of raw sd.cpp CLI arguments; the dashboard's Image lab builds this block and is the reference for its contents.",
            "type": "string"
          },
          "size": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "prompt"
        ],
        "type": "object"
      },
      "ImageGenerationsResponse": {
        "description": "The upstream's answer, relayed as it sends it: each image carries what response_format asked for, plus whatever else the upstream adds (revised_prompt).",
        "properties": {
          "created": {
            "type": "integer"
          },
          "data": {
            "items": {
              "anyOf": [
                {
                  "required": [
                    "b64_json"
                  ]
                },
                {
                  "required": [
                    "url"
                  ]
                }
              ],
              "description": "One image: b64_json, or url when the request asked for response_format url (an upstream's default, dall-e's, for instance).",
              "properties": {
                "b64_json": {
                  "type": "string"
                },
                "revised_prompt": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "created",
          "data"
        ],
        "type": "object"
      },
      "InputPath": {
        "anyOf": [
          {
            "const": "audio",
            "description": "The model heard the turn's audio.",
            "type": "string"
          },
          {
            "const": "transcript",
            "description": "The model read the speech-to-text transcript.",
            "type": "string"
          }
        ],
        "description": "How a voice turn's words reached the chat model."
      },
      "JsonRpcError": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "id": {},
          "jsonrpc": {
            "enum": [
              "2.0"
            ],
            "type": "string"
          }
        },
        "required": [
          "jsonrpc",
          "error"
        ],
        "type": "object"
      },
      "JsonRpcRequest": {
        "properties": {
          "id": {
            "description": "Absent on a notification (e.g. notifications/initialized); string or number otherwise."
          },
          "jsonrpc": {
            "enum": [
              "2.0"
            ],
            "type": "string"
          },
          "method": {
            "description": "e.g. initialize, ping, tools/list, tools/call, resources/list, resources/templates/list, resources/read, notifications/initialized.",
            "type": "string"
          },
          "params": {
            "additionalProperties": true,
            "type": "object"
          }
        },
        "required": [
          "jsonrpc",
          "method"
        ],
        "type": "object"
      },
      "JsonRpcResponse": {
        "properties": {
          "id": {},
          "jsonrpc": {
            "enum": [
              "2.0"
            ],
            "type": "string"
          },
          "result": {
            "additionalProperties": true,
            "type": "object"
          }
        },
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "type": "object"
      },
      "KbMode": {
        "anyOf": [
          {
            "const": "auto",
            "description": "Search before every turn and send the excerpts with the user's\nmessage.",
            "type": "string"
          },
          {
            "const": "tool",
            "description": "Give the model the knowledge search tools; it searches when it\ndecides to.",
            "type": "string"
          }
        ],
        "description": "How a thread's knowledge bases reach the model."
      },
      "LanguageNote": {
        "description": "A speech model its language does not reach as set — the ASR the spoken\nlanguage, the TTS the reply language: a thread's `voice_resolved.language_notes`,\nand Settings' `chat_voice_language_notes` for the Chat's own models.",
        "properties": {
          "alias": {
            "description": "The stage's alias.",
            "type": "string"
          },
          "message": {
            "description": "The whole sentence the page shows: the model, then what it does\n(\"text-to-speech model 'audio/…' takes no language: …\").",
            "type": "string"
          },
          "stage": {
            "description": "`asr` or `tts`.",
            "type": "string"
          }
        },
        "required": [
          "stage",
          "alias",
          "message"
        ],
        "type": "object"
      },
      "LiveTurn": {
        "description": "A turn answering a thread now, who started it, and whether it is a\nbound realtime session's voice turn.",
        "properties": {
          "by": {
            "type": "string"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          },
          "voice": {
            "type": "boolean"
          }
        },
        "required": [
          "thread_id",
          "by",
          "voice"
        ],
        "type": "object"
      },
      "LiveVoice": {
        "description": "A realtime session bound to a thread now, and who bound it (\"the\ndashboard\", \"device 'phone'\").",
        "properties": {
          "by": {
            "type": "string"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "thread_id",
          "by"
        ],
        "type": "object"
      },
      "LlamaCppError": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "description": "The HTTP status, repeated in the body as llama.cpp does.",
                "type": "integer"
              },
              "lmgw_code": {
                "description": "lmgw's own machine-readable error code, e.g. gpu_hold, gpu_benchmark, gpu_deferred, gpu_setup, engine_download.",
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "type": {
                "enum": [
                  "invalid_request_error",
                  "authentication_error",
                  "permission_error",
                  "not_found_error",
                  "not_supported_error",
                  "unavailable_error",
                  "server_error"
                ],
                "type": "string"
              }
            },
            "required": [
              "code",
              "message",
              "type",
              "lmgw_code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "McpServerDetail": {
        "properties": {
          "description": {
            "description": "A toolset's purpose; \"\" for a server.",
            "type": "string"
          },
          "kind": {
            "description": "builtin: lmgw's own toolsets (lmgw, for owner credentials only; docs; kb); server: a registered MCP server; agent: a service agent's tools.",
            "enum": [
              "builtin",
              "server",
              "agent"
            ],
            "type": "string"
          },
          "name": {
            "description": "A server's configured name; a toolset's label.",
            "type": "string"
          },
          "object": {
            "enum": [
              "mcp.server"
            ],
            "type": "string"
          },
          "server_label": {
            "description": "What goes into a {\"type\": \"mcp\", \"server_label\"} tool on /v1/realtime or /v1/responses: a built-in toolset's label, a registered server's tool prefix, else its name.",
            "type": "string"
          },
          "tools": {
            "items": {
              "properties": {
                "description": {
                  "description": "\"\" when the server gave none.",
                  "type": "string"
                },
                "input_schema": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "name": {
                  "description": "The server's own name for the tool: its exposed name minus the <prefix>__ namespace.",
                  "type": "string"
                }
              },
              "required": [
                "name",
                "description",
                "input_schema"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "object",
          "server_label",
          "kind",
          "name",
          "description",
          "tools"
        ],
        "type": "object"
      },
      "McpServerList": {
        "properties": {
          "data": {
            "items": {
              "properties": {
                "description": {
                  "description": "A toolset's purpose; \"\" for a server.",
                  "type": "string"
                },
                "kind": {
                  "description": "builtin: lmgw's own toolsets (lmgw, for owner credentials only; docs; kb); server: a registered MCP server; agent: a service agent's tools.",
                  "enum": [
                    "builtin",
                    "server",
                    "agent"
                  ],
                  "type": "string"
                },
                "name": {
                  "description": "A server's configured name; a toolset's label.",
                  "type": "string"
                },
                "object": {
                  "enum": [
                    "mcp.server"
                  ],
                  "type": "string"
                },
                "server_label": {
                  "description": "What goes into a {\"type\": \"mcp\", \"server_label\"} tool on /v1/realtime or /v1/responses: a built-in toolset's label, a registered server's tool prefix, else its name.",
                  "type": "string"
                }
              },
              "required": [
                "object",
                "server_label",
                "kind",
                "name",
                "description"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "object": {
            "enum": [
              "list"
            ],
            "type": "string"
          }
        },
        "required": [
          "object",
          "data"
        ],
        "type": "object"
      },
      "MediaAction": {
        "description": "What an image card's action does (design §8.3).",
        "oneOf": [
          {
            "const": "reroll",
            "description": "The same prompt and settings, a new seed.",
            "type": "string"
          },
          {
            "const": "vary",
            "description": "A variation (img2img) of the picture, on a row without `edit`.",
            "type": "string"
          },
          {
            "const": "edit",
            "description": "An instruction edit of the picture, on a row with `edit`.",
            "type": "string"
          },
          {
            "const": "upscale",
            "description": "An ESRGAN upscale of the picture.",
            "type": "string"
          }
        ]
      },
      "MediaChoice": {
        "description": "One model a media tool can use, as a picker lists it.",
        "properties": {
          "label": {
            "description": "What a person reads: the name, and what it is (its family, on this\nmachine, a cloud model via its upstream).",
            "type": "string"
          },
          "local": {
            "description": "One of lmgw's own rows rather than an alias.",
            "type": "boolean"
          },
          "name": {
            "description": "The name the tool's `model` takes and a default stores.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "label",
          "local"
        ],
        "type": "object"
      },
      "MediaChoices": {
        "description": "What each media tool can use, for the default pickers: the same rows\nand aliases its `model` enum lists for the caller.",
        "properties": {
          "edit": {
            "items": {
              "$ref": "#/components/schemas/MediaChoice"
            },
            "type": "array"
          },
          "generate": {
            "items": {
              "$ref": "#/components/schemas/MediaChoice"
            },
            "type": "array"
          },
          "speak": {
            "items": {
              "$ref": "#/components/schemas/MediaChoice"
            },
            "type": "array"
          },
          "transcribe": {
            "items": {
              "$ref": "#/components/schemas/MediaChoice"
            },
            "type": "array"
          },
          "voices": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "description": "The voices of each speech row, by its name; a cloud alias has none\nlisted (its voices are the provider's own).",
            "type": "object"
          }
        },
        "required": [
          "generate",
          "edit",
          "speak",
          "transcribe",
          "voices"
        ],
        "type": "object"
      },
      "MediaDefaults": {
        "additionalProperties": false,
        "description": "One level's default models, by tool (module doc).\n\nInput is strict (`deny_unknown_fields`): a write that names a field this\nbuild does not know is refused with the fields it does, rather than\nstored as nothing. A stored level is read through\n`MediaDefaults::from_stored`, which drops such a key on its own.",
        "properties": {
          "edit": {
            "description": "`image__edit`'s model.",
            "type": [
              "string",
              "null"
            ]
          },
          "generate": {
            "description": "`image__generate`'s model, as its `model` enum names it\n(`image/<id>` or an alias).",
            "type": [
              "string",
              "null"
            ]
          },
          "speak": {
            "description": "`audio__speak`'s model.",
            "type": [
              "string",
              "null"
            ]
          },
          "transcribe": {
            "description": "`audio__transcribe`'s model.",
            "type": [
              "string",
              "null"
            ]
          },
          "voice": {
            "description": "The voice `audio__speak` uses with the default speech model when a\ncall names none.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "MediaFacts": {
        "description": "The facts of a produced file, under `meta.media` of its attachment\n(design §9). Every field is optional: what a call did not have is left\nout, never guessed.",
        "properties": {
          "answered_by": {
            "description": "The model or alias that answered instead of `model`: its fallback,\nfor whatever reason it could not answer.",
            "type": [
              "string",
              "null"
            ]
          },
          "cfg": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "duration_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "height": {
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "job_ms": {
            "description": "The job's own time, `completed − started` (sd-server's job API).",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "language": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "description": "The model the call named (`image/z-image-turbo`).",
            "type": [
              "string",
              "null"
            ]
          },
          "negative_prompt": {
            "type": [
              "string",
              "null"
            ]
          },
          "not_applied": {
            "description": "What the answering route could not take and so did not apply\n(`seed`, `steps`, ...): a cloud fallback gets no smuggled parameters.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "parent": {
            "description": "The attachment this one was made from (a card action's source).",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "prompt": {
            "type": [
              "string",
              "null"
            ]
          },
          "scale": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "steps": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "strength": {
            "description": "A variation's strength.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "tool": {
            "description": "The tool that made it: `image__generate`, `audio__speak`, ...",
            "type": [
              "string",
              "null"
            ]
          },
          "upscaler": {
            "type": [
              "string",
              "null"
            ]
          },
          "voice": {
            "type": [
              "string",
              "null"
            ]
          },
          "wall_ms": {
            "description": "The call's whole time, loading included.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "width": {
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "MediaPhase": {
        "description": "What a running image or audio call is doing (`ToolProgressFrame::phase`).",
        "oneOf": [
          {
            "enum": [
              "speaking",
              "transcribing",
              "upscaling"
            ],
            "type": "string"
          },
          {
            "const": "downloading",
            "description": "The call's model's engine image is being downloaded before the model\ncan be loaded (machine-check design §5): `image`, `done_bytes`, and\n`total_bytes` where the size is known.",
            "type": "string"
          },
          {
            "const": "unloading",
            "description": "Another model is being stopped to make room: `model` names it.",
            "type": "string"
          },
          {
            "const": "loading",
            "description": "The call's own model is being brought onto the GPU.",
            "type": "string"
          },
          {
            "const": "waiting_for_room",
            "description": "Nothing more can be stopped yet: the call waits for memory\n(`needs_bytes`, `free_bytes`).",
            "type": "string"
          },
          {
            "const": "queued",
            "description": "The image server holds the job in its queue (`queue_position`).",
            "type": "string"
          },
          {
            "const": "generating",
            "description": "The picture is being drawn (`pass`, `step`, `total_steps`, `preview`\nwhere the image server reports them).",
            "type": "string"
          }
        ]
      },
      "MediaUnavailable": {
        "description": "A stored default that does not resolve now, and why: the model was\nswitched off or deleted, an alias lost the route, the caller's key may\nnot use it, a voice its model does not have.",
        "properties": {
          "field": {
            "description": "`generate`, `edit`, `speak`, `voice` or `transcribe`.",
            "type": "string"
          },
          "name": {
            "description": "The stored name.",
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "field",
          "name",
          "reason"
        ],
        "type": "object"
      },
      "Message": {
        "description": "One stored message of a thread.",
        "properties": {
          "answered_by": {
            "description": "The alias that actually answered, when it was not `model` (a\nfallback); `null` when `model` itself answered.",
            "type": [
              "string",
              "null"
            ]
          },
          "attachments": {
            "description": "The files sent with this message.",
            "items": {
              "$ref": "#/components/schemas/AttachmentMeta"
            },
            "type": "array"
          },
          "completion_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "content": {
            "type": "string"
          },
          "context": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MessageContext"
              },
              {
                "type": "null"
              }
            ],
            "description": "The retrieval that ran for this user message; `null` when none ran."
          },
          "created_at": {
            "description": "When the message was written (UTC, `YYYY-MM-DD HH:MM:SS`).",
            "type": "string"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "images_note": {
            "description": "For a reply that a fallback without sight answered: who, for which\nmodel, and what went to it in the images' place. Absent otherwise.",
            "type": "string"
          },
          "ir_messages": {
            "description": "An agentic turn's tool calls and results as JSON text; `null` for a\nplain chat turn.",
            "type": [
              "string",
              "null"
            ]
          },
          "kb_refs": {
            "description": "Knowledge bases picked with `#` for this user message only.",
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "model": {
            "description": "A reply's model: the alias its turn asked for. `null` on user\nmessages and on replies saved before it was recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "origin": {
            "description": "A user message's origin: the sentence its client sent with it about\nwhere the user wrote it (`origin` of the send or the edit), which\nthe model reads before the message's text. `null` when its client\nsent none, and on every other role.",
            "type": [
              "string",
              "null"
            ]
          },
          "pending_approvals": {
            "description": "The calls a gated turn's reply still waits on\n(`POST /chat/api/threads/{id}/approvals` decides them). Absent when\nnone wait.",
            "items": {
              "$ref": "#/components/schemas/ApprovalRequest"
            },
            "type": "array"
          },
          "prompt_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning": {
            "description": "A reasoning model's thinking trace; empty otherwise.",
            "type": "string"
          },
          "role": {
            "description": "`user`, `assistant`, or `tool` (a late MCP task result).",
            "type": "string"
          },
          "task": {
            "$ref": "#/components/schemas/MessageTask",
            "description": "On a late MCP task result (role `tool`): the task's facts. Absent\notherwise."
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          },
          "voice": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MessageVoice"
              },
              {
                "type": "null"
              }
            ],
            "description": "How the turn was spoken; `null` for a typed turn."
          }
        },
        "required": [
          "id",
          "thread_id",
          "role",
          "content",
          "reasoning",
          "prompt_tokens",
          "completion_tokens",
          "ir_messages",
          "kb_refs",
          "context",
          "model",
          "answered_by",
          "voice",
          "origin",
          "created_at",
          "attachments"
        ],
        "type": "object"
      },
      "MessageContext": {
        "description": "The retrieval that ran for one user message. Excerpt `n` in the\n`<context>` block (and `[n]` in the answer) is `excerpts[n - 1]`.",
        "properties": {
          "budget_tokens": {
            "description": "The budget the retrieval ran with.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "dropped": {
            "description": "Excerpts that ranked but did not fit the budget.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "excerpts": {
            "items": {
              "$ref": "#/components/schemas/ContextExcerpt"
            },
            "type": "array"
          },
          "kb_ids": {
            "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "ms": {
            "description": "How long the retrieval took.",
            "format": "double",
            "type": "number"
          },
          "notes": {
            "description": "Why something was not searched, or not fully: one sentence each.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "query": {
            "description": "What was searched for.",
            "type": "string"
          },
          "searched": {
            "description": "The bases that were searched, by name.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "tokens": {
            "description": "Tokens the excerpts use, heading paths included.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "excerpts",
          "tokens",
          "dropped",
          "budget_tokens",
          "notes",
          "searched",
          "kb_ids",
          "query",
          "ms"
        ],
        "type": "object"
      },
      "MessageTask": {
        "description": "What a result row says of its task: `task` on a message of role `tool`.",
        "properties": {
          "ended_by": {
            "description": "Who cancelled it, for a cancel lmgw sent (\"the dashboard\", \"device\n'phone'\"); `null` otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "server_label": {
            "description": "The label the tool was offered under when it was called.",
            "type": "string"
          },
          "status": {
            "description": "How it ended: `completed`, `failed`, `cancelled`, or `abandoned`\n(the server no longer knows it, or its server row was removed).",
            "enum": [
              "completed",
              "failed",
              "cancelled",
              "abandoned"
            ],
            "type": "string"
          },
          "structured_content": {
            "description": "The result's MCP `structuredContent`, for a view of the call\n(client-apps design §7.5): the model reads the result's `content`,\nand this only when the content was empty. Absent when the result\nhad none, and for a result stored by an earlier lmgw."
          },
          "task_id": {
            "description": "The server's id of the task.",
            "type": "string"
          },
          "tool": {
            "description": "The name the model called (`<label>__<tool>`).",
            "type": "string"
          }
        },
        "required": [
          "task_id",
          "server_label",
          "tool",
          "status",
          "ended_by"
        ],
        "type": "object"
      },
      "MessageVoice": {
        "description": "How a turn was spoken, on its message: `null` on the message for a typed\nturn. On a user message: how it was dictated or spoken in realtime mode,\nthe speech-to-text alias that was asked and the one that answered, and\nthe audio's length. On a spoken reply: the text-to-speech alias, the\nvoice, the part that was never heard and the turn's timing.",
        "properties": {
          "asr": {
            "type": "string"
          },
          "asr_answered_by": {
            "type": "string"
          },
          "asr_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "audio_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "input": {
            "$ref": "#/components/schemas/InputPath",
            "description": "On a user message: `audio` when the chat model heard the turn;\nabsent on the transcript path."
          },
          "timing": {
            "$ref": "#/components/schemas/VoiceTiming"
          },
          "transcript_error": {
            "description": "On a user message the model heard: why its transcription failed.",
            "type": "string"
          },
          "tts": {
            "type": "string"
          },
          "tts_answered_by": {
            "type": "string"
          },
          "unheard": {
            "description": "The reply's text after the heard part, shown behind a \"not heard\"\nmarker. Not in `content`, so the model never sees it.",
            "type": "string"
          },
          "via": {
            "description": "`dictation` or `realtime`.",
            "type": "string"
          },
          "voice": {
            "type": "string"
          }
        },
        "required": [
          "via"
        ],
        "type": "object"
      },
      "ModelById": {
        "description": "The OpenAiModel shape unless the caller sent anthropic-version, in which case AnthropicModel. No lmgw block on the single-model route.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/OpenAiModel"
          },
          {
            "$ref": "#/components/schemas/AnthropicModel"
          }
        ]
      },
      "ModelCapabilities": {
        "additionalProperties": false,
        "description": "The `capabilities` object of one model on `GET /v1/models`.\n\n`task`, `endpoints` and `source` are always present — they are what makes\nthe entry actionable at all (\"this id exists, here is where to send it,\nhere is how much to trust the rest\"). Everything else is absent unless a\nsource stated it.",
        "properties": {
          "context_editing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ContextEditingCaps"
              },
              {
                "type": "null"
              }
            ],
            "description": "Anthropic's context management (`context_management` on\n`/v1/messages`: context editing and threshold compaction, and the\ntop-level on-demand `compaction`), under a name of its\nown because the Anthropic-shaped model entry puts Anthropic's\n`context_management` block beside lmgw's object. Present only on an\nAnthropic-protocol route, the one route that sends a request's\n`context_management` on as written; every other route leaves it out\nand names it in `x-lmgw-params-ignored`."
          },
          "endpoints": {
            "description": "The lmgw routes that accept this model id.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "input_modalities": {
            "description": "Subset of `text`, `image`, `audio`, `video`, `file`, `pdf`,\n`embedding`. `pdf` is a catalog's word (Anthropic's `pdf_input`,\nKilo's and OpenRouter's modality).\nAbsent = unknown, never \"none\".",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "languages": {
            "description": "ISO 639-1 codes (a few three-letter ones, `yue`) of the languages a\nlocal audio model works in, whatever its task: speech, recognition,\nalignment. A request's `language` takes them (lmgw sends each in the\nmodel's own spelling). Absent when the model's package names none\nas codes; see `multilingual` for a family that says only that it\ncovers many.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "multilingual": {
            "description": "The model's family says it is multilingual without listing codes\n(\"multilingual\", \"80+ languages\"): it works in more languages than\n`languages` names, which then holds few or none. Absent otherwise;\nabsent along with `languages` means unknown, never \"one language\".",
            "type": [
              "boolean",
              "null"
            ]
          },
          "output_modalities": {
            "description": "The same vocabulary, plus `decisions`: what a decision model answers\nwith (llama.cpp's and OpenRouter's word). A client that checks\nllama.cpp's `architecture.output_modalities` for `decisions` reads\nthis list instead. Absent = unknown.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "reasoning": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ReasoningCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "description": "Where the facts came from: `gguf+config`, `catalog`, `config`, or\n`owner` (an alias's capabilities override).",
            "type": "string"
          },
          "speech": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SpeechCaps"
              },
              {
                "type": "null"
              }
            ],
            "description": "A text-to-speech model's expressive controls — what `instructions`,\ninline tags, `language` and `stream_format` do on it\n(the speech capabilities object). A local audio model's is derived; a\ncloud alias has one only through an alias's capabilities override."
          },
          "structured_output": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/StructuredOutputCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "task": {
            "description": "`chat` | `embedding` | `rerank` | `decision` (a decision model,\nanswering on `/v1/systemone`) | `tts` | `asr` | an audio.cpp task\nname | an image task | `realtime` (an OpenAI Realtime model, no lmgw\nroute). Determines `endpoints`.",
            "type": "string"
          },
          "tool_calls": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ToolCallCaps"
              },
              {
                "type": "null"
              }
            ]
          },
          "vision": {
            "description": "`input_modalities` contains `image`. Redundant with the list on\npurpose: a client can read this one boolean to decide whether to\nsend images, e.g. whether a session gets a screenshot tool. Absent\nexactly when `input_modalities` is absent.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "task",
          "endpoints",
          "source"
        ],
        "type": "object"
      },
      "ModelList": {
        "description": "OpenAiModelList unless the caller sent anthropic-version, in which case AnthropicModelList.",
        "oneOf": [
          {
            "properties": {
              "data": {
                "items": {
                  "$ref": "#/components/schemas/OpenAiModel"
                },
                "type": "array"
              },
              "lmgw": {
                "properties": {
                  "endpoints": {
                    "description": "Every path listed here exists in this API and carries the capability its own operation documents.",
                    "properties": {
                      "anthropic": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "openai": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "other": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      }
                    },
                    "required": [
                      "openai",
                      "anthropic",
                      "other"
                    ],
                    "type": "object"
                  },
                  "headers": {
                    "additionalProperties": {
                      "type": "string"
                    },
                    "type": "object"
                  },
                  "notes": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "version": {
                    "type": "string"
                  }
                },
                "required": [
                  "version",
                  "endpoints",
                  "headers",
                  "notes"
                ],
                "type": "object"
              },
              "object": {
                "enum": [
                  "list"
                ],
                "type": "string"
              }
            },
            "required": [
              "object",
              "data",
              "lmgw"
            ],
            "type": "object"
          },
          {
            "properties": {
              "data": {
                "items": {
                  "$ref": "#/components/schemas/AnthropicModel"
                },
                "type": "array"
              },
              "first_id": {
                "type": "null"
              },
              "has_more": {
                "enum": [
                  false
                ],
                "type": "boolean"
              },
              "last_id": {
                "type": "null"
              },
              "lmgw": {
                "properties": {
                  "endpoints": {
                    "description": "Every path listed here exists in this API and carries the capability its own operation documents.",
                    "properties": {
                      "anthropic": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "openai": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "other": {
                        "items": {
                          "type": "string"
                        },
                        "type": "array"
                      }
                    },
                    "required": [
                      "openai",
                      "anthropic",
                      "other"
                    ],
                    "type": "object"
                  },
                  "headers": {
                    "additionalProperties": {
                      "type": "string"
                    },
                    "type": "object"
                  },
                  "notes": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "version": {
                    "type": "string"
                  }
                },
                "required": [
                  "version",
                  "endpoints",
                  "headers",
                  "notes"
                ],
                "type": "object"
              }
            },
            "required": [
              "data",
              "has_more",
              "lmgw"
            ],
            "type": "object"
          }
        ]
      },
      "NoulAnswer": {
        "properties": {
          "noul": {
            "description": "P(yes), from 0 (no) to 1 (yes).",
            "format": "double",
            "type": "number"
          }
        },
        "required": [
          "noul"
        ],
        "type": "object"
      },
      "NoulCriteria": {
        "properties": {
          "false": {
            "description": "What a no means.",
            "type": [
              "string",
              "null"
            ]
          },
          "true": {
            "description": "What a yes means.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "NoulQuestion": {
        "properties": {
          "criteria": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/NoulCriteria"
              },
              {
                "type": "null"
              }
            ],
            "description": "What a yes and a no mean, when the question alone does not say."
          },
          "instructions": {
            "description": "The yes/no question: a string, an object or an array."
          }
        },
        "required": [
          "instructions"
        ],
        "type": "object"
      },
      "OngoingInput": {
        "additionalProperties": false,
        "description": "`ongoing` in a folder create or patch: an object marks the folder as one\nongoing conversation (its defaults must name a model), `null` ends that.",
        "properties": {
          "idle_minutes": {
            "description": "Minutes without a message after which a new thread starts; `0`: only\nwhen a client asks. A whole number of zero or more.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "idle_minutes"
        ],
        "type": "object"
      },
      "OpenAiError": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "description": "lmgw's own machine-readable error code (e.g. gpu_hold, gpu_benchmark, gpu_deferred, gpu_setup — a 503: the local model could not start on the graphics card, and the message says what on the computer lmgw runs on is not ready (fixed there, not by retrying), engine_download — a 502: the engine the local model runs in could not be downloaded, response_format_unsupported — the model or its upstream cannot produce the asked structured output type, invalid_json_schema — the upstream rejected the schema, its message kept, budget_unpriced — a budgeted caller's request on a cloud model with no price on file for what it is billed in, flex without a flex price among them), not the HTTP status.",
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "description": "The request field the error is about: response_format (chat completions, completions) or text.format (/v1/responses) for the codes response_format_unsupported and invalid_json_schema; null for every other error.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "type": {
                "description": "e.g. invalid_request_error, authentication_error, not_found_error, rate_limit_error, api_error.",
                "type": "string"
              }
            },
            "required": [
              "message",
              "type",
              "code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "OpenAiModel": {
        "properties": {
          "capabilities": {
            "$ref": "#/components/schemas/ModelCapabilities"
          },
          "context_length": {
            "type": "integer"
          },
          "created": {
            "description": "Stable for the life of the gateway process rather than the time of each request; the catalog's own timestamp when it has one.",
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "max_output_tokens": {
            "type": "integer"
          },
          "notes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "object": {
            "enum": [
              "model"
            ],
            "type": "string"
          },
          "owned_by": {
            "type": "string"
          },
          "pricing": {
            "properties": {
              "completion": {
                "type": "string"
              },
              "prompt": {
                "description": "USD per prompt token, as a decimal string; \"0\" for a local model.",
                "type": "string"
              }
            },
            "required": [
              "prompt",
              "completion"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "owned_by"
        ],
        "type": "object"
      },
      "PreviewTokens": {
        "description": "The token counts of a preview, through the universal counter.",
        "properties": {
          "alias": {
            "type": "string"
          },
          "answered_by": {
            "description": "The alias that counted, when it was not `alias` (a fallback).",
            "type": [
              "string",
              "null"
            ]
          },
          "approx": {
            "description": "How the counts are approximate, as `x-lmgw-count-approximate` says\nit; empty when they are exact.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "static": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "text_turn": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "voice_turn": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "alias",
          "answered_by",
          "static",
          "text_turn",
          "voice_turn",
          "approx"
        ],
        "type": "object"
      },
      "Profile": {
        "description": "A profile as `GET /chat/api/profiles` lists it.",
        "properties": {
          "builtin": {
            "description": "The built-in profile this row is (`concise`); `null` for one of the\nowner's own. Read only.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "examples": {
            "description": "Static example exchanges, in order.",
            "items": {
              "$ref": "#/components/schemas/Example"
            },
            "type": "array"
          },
          "follows_builtin": {
            "description": "The fields a built-in row takes from the built-in text, so they\nfollow its improvements. Read only.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "format": "int64",
            "type": "integer"
          },
          "length_rule": {
            "description": "How long replies are; empty for none.",
            "type": "string"
          },
          "name": {
            "description": "Unique in any case; never `default`.",
            "type": "string"
          },
          "persona": {
            "description": "Who the model is and how it sounds; empty for none. When set, it\ntakes the thread's system prompt's place.",
            "type": "string"
          },
          "reasoning": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Reasoning"
              },
              {
                "type": "null"
              }
            ],
            "description": "Reasoning on or off; `null` inherits."
          },
          "updated_at": {
            "type": "string"
          },
          "used_by": {
            "$ref": "#/components/schemas/UsedBy"
          },
          "voice": {
            "$ref": "#/components/schemas/ProfileVoice"
          },
          "voice_block": {
            "description": "The voice turn's block: `null` for the generic one, `\"\"` for none, a\ntext to use as it is.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "builtin",
          "persona",
          "length_rule",
          "examples",
          "voice_block",
          "reasoning",
          "voice",
          "follows_builtin",
          "used_by",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "ProfileDraft": {
        "additionalProperties": false,
        "description": "A profile's content fields, with nothing saved: what Preview, Test and\nSpeak take, and what a create fills in.",
        "properties": {
          "examples": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/Example"
            },
            "type": "array"
          },
          "length_rule": {
            "default": "",
            "type": "string"
          },
          "persona": {
            "default": "",
            "type": "string"
          },
          "reasoning": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Reasoning"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "voice": {
            "$ref": "#/components/schemas/ProfileVoiceInput",
            "default": {
              "speech_style": null,
              "tts_alias": null,
              "voice": null
            }
          },
          "voice_block": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ProfileVoice": {
        "additionalProperties": false,
        "description": "The speech part of a profile: the subset of a thread's voice settings a\nprofile carries, with the same checks and meanings. Each `null` inherits.",
        "properties": {
          "speech_style": {
            "description": "The speaking style the text-to-speech model is given; an empty text\nis none.",
            "type": [
              "string",
              "null"
            ]
          },
          "tts_alias": {
            "description": "The text-to-speech alias (task `tts` or `vdes`).",
            "type": [
              "string",
              "null"
            ]
          },
          "voice": {
            "description": "A voice of that text-to-speech model, or of the Chat's own when\n`tts_alias` is `null`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "tts_alias",
          "voice",
          "speech_style"
        ],
        "type": "object"
      },
      "ProfileVoiceInput": {
        "additionalProperties": false,
        "description": "The speech part of a profile: the subset of a thread's voice settings a\nprofile carries, with the same checks and meanings. Each `null` inherits.",
        "properties": {
          "speech_style": {
            "default": null,
            "description": "The speaking style the text-to-speech model is given; an empty text\nis none.",
            "type": [
              "string",
              "null"
            ]
          },
          "tts_alias": {
            "default": null,
            "description": "The text-to-speech alias (task `tts` or `vdes`).",
            "type": [
              "string",
              "null"
            ]
          },
          "voice": {
            "default": null,
            "description": "A voice of that text-to-speech model, or of the Chat's own when\n`tts_alias` is `null`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "RealtimeAvailability": {
        "description": "Whether voice mode may bind the thread.",
        "properties": {
          "admin_tools": {
            "description": "The thread carries lmgw's admin tools while the self-admin level is\n`full`: its tools can change lmgw. Shown, never a refusal.",
            "type": "boolean"
          },
          "code": {
            "description": "The refusal's code, the one the bind answers with\n(`chat_thread_admin`); `null` when `ok`.",
            "type": [
              "string",
              "null"
            ]
          },
          "ok": {
            "type": "boolean"
          },
          "reason": {
            "description": "The refusal in words; `null` when `ok`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "ok",
          "code",
          "reason",
          "admin_tools"
        ],
        "type": "object"
      },
      "Reasoning": {
        "description": "A profile's reasoning switch; `null` where it is used inherits (the\nthread's own fields win over it, the route's default comes after it).",
        "enum": [
          "on",
          "off"
        ],
        "type": "string"
      },
      "ReasoningCaps": {
        "additionalProperties": false,
        "description": "Reasoning / thinking support and how a request controls it.",
        "properties": {
          "budget_tokens": {
            "description": "The configured default thinking-token budget, when set and non-zero\n(a zero budget is published as `enabled: false`, not as a budget).",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "can_disable": {
            "description": "Whether a request can switch thinking off entirely. On an Anthropic\nroute: the catalog's `thinking.types.disabled.supported`.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "control": {
            "description": "The exact header and body fields that work on this route; omitted when\nempty (nothing to control on a `fixed` model).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "default": {
            "description": "The effort in force when the request sets none.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "The default state as this alias is configured. Absent when no source\nstates it — \"the catalog says the model supports reasoning\" does not\nsay whether it is on.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "kind": {
            "description": "`fixed` (nothing to change per request), `toggle` (on/off per\nrequest), `levels` (effort selectable per request).",
            "type": "string"
          },
          "levels": {
            "description": "Accepted effort values, least → most in the canonical order. Only for\n`kind == \"levels\"`; omitted entirely when empty.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "preserve_history": {
            "description": "Whether replayed reasoning of earlier turns reaches the model again.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "thinking_types": {
            "description": "The Messages `thinking` types the model takes, as an Anthropic\nupstream's catalog publishes them (`capabilities.thinking.types`), in\nAnthropic's order: `adaptive`, `between_tools`, `disabled`, `enabled`\n(the budget form). Only on an Anthropic route; omitted when the\ncatalog names none of them as supported.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "kind"
        ],
        "type": "object"
      },
      "RerankRequest": {
        "properties": {
          "documents": {
            "description": "Jina's spelling.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "texts": {
            "description": "TEI's spelling — either works; an embedding-only row is refused.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "top_n": {
            "type": "integer"
          }
        },
        "required": [
          "model",
          "query"
        ],
        "type": "object"
      },
      "RerankResponse": {
        "description": "Jina's results shape, regardless of which request spelling was sent. Built by lmgw from the model's scores, never relayed: no result carries its document.",
        "properties": {
          "model": {
            "description": "The model as the request named it.",
            "type": "string"
          },
          "object": {
            "enum": [
              "list"
            ],
            "type": "string"
          },
          "results": {
            "items": {
              "properties": {
                "index": {
                  "description": "The document's position in the request.",
                  "minimum": 0,
                  "type": "integer"
                },
                "relevance_score": {
                  "type": "number"
                }
              },
              "required": [
                "index",
                "relevance_score"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "usage": {
            "properties": {
              "prompt_tokens": {
                "description": "What the model reported; 0 when it reported nothing.",
                "minimum": 0,
                "type": "integer"
              },
              "total_tokens": {
                "description": "The same number: reranking generates nothing.",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "prompt_tokens",
              "total_tokens"
            ],
            "type": "object"
          }
        },
        "required": [
          "object",
          "model",
          "results",
          "usage"
        ],
        "type": "object"
      },
      "Response": {
        "additionalProperties": true,
        "description": "An upstream that speaks the Responses API natively is relayed as it sends the body: such a body may carry status queued (background), a null or missing usage and no store. lmgw's own translation always sends usage and store.",
        "properties": {
          "access_programs": {
            "description": "Always null; present because OpenAI's schema requires the field.",
            "type": "null"
          },
          "created_at": {
            "type": "integer"
          },
          "error": {
            "type": [
              "object",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "incomplete_details": {
            "properties": {
              "reason": {
                "type": "string"
              }
            },
            "required": [
              "reason"
            ],
            "type": [
              "object",
              "null"
            ]
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "response"
            ],
            "type": "string"
          },
          "output": {
            "description": "Items are loosely typed here. An output_text part of a message item carries `logprobs: []`: lmgw relays no log probabilities yet; OpenAI's schema requires the field.",
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "status": {
            "enum": [
              "queued",
              "in_progress",
              "completed",
              "incomplete",
              "failed",
              "cancelled"
            ],
            "type": "string"
          },
          "store": {
            "description": "Whether lmgw stored this response, so a later request can continue from it with previous_response_id. Sent by lmgw's own translation; a verbatim upstream body may leave it out.",
            "type": "boolean"
          },
          "usage": {
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "input_tokens_details": {
                "description": "Tokens read from and written to the prompt cache, both part of input_tokens; 0 when the upstream reported none (cache_write_tokens is lmgw's own addition and absent from a verbatim upstream body).",
                "properties": {
                  "cache_write_tokens": {
                    "type": "integer"
                  },
                  "cached_tokens": {
                    "type": "integer"
                  }
                },
                "required": [
                  "cached_tokens"
                ],
                "type": "object"
              },
              "output_tokens": {
                "type": "integer"
              },
              "output_tokens_details": {
                "properties": {
                  "reasoning_tokens": {
                    "type": "integer"
                  }
                },
                "required": [
                  "reasoning_tokens"
                ],
                "type": "object"
              },
              "total_tokens": {
                "type": "integer"
              }
            },
            "required": [
              "input_tokens",
              "input_tokens_details",
              "output_tokens",
              "output_tokens_details",
              "total_tokens"
            ],
            "type": [
              "object",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "object",
          "created_at",
          "status",
          "model",
          "output",
          "error",
          "incomplete_details"
        ],
        "type": "object"
      },
      "ResponseDeleted": {
        "properties": {
          "deleted": {
            "enum": [
              true
            ],
            "type": "boolean"
          },
          "id": {
            "type": "string"
          },
          "object": {
            "enum": [
              "response"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "deleted"
        ],
        "type": "object"
      },
      "ResponseInputItems": {
        "properties": {
          "data": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "object": {
            "enum": [
              "list"
            ],
            "type": "string"
          }
        },
        "required": [
          "object",
          "data"
        ],
        "type": "object"
      },
      "ResponseInputTokens": {
        "properties": {
          "input_tokens": {
            "type": "integer"
          },
          "object": {
            "enum": [
              "response.input_tokens"
            ],
            "type": "string"
          }
        },
        "required": [
          "object",
          "input_tokens"
        ],
        "type": "object"
      },
      "ResponseStreamEvent": {
        "additionalProperties": true,
        "description": "SSE event: response.<name>, data: <this object>. The response.output_text.delta and .done events carry `logprobs: []` (lmgw relays no log probabilities yet; OpenAI's schema requires the field).",
        "properties": {
          "sequence_number": {
            "type": "integer"
          },
          "type": {
            "description": "response.created … response.completed/.incomplete/.failed, response.output_text.delta, the mcp_*/function_call_* tool-call events, …",
            "type": "string"
          }
        },
        "required": [
          "type",
          "sequence_number"
        ],
        "type": "object"
      },
      "ResponsesRequest": {
        "additionalProperties": true,
        "properties": {
          "background": {
            "description": "true is refused on every path: a background response finishes after its answer has left, so lmgw could never record what it spent or hold it to a budget.",
            "type": "boolean"
          },
          "include": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "input": {
            "description": "A string (one user turn), or an array of items.",
            "items": {
              "description": "A message ({type:message,role,content}), a prior turn's {type:function_call,call_id,name,arguments} (call_id as lmgw gave it: a Gemini model's carries its thought signature and runs to hundreds of characters; echo it exactly, and do not send it to another provider directly) or {type:function_call_output,call_id,output} (output a string, or an array of {type:input_text,text} and {type:input_image,image_url} items: a base64 data: image goes on as an image where the upstream's tool results take one and as a named placeholder elsewhere, another URL as a resource naming it, and any other item as its JSON text), an mcp_call echo, or an {type:mcp_approval_response,approval_request_id,approve,reason} verdict on a previous response's pending call. On an upstream that implements the Responses API itself (the OpenAI platform, a compatible row flagged for it) every other item the API defines goes there as sent: an {type:item_reference,id} (or an untyped {id}), a hosted tool's record (web_search_call, file_search_call, code_interpreter_call, image_generation_call, computer_call and its output, …), and content parts lmgw's loop has no reading for (input_file, an input_image by file_id). lmgw's own loop refuses each of them by name (400 unsupported). For a client key, an item_reference id and any input item's own id (a reasoning item's rs_…, a message's msg_…, a hosted call's) pass only when a native answer given to that key carried the item, and a file_id anywhere in the body never does (lmgw does not proxy /v1/files, so no client key made one): either answers 404 as an unknown previous_response_id does. The owner key passes."
            }
          },
          "instructions": {
            "description": "Becomes the leading system message; an explicit empty string drops it on a chained call.",
            "type": "string"
          },
          "max_output_tokens": {
            "type": "integer"
          },
          "max_tool_calls": {
            "type": "integer"
          },
          "metadata": {
            "description": "Echoed back verbatim on the response object."
          },
          "model": {
            "type": "string"
          },
          "parallel_tool_calls": {
            "default": true,
            "type": "boolean"
          },
          "previous_response_id": {
            "description": "Continues a stored response: its conversation, tool calls and results included, goes ahead of this call's input, and mcp_approval_response items settle the calls it stopped at. 400 while the gateway's response store is switched off; 404 when no stored response has this id (it was evicted, or created with storing off). On an upstream that implements the Responses API itself, an id lmgw holds continues in lmgw's own loop and any other id goes to the upstream with the body; with mcp tools lmgw serves, such an id is a 400, since neither side can serve both.",
            "type": "string"
          },
          "reasoning": {
            "description": "The one reasoning control this dialect reads: reasoning.effort.",
            "properties": {
              "effort": {
                "type": "string"
              }
            },
            "type": "object"
          },
          "service_tier": {
            "description": "OpenAI's processing tier (auto, default, flex, priority, fast, scale, ultrafast), forwarded as sent; on an OpenAI platform row lmgw sends auto when it is unset, and prices the answer at the tier the answer reports. A request by a caller with a budget (its key's, or the gateway's) on a cloud model with no price on file for what it is billed in is refused before the send: 403 budget_unpriced, naming the model and the missing price. A flex request needs a flex price: no other tier's price bounds a flex answer's spend, which is cheaper.",
            "type": "string"
          },
          "store": {
            "description": "Whether lmgw keeps this response, so a later call can continue it with previous_response_id (default true). Storing also needs the gateway's response store, which is on by default: a request can turn storing off, never on. The response object's store says whether this response was kept, so a client can see up front whether previous_response_id will work. On an upstream that implements the Responses API itself the body goes there as sent, and storing is the provider's.",
            "type": "boolean"
          },
          "stream": {
            "default": false,
            "type": "boolean"
          },
          "temperature": {
            "type": "number"
          },
          "text": {
            "additionalProperties": true,
            "description": "text.format (json_schema, json_object, text) is the structured output every upstream gets in its own spelling, as on /v1/chat/completions; a native Responses upstream gets the body as sent. Its refusals are 400 response_format_unsupported / invalid_json_schema with param text.format.",
            "type": "object"
          },
          "tool_choice": {
            "description": "\"auto\" | \"none\" | \"required\" | {type:function,name} everywhere; any other form the upstream's API defines ({type:web_search_preview}, {type:allowed_tools,…}, {type:mcp,server_label}, …) goes natively to an upstream that implements the Responses API itself and is refused by lmgw's own loop."
          },
          "tools": {
            "description": "function tools the loop hands back to the client; mcp tools run server-side on lmgw's own registered MCP servers, and keep the request in lmgw's own loop on an upstream that implements the Responses API itself (an mcp label lmgw does not serve goes there with the body). Hosted tools (web_search, file_search, code_interpreter, image_generation, computer_use_preview, …) go natively to such an upstream, which runs them, and are refused by lmgw's own loop.",
            "items": {
              "oneOf": [
                {
                  "properties": {
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "parameters": {
                      "additionalProperties": true,
                      "type": "object"
                    },
                    "type": {
                      "enum": [
                        "function"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "name"
                  ],
                  "type": "object"
                },
                {
                  "properties": {
                    "allowed_tools": {
                      "description": "Tool names, as a list or {tool_names}; a name matches the exposed or the server's own spelling (docs__query or query). An empty list leaves nothing. read_only is refused: lmgw does not read MCP tool annotations.",
                      "oneOf": [
                        {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        {
                          "properties": {
                            "tool_names": {
                              "items": {
                                "type": "string"
                              },
                              "type": "array"
                            }
                          },
                          "type": "object"
                        }
                      ]
                    },
                    "connector_id": {
                      "description": "One of OpenAI's connectors: never lmgw's to serve, handled as a foreign server_url.",
                      "type": "string"
                    },
                    "require_approval": {
                      "description": "\"never\" (default) | \"always\" | {never:{tool_names}, always:{tool_names}}. read_only is refused, as in allowed_tools."
                    },
                    "server_label": {
                      "description": "Matches a registered MCP server's own tool prefix (or its name when it has none) — lmgw resolves this against its own servers, never against a client-supplied server_url.",
                      "type": "string"
                    },
                    "server_url": {
                      "description": "A server for the upstream to dial (OpenAI's hosted MCP tool); lmgw never dials it. A block whose server_url is not this gateway's own /mcp is not lmgw's to serve: it goes to an upstream that takes /v1/responses natively, and a request served by lmgw's own loop is refused with a 400 naming it. This gateway's own /mcp reads as no server_url.",
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "mcp"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "server_label"
                  ],
                  "type": "object"
                },
                {
                  "additionalProperties": true,
                  "description": "A hosted tool: goes with the body to an upstream that implements the Responses API itself, which runs it; lmgw's own loop refuses it (400 unsupported), and so does a request that also needs the loop (mcp tools lmgw serves, a previous_response_id lmgw stored), naming both. For a client key, a tool that names something stored under the provider account (a file_search vector_store_ids entry, a code_interpreter container id or file_ids, a shell container_reference or skill_id) answers 404 as an unknown id does; the owner key passes. Fees such a tool bills beyond its tokens (web search, file search, containers, image generation) are not priced yet: its row is unpriced, with a price_note naming the calls, and budgets count its token part as a lower bound.",
                  "properties": {
                    "type": {
                      "description": "web_search, file_search, code_interpreter, image_generation, computer_use_preview, shell, … as the upstream's own Responses API defines them.",
                      "not": {
                        "enum": [
                          "function",
                          "mcp"
                        ]
                      },
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "type": "object"
                }
              ]
            },
            "type": "array"
          },
          "top_k": {
            "type": "integer"
          },
          "top_p": {
            "type": "number"
          },
          "truncation": {
            "description": "\"auto\" goes natively to an upstream that implements the Responses API itself; lmgw's own loop refuses it, since it never silently drops conversation history.",
            "type": "string"
          }
        },
        "required": [
          "model"
        ],
        "type": "object"
      },
      "ResultTask": {
        "description": "The MCP task a call started, on its `result` frame.",
        "properties": {
          "id": {
            "description": "lmgw's id of the task (`ThreadTask.id`).",
            "format": "int64",
            "type": "integer"
          },
          "server_label": {
            "type": "string"
          },
          "task_id": {
            "description": "The server's id of the task.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "task_id",
          "server_label"
        ],
        "type": "object"
      },
      "RevokeKind": {
        "anyOf": [
          {
            "enum": [
              "device_disabled",
              "key_expired",
              "key_unknown",
              "certificate_expired",
              "revoked"
            ],
            "type": "string"
          }
        ],
        "description": "What revoked a key, as a `CLOSE_REVOKED` close's reason starts with it\nand the change feed's `revoked` event carries it (`kind`):\n\n- `device_disabled`: a paired device was disabled; it may be enabled\n  again, so it keeps its pairing;\n- `key_expired`: a paired device's key passed its expiry;\n- `key_unknown`: a paired device's key was rotated or deleted: pair the\n  device again;\n- `certificate_expired`: a paired device's client certificate passed its\n  `notAfter` while the connection was open (device link design §5.1):\n  pair the device again;\n- `revoked`: any other kind of key, for any of these.\n\nForward compatible like every enum a client reads: a token a newer\ngateway sends reads as `RevokeKind::Unknown`, as sent. One an older\ngateway does not send at all — a close reason without a token, a\n`revoked` event without `kind` — is an empty `Unknown`, the default, so\na client never reads a device's rotation as another key's revocation."
      },
      "Row": {
        "description": "One row of the review table.\n\nBoth a live frame and a stored result use this shape, so the table renders\nthe same whether the run is in flight or was finished last week.",
        "properties": {
          "attention": {
            "default": false,
            "description": "The output equals the fallback, or the call failed; through a question\nset also a confidence below the set's measured threshold (`decide`).",
            "type": "boolean"
          },
          "columns": {
            "additionalProperties": true,
            "default": {},
            "description": "The manifest's `columns`, rendered. Order comes from the manifest, not\nfrom this map.",
            "type": "object"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "default": "",
            "description": "`item.id` rendered. Empty marks the row errored — there is no\nstable identity to apply anything against.",
            "type": "string"
          },
          "item": {
            "description": "The **source** item, kept so a re-run can re-fetch and re-classify this\nrow without re-listing the mailbox. Not shown anywhere."
          },
          "output": {
            "default": null,
            "description": "The structured answer. `null` for a list-only run, which makes no call."
          },
          "prompt": {
            "description": "Exactly the `user` text the model received, for the details modal.\nKept per row because \"why did it say that\" is the question the\nreview table exists to answer.",
            "type": [
              "string",
              "null"
            ]
          },
          "raw": {
            "description": "What the model actually replied, so a surprising answer is explainable.",
            "type": [
              "string",
              "null"
            ]
          },
          "set": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentRowSet"
              },
              {
                "type": "null"
              }
            ],
            "description": "The question set that classified this row, as the run read it\n(`decide`); `None` for the model call. \"Save as labelled set\" saves\na run's rows into the set stamped on them."
          }
        },
        "type": "object"
      },
      "ScoreAnswer": {
        "properties": {
          "confidence": {
            "format": "double",
            "type": "number"
          },
          "legend": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Each level's index (`\"0\"`, `\"1\"`, …) with its description.",
            "type": "object"
          },
          "probabilities": {
            "additionalProperties": {
              "format": "double",
              "type": "number"
            },
            "description": "Each level's index with its probability.",
            "type": "object"
          },
          "score": {
            "description": "The expected level index, weighted by probability: it can fall between\ntwo levels.",
            "format": "double",
            "type": "number"
          }
        },
        "required": [
          "score",
          "legend",
          "probabilities",
          "confidence"
        ],
        "type": "object"
      },
      "ScoreQuestion": {
        "properties": {
          "criteria": {
            "description": "The levels' descriptions, lowest first: 2 to 10 of them.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "instructions": {
            "description": "The question: a string, an object or an array."
          }
        },
        "required": [
          "instructions",
          "criteria"
        ],
        "type": "object"
      },
      "SearchHit2": {
        "description": "One place that matches.",
        "properties": {
          "kind": {
            "description": "`t` the title, `m` a message, `a` an attachment's name.",
            "type": "string"
          },
          "message_id": {
            "description": "The message, for kind `m`.",
            "format": "int64",
            "type": "integer"
          },
          "role": {
            "description": "The message's role, for kind `m`.",
            "type": "string"
          },
          "snippet": {
            "description": "The text around the match, with the match between U+E000 and U+E001\n(private-use characters; escape the text before turning them into\nmarkup).",
            "type": "string"
          }
        },
        "required": [
          "kind",
          "snippet"
        ],
        "type": "object"
      },
      "SearchThread": {
        "description": "A thread with matches.",
        "properties": {
          "archived": {
            "type": "boolean"
          },
          "folder_id": {
            "description": "`null` for a thread in no folder, and for one in a folder the\ncaller cannot see.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "hits": {
            "description": "The best matches, up to three.",
            "items": {
              "$ref": "#/components/schemas/SearchHit2"
            },
            "type": "array"
          },
          "match_count": {
            "description": "How many places in the thread match.",
            "format": "int64",
            "type": "integer"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "thread_id",
          "title",
          "folder_id",
          "archived",
          "updated_at",
          "match_count",
          "hits"
        ],
        "type": "object"
      },
      "ServedModel": {
        "description": "An alias a stage asked for, the one that answered when it was another,\nand (for the text-to-speech stage) the voice.",
        "properties": {
          "alias": {
            "type": "string"
          },
          "answered_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "voice": {
            "type": "string"
          }
        },
        "required": [
          "alias",
          "answered_by"
        ],
        "type": "object"
      },
      "Sourced_Nullable_string": {
        "description": "A value and the level it came from; `source: null` when no level sets it.",
        "properties": {
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VoiceSource"
              },
              {
                "type": "null"
              }
            ]
          },
          "value": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "value",
          "source"
        ],
        "type": "object"
      },
      "Sourced_TurnDetectionMode": {
        "description": "A value and the level it came from; `source: null` when no level sets it.",
        "properties": {
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VoiceSource"
              },
              {
                "type": "null"
              }
            ]
          },
          "value": {
            "$ref": "#/components/schemas/TurnDetectionMode"
          }
        },
        "required": [
          "value",
          "source"
        ],
        "type": "object"
      },
      "Sourced_boolean": {
        "description": "A value and the level it came from; `source: null` when no level sets it.",
        "properties": {
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VoiceSource"
              },
              {
                "type": "null"
              }
            ]
          },
          "value": {
            "type": "boolean"
          }
        },
        "required": [
          "value",
          "source"
        ],
        "type": "object"
      },
      "SpeechCaps": {
        "additionalProperties": false,
        "description": "The `speech` object of a text-to-speech model's capabilities. Absent\nfields are unknown, as everywhere in the schema.",
        "properties": {
          "inline_tags": {
            "description": "What inline tags in `input` do: `none` (stripped, never read out),\n`fixed` (the ones in `tags` are rendered, stage directions mapped\nonto them, the rest stripped), `free` (every `[tag]` is rendered).",
            "type": [
              "string",
              "null"
            ]
          },
          "instructions": {
            "description": "What `instructions` do: `none` (dropped — said in `x-lmgw-speech`),\n`style` (a speaking style for the voice), `voice_design` (the voice\nis designed from them), `passthrough` (sent; the model reads them —\nit declares an instruction option, or lmgw knows its engine reads\none anyway — and decides what they do).",
            "type": [
              "string",
              "null"
            ]
          },
          "instructions_required": {
            "description": "A request without instructions is refused (`instructions_required`)\nunless the row has a default description.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "sample_rate": {
            "description": "The sample rate of its audio, in Hz, as its last answer through lmgw\nsaid (a streamed answer's PCM has no header of its own; the same\nfigure is the `x-lmgw-sample-rate` header on it). Absent until the\nmodel has answered once since lmgw started.",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "streaming": {
            "description": "`stream_format` (`sse` or `audio`, `response_format: pcm`) works on\nthis row: it runs in streaming mode.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "tags": {
            "description": "The tags a `fixed` model renders, written `[tag]`.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SpeechStyle": {
        "description": "The speech instructions; `\"\"` is none.",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/VoiceSource",
            "description": "The level the text came from; `row` when the text-to-speech model's\nown description stands in for it."
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "text",
          "source"
        ],
        "type": "object"
      },
      "Stage": {
        "description": "One speech stage.",
        "properties": {
          "alias": {
            "description": "`null`: nothing configured at any level.",
            "type": [
              "string",
              "null"
            ]
          },
          "cpu": {
            "description": "An audio model that runs on the CPU: the GPU hold does not stop it, a\nbenchmark run's lease does.",
            "type": "boolean"
          },
          "fallback": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Fallback"
              },
              {
                "type": "null"
              }
            ],
            "description": "What answers instead while the model is blocked; `null` off this\nmachine, or when the model has no usable fallback."
          },
          "fallback_unusable": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FallbackUnusable"
              },
              {
                "type": "null"
              }
            ],
            "description": "A fallback the model names that cannot stand in, and why."
          },
          "inherited": {
            "description": "What the levels below the thread give: the alias the thread uses once\nits own override is cleared; equal to `alias` when the thread sets\nnone.",
            "type": [
              "string",
              "null"
            ]
          },
          "local": {
            "description": "`false` for an alias served off this machine; `null` when the alias\ndoes not resolve.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "managed": {
            "description": "A model lmgw starts itself: the GPU hold and a benchmark run's lease\napply to it.",
            "type": "boolean"
          },
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VoiceSource"
              },
              {
                "type": "null"
              }
            ],
            "description": "The level `alias` came from; `null` with no alias."
          }
        },
        "required": [
          "alias",
          "source",
          "inherited",
          "local",
          "managed",
          "cpu",
          "fallback",
          "fallback_unusable"
        ],
        "type": "object"
      },
      "StructuredOutputCaps": {
        "additionalProperties": false,
        "description": "`response_format` support.",
        "properties": {
          "json_object": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "json_schema": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "SystemOneAnswer": {
        "description": "One answer, by its question's `type`.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChoiceAnswer",
            "properties": {
              "type": {
                "const": "choice",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/ScoreAnswer",
            "properties": {
              "type": {
                "const": "score",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/NoulAnswer",
            "properties": {
              "type": {
                "const": "noul",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          }
        ]
      },
      "SystemOneQuestion": {
        "description": "One question, by its `type`.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChoiceQuestion",
            "description": "Pick one of the named options.",
            "properties": {
              "type": {
                "const": "choice",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/ScoreQuestion",
            "description": "Rate on 2 to 10 ordered levels.",
            "properties": {
              "type": {
                "const": "score",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/NoulQuestion",
            "description": "Yes or no.",
            "properties": {
              "type": {
                "const": "noul",
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          }
        ]
      },
      "SystemOneResponse": {
        "description": "`POST /v1/systemone`'s answer, as the upstream sent it.\n\n`model` is the upstream's own: the versioned id that answered on TypeSafe\n(`jev-1.13.0`), a dated id on OpenRouter, the server's `--alias` on\nllama.cpp. lmgw does not write the requested name back; which alias\nanswered is `x-lmgw-fallback`'s to say (§2.1).",
        "properties": {
          "answers": {
            "additionalProperties": {
              "$ref": "#/components/schemas/SystemOneAnswer"
            },
            "description": "One answer per question, under the question's key.",
            "type": "object"
          },
          "id": {
            "description": "OpenRouter's extension: the generation's id.",
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": "string"
          },
          "provider": {
            "description": "OpenRouter's extension: the provider that answered.",
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "$ref": "#/components/schemas/SystemOneUsage"
          }
        },
        "required": [
          "model",
          "answers",
          "usage"
        ],
        "type": "object"
      },
      "SystemOneUsage": {
        "description": "What a request processed: lmgw logs `input_tokens` as the row's prompt\ntokens and `output_tokens` as its completion tokens, and prices them from\nits own price rows (§2.6).",
        "properties": {
          "cost": {
            "description": "OpenRouter's extension: what the request cost there, in USD. Relayed,\nnever read: lmgw prices from its own rows.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "input_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "output_tokens": {
            "description": "Always 0 on llama.cpp; TypeSafe and OpenRouter report a non-zero\ncount, which Jev's price does not charge.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "type": "object"
      },
      "Takeover": {
        "description": "`?takeover=`: whether a bind may take its thread from another session.",
        "oneOf": [
          {
            "const": "always",
            "description": "Take the thread over (what a bind without the parameter does).",
            "type": "string"
          },
          {
            "const": "never",
            "description": "Never: refuse while another session is bound to the thread.",
            "type": "string"
          },
          {
            "const": "ask",
            "description": "Ask first (WebRTC calls only, realtime calls design §2.8): a thread\nheld when the call's channel opens makes the call wait,\n`lmgw.session.bind_pending`, for the client's\n`lmgw.session.take_over` or the holder's end.",
            "type": "string"
          }
        ]
      },
      "Target": {
        "description": "A device the caller can offer a file to.",
        "properties": {
          "device_id": {
            "description": "Its key id: the offer's `to_device`.",
            "format": "int64",
            "type": "integer"
          },
          "last_seen_at": {
            "description": "When one of its connections last opened or closed (RFC 3339 UTC);\n`null` for one that never connected.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Its paired name, without `device:`.",
            "type": "string"
          },
          "online": {
            "description": "Whether it holds its Chat feed open now, so it hears an offer at\nonce.",
            "type": "boolean"
          }
        },
        "required": [
          "device_id",
          "name",
          "online",
          "last_seen_at"
        ],
        "type": "object"
      },
      "TaskRequest": {
        "properties": {
          "model": {
            "type": "string"
          },
          "request": {
            "additionalProperties": true,
            "description": "Relayed to audio.cpp's generic task endpoint untouched; its shape is the task's own and is not modeled here.",
            "type": "object"
          }
        },
        "required": [
          "model",
          "request"
        ],
        "type": "object"
      },
      "TestUsage": {
        "description": "A test call's token usage, as the model reported it.",
        "properties": {
          "completion_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "prompt_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "prompt_tokens",
          "completion_tokens"
        ],
        "type": "object"
      },
      "TextCompletion": {
        "description": "Relayed as the upstream sends it.",
        "properties": {
          "choices": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "text_completion"
            ],
            "type": "string"
          },
          "usage": {
            "additionalProperties": true,
            "type": "object"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "type": "object"
      },
      "TextCompletionChunk": {
        "additionalProperties": true,
        "description": "One frame, relayed as the upstream sends it: `data: <this object>`, repeated, ending with the literal `data: [DONE]`.",
        "properties": {
          "choices": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "enum": [
              "text_completion"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "type": "object"
      },
      "Thread": {
        "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
        "properties": {
          "agent_id": {
            "description": "The agent the thread was opened from, if any.",
            "type": [
              "string",
              "null"
            ]
          },
          "archived_at": {
            "description": "When the thread was archived; `null` while it is active.",
            "type": [
              "string",
              "null"
            ]
          },
          "continue": {
            "$ref": "#/components/schemas/ContinueState",
            "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
          },
          "created_at": {
            "type": "string"
          },
          "folder_id": {
            "description": "The folder the thread is in; `null` for none.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "frequency_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "id": {
            "description": "Negative for a temporary thread.",
            "format": "int64",
            "type": "integer"
          },
          "kb_budget_tokens": {
            "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "description": "Knowledge bases the thread searches, by id.",
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "kb_mode": {
            "$ref": "#/components/schemas/KbMode"
          },
          "kind": {
            "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
            "type": "string"
          },
          "last_message_at": {
            "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "max_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
            "items": {
              "$ref": "#/components/schemas/ThreadMcp"
            },
            "type": "array"
          },
          "media_defaults": {
            "$ref": "#/components/schemas/MediaDefaults",
            "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
          },
          "min_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "description": "The alias the thread's turns go to.",
            "type": "string"
          },
          "pinned": {
            "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
            "type": "boolean"
          },
          "presence_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "purge_at": {
            "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_budget": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "description": "Stop sequences; empty leaves the route's default.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system_prompt": {
            "type": "string"
          },
          "temperature": {
            "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "temporary": {
            "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "top_k": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "updated_at": {
            "description": "Moves with every change to the thread and every new message.",
            "type": "string"
          },
          "voice": {
            "$ref": "#/components/schemas/ThreadVoice"
          },
          "voice_resolved": {
            "$ref": "#/components/schemas/VoiceResolved",
            "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
          }
        },
        "required": [
          "id",
          "title",
          "model_alias",
          "system_prompt",
          "temperature",
          "max_tokens",
          "top_p",
          "top_k",
          "min_p",
          "repeat_penalty",
          "presence_penalty",
          "frequency_penalty",
          "seed",
          "stop",
          "kind",
          "mcp_tools",
          "reasoning_enabled",
          "reasoning_effort",
          "reasoning_budget",
          "agent_id",
          "pinned",
          "archived_at",
          "folder_id",
          "profile_id",
          "kb_ids",
          "kb_mode",
          "kb_budget_tokens",
          "voice",
          "media_defaults",
          "created_at",
          "updated_at",
          "last_message_at",
          "purge_at",
          "temporary",
          "voice_resolved"
        ],
        "type": "object"
      },
      "ThreadChanged": {
        "description": "`thread.created` / `thread.updated` for a thread that exists at delivery:\nthe thread as `GET /chat/api/threads` lists it now, with `by` beside its\nfields.",
        "properties": {
          "agent_id": {
            "description": "The agent the thread was opened from, if any.",
            "type": [
              "string",
              "null"
            ]
          },
          "archived_at": {
            "description": "When the thread was archived; `null` while it is active.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "description": "Who made the change; `null` for the gateway's own, such as the sweep.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "folder_id": {
            "description": "The folder the thread is in; `null` for none.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "frequency_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "id": {
            "description": "Negative for a temporary thread.",
            "format": "int64",
            "type": "integer"
          },
          "kb_budget_tokens": {
            "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "description": "Knowledge bases the thread searches, by id.",
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "kb_mode": {
            "$ref": "#/components/schemas/KbMode"
          },
          "kind": {
            "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
            "type": "string"
          },
          "last_message_at": {
            "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "max_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
            "items": {
              "$ref": "#/components/schemas/ThreadMcp"
            },
            "type": "array"
          },
          "media_defaults": {
            "$ref": "#/components/schemas/MediaDefaults",
            "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
          },
          "min_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "description": "The alias the thread's turns go to.",
            "type": "string"
          },
          "pinned": {
            "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
            "type": "boolean"
          },
          "presence_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "purge_at": {
            "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_budget": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "description": "Stop sequences; empty leaves the route's default.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system_prompt": {
            "type": "string"
          },
          "temperature": {
            "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "temporary": {
            "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "top_k": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "updated_at": {
            "description": "Moves with every change to the thread and every new message.",
            "type": "string"
          },
          "voice": {
            "$ref": "#/components/schemas/ThreadVoice"
          }
        },
        "required": [
          "id",
          "title",
          "model_alias",
          "system_prompt",
          "temperature",
          "max_tokens",
          "top_p",
          "top_k",
          "min_p",
          "repeat_penalty",
          "presence_penalty",
          "frequency_penalty",
          "seed",
          "stop",
          "kind",
          "mcp_tools",
          "reasoning_enabled",
          "reasoning_effort",
          "reasoning_budget",
          "agent_id",
          "pinned",
          "archived_at",
          "folder_id",
          "profile_id",
          "kb_ids",
          "kb_mode",
          "kb_budget_tokens",
          "voice",
          "media_defaults",
          "created_at",
          "updated_at",
          "last_message_at",
          "purge_at",
          "temporary",
          "by"
        ],
        "type": "object"
      },
      "ThreadDefaults": {
        "description": "What a new thread in a folder starts with. Every field is optional;\n`null` is the Chat's own default. A copy is taken when a thread is\ncreated, except that an ongoing conversation's changed defaults also\nreach its current thread — and `media_defaults`, which every thread in\nthe folder reads at each turn.",
        "properties": {
          "frequency_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "kb_budget_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "kb_mode": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/KbMode"
              },
              {
                "type": "null"
              }
            ]
          },
          "max_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "items": {
              "$ref": "#/components/schemas/ThreadMcp"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "media_defaults": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MediaDefaults"
              },
              {
                "type": "null"
              }
            ],
            "description": "The image and audio tools' default models of every thread in the\nfolder, read at each turn rather than copied: an absent field\ninherits Settings → Chat's, an empty one is no default, and a\nthread's own wins."
          },
          "min_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "description": "The model of a new thread; an ongoing conversation needs one.",
            "type": [
              "string",
              "null"
            ]
          },
          "presence_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "description": "The personality profile of a new thread; `null` for the Chat's own\ndefault (Settings → Chat).",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_budget": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "system_prompt": {
            "type": [
              "string",
              "null"
            ]
          },
          "temperature": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "top_k": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "voice": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ThreadVoice"
              },
              {
                "type": "null"
              }
            ],
            "description": "Voice settings, laid field by field over a new thread's."
          }
        },
        "required": [
          "model_alias",
          "system_prompt",
          "temperature",
          "max_tokens",
          "top_p",
          "top_k",
          "min_p",
          "repeat_penalty",
          "presence_penalty",
          "frequency_penalty",
          "seed",
          "stop",
          "reasoning_enabled",
          "reasoning_effort",
          "reasoning_budget",
          "mcp_tools",
          "kb_ids",
          "kb_mode",
          "kb_budget_tokens",
          "voice",
          "profile_id",
          "media_defaults"
        ],
        "type": "object"
      },
      "ThreadDefaultsInput": {
        "description": "What a new thread in a folder starts with. Every field is optional;\n`null` is the Chat's own default. A copy is taken when a thread is\ncreated, except that an ongoing conversation's changed defaults also\nreach its current thread — and `media_defaults`, which every thread in\nthe folder reads at each turn.",
        "properties": {
          "frequency_penalty": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "kb_budget_tokens": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "default": null,
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "kb_mode": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/KbMode"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "max_tokens": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "default": null,
            "items": {
              "$ref": "#/components/schemas/ThreadMcpInput"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "media_defaults": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MediaDefaults"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "The image and audio tools' default models of every thread in the\nfolder, read at each turn rather than copied: an absent field\ninherits Settings → Chat's, an empty one is no default, and a\nthread's own wins."
          },
          "min_p": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "default": null,
            "description": "The model of a new thread; an ongoing conversation needs one.",
            "type": [
              "string",
              "null"
            ]
          },
          "presence_penalty": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "default": null,
            "description": "The personality profile of a new thread; `null` for the Chat's own\ndefault (Settings → Chat).",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_budget": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "default": null,
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "default": null,
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "system_prompt": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "temperature": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "top_k": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "default": null,
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "voice": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ThreadVoice"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Voice settings, laid field by field over a new thread's."
          }
        },
        "type": "object"
      },
      "ThreadGone": {
        "description": "`thread.deleted`, and `thread.created` / `thread.updated` for a thread\nthat is gone by the time the event is delivered.",
        "properties": {
          "by": {
            "description": "Who made the change; `null` for the gateway's own (the sweep).",
            "type": [
              "string",
              "null"
            ]
          },
          "deleted": {
            "type": "boolean"
          },
          "thread_id": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "thread_id",
          "deleted",
          "by"
        ],
        "type": "object"
      },
      "ThreadMcp": {
        "description": "A tool server attached to a thread: the label it is reached by, and\noptionally the tools of it the thread uses.",
        "properties": {
          "allowed_tools": {
            "description": "The tools of that server the thread uses; `null` for all of them.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "require_approval": {
            "description": "Which of them wait for an approval before they run, in OpenAI's\nshapes: `\"never\"` (the default, also when absent), `\"always\"`, or\n`{\"always\": {\"tool_names\": […]}, \"never\": {\"tool_names\": […]}}`. A\nname may be the tool's own or its prefixed one. `read_only` is\nrefused. A gated call stops the turn; `POST\n/chat/api/threads/{id}/approvals` decides it."
          },
          "server_label": {
            "description": "A registered tool server's tool prefix (or its name when it has\nnone), or a built-in toolset such as `kb`.",
            "type": "string"
          }
        },
        "required": [
          "server_label",
          "allowed_tools"
        ],
        "type": "object"
      },
      "ThreadMcpInput": {
        "description": "A tool server attached to a thread: the label it is reached by, and\noptionally the tools of it the thread uses.",
        "properties": {
          "allowed_tools": {
            "default": null,
            "description": "The tools of that server the thread uses; `null` for all of them.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "require_approval": {
            "description": "Which of them wait for an approval before they run, in OpenAI's\nshapes: `\"never\"` (the default, also when absent), `\"always\"`, or\n`{\"always\": {\"tool_names\": […]}, \"never\": {\"tool_names\": […]}}`. A\nname may be the tool's own or its prefixed one. `read_only` is\nrefused. A gated call stops the turn; `POST\n/chat/api/threads/{id}/approvals` decides it."
          },
          "server_label": {
            "description": "A registered tool server's tool prefix (or its name when it has\nnone), or a built-in toolset such as `kb`.",
            "type": "string"
          }
        },
        "required": [
          "server_label"
        ],
        "type": "object"
      },
      "ThreadRow": {
        "description": "A Chat thread as `GET /chat/api/threads` lists it, and as the change\nfeed's `thread.created` and `thread.updated` carry it.",
        "properties": {
          "agent_id": {
            "description": "The agent the thread was opened from, if any.",
            "type": [
              "string",
              "null"
            ]
          },
          "archived_at": {
            "description": "When the thread was archived; `null` while it is active.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "folder_id": {
            "description": "The folder the thread is in; `null` for none.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "frequency_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "id": {
            "description": "Negative for a temporary thread.",
            "format": "int64",
            "type": "integer"
          },
          "kb_budget_tokens": {
            "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "kb_ids": {
            "description": "Knowledge bases the thread searches, by id.",
            "items": {
              "format": "int64",
              "type": "integer"
            },
            "type": "array"
          },
          "kb_mode": {
            "$ref": "#/components/schemas/KbMode"
          },
          "kind": {
            "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
            "type": "string"
          },
          "last_message_at": {
            "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "max_tokens": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "mcp_tools": {
            "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
            "items": {
              "$ref": "#/components/schemas/ThreadMcp"
            },
            "type": "array"
          },
          "media_defaults": {
            "$ref": "#/components/schemas/MediaDefaults",
            "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
          },
          "min_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "model_alias": {
            "description": "The alias the thread's turns go to.",
            "type": "string"
          },
          "pinned": {
            "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
            "type": "boolean"
          },
          "presence_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "profile_id": {
            "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "purge_at": {
            "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_budget": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning_enabled": {
            "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "repeat_penalty": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "seed": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "stop": {
            "description": "Stop sequences; empty leaves the route's default.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system_prompt": {
            "type": "string"
          },
          "temperature": {
            "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "temporary": {
            "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "top_k": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "top_p": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "updated_at": {
            "description": "Moves with every change to the thread and every new message.",
            "type": "string"
          },
          "voice": {
            "$ref": "#/components/schemas/ThreadVoice"
          }
        },
        "required": [
          "id",
          "title",
          "model_alias",
          "system_prompt",
          "temperature",
          "max_tokens",
          "top_p",
          "top_k",
          "min_p",
          "repeat_penalty",
          "presence_penalty",
          "frequency_penalty",
          "seed",
          "stop",
          "kind",
          "mcp_tools",
          "reasoning_enabled",
          "reasoning_effort",
          "reasoning_budget",
          "agent_id",
          "pinned",
          "archived_at",
          "folder_id",
          "profile_id",
          "kb_ids",
          "kb_mode",
          "kb_budget_tokens",
          "voice",
          "media_defaults",
          "created_at",
          "updated_at",
          "last_message_at",
          "purge_at",
          "temporary"
        ],
        "type": "object"
      },
      "ThreadTask": {
        "description": "One of a thread's tasks: still running, or ended with its result on its\nway into the thread.",
        "properties": {
          "by": {
            "description": "Who started it (\"the dashboard\", \"device 'phone'\").",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "lmgw's id of the task: the cancel route's `{task}`.",
            "format": "int64",
            "type": "integer"
          },
          "server_label": {
            "type": "string"
          },
          "started_at": {
            "description": "When it started (UTC, `YYYY-MM-DD HH:MM:SS`).",
            "type": "string"
          },
          "status": {
            "description": "`working` or `input_required` while it runs; `completed`, `failed`,\n`cancelled` or `abandoned` once it ended.",
            "enum": [
              "working",
              "input_required",
              "completed",
              "failed",
              "cancelled",
              "abandoned"
            ],
            "type": "string"
          },
          "status_message": {
            "description": "The server's last word on it, when it gave one.",
            "type": [
              "string",
              "null"
            ]
          },
          "task_id": {
            "description": "The server's id of the task.",
            "type": "string"
          },
          "tool": {
            "description": "The name the model called.",
            "type": "string"
          },
          "ttl_ms": {
            "description": "How long the server keeps it, as it stated; `null` when it stated\nnone.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "waiting_for": {
            "description": "What it waits for, when it waits: a device that is not connected\n(its tasks are asked about again when it links), a turn of the\nthread that runs (a result enters the thread once it ended), or the\ndecision on the calls the thread's last reply waits on.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "task_id",
          "server_label",
          "tool",
          "status",
          "status_message",
          "ttl_ms",
          "started_at",
          "by",
          "waiting_for"
        ],
        "type": "object"
      },
      "ThreadVoice": {
        "description": "A thread's own voice settings. Every field is optional and absent when\nunset: an absent field takes the Chat's voice settings.",
        "properties": {
          "asr_alias": {
            "description": "The speech-to-text alias for dictation, voice mode and audio\nattachments.",
            "type": [
              "string",
              "null"
            ]
          },
          "audio_input": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AudioInputMode"
              },
              {
                "type": "null"
              }
            ]
          },
          "language": {
            "description": "The language the user speaks, a two-letter ISO 639-1 code, or `auto`\nto let the speech-to-text model detect it.",
            "type": [
              "string",
              "null"
            ]
          },
          "read_aloud": {
            "description": "Read every reply aloud as it streams.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "reply_language": {
            "description": "The language replies are in, a two-letter code, or `auto` to follow\nthe language the user speaks.",
            "type": [
              "string",
              "null"
            ]
          },
          "seed": {
            "description": "The thread's text-to-speech seed, so one thread keeps one voice on a\nmodel that draws its voice. Set on first use.",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "speech_style": {
            "description": "The speaking style the text-to-speech model is given; an empty text\nis none for this thread.",
            "type": [
              "string",
              "null"
            ]
          },
          "tts_alias": {
            "description": "The text-to-speech alias for read-aloud and voice mode.",
            "type": [
              "string",
              "null"
            ]
          },
          "turn_detection": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TurnDetectionMode"
              },
              {
                "type": "null"
              }
            ]
          },
          "voice": {
            "description": "A voice of that text-to-speech model.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ThreadsFate": {
        "description": "What a folder delete does with the threads in the folder.",
        "oneOf": [
          {
            "const": "keep",
            "description": "The threads stay, in no folder.",
            "type": "string"
          },
          {
            "const": "delete",
            "description": "The threads are deleted with the folder.",
            "type": "string"
          }
        ]
      },
      "Timings": {
        "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
        "properties": {
          "cache_n": {
            "description": "Prompt tokens served from the KV cache.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "draft_n": {
            "description": "Draft tokens proposed (speculative or MTP decoding).",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "draft_n_accepted": {
            "description": "Draft tokens accepted.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "predicted_ms": {
            "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
            "format": "double",
            "type": "number"
          },
          "predicted_n": {
            "description": "Tokens generated so far.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "predicted_per_second": {
            "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
            "format": "double",
            "type": "number"
          },
          "prompt_ms": {
            "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
            "format": "double",
            "type": "number"
          },
          "prompt_n": {
            "description": "Prompt tokens actually processed this turn (the cache excluded).",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "prompt_per_second": {
            "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
            "format": "double",
            "type": "number"
          }
        },
        "required": [
          "prompt_n",
          "predicted_n"
        ],
        "type": "object"
      },
      "TokenizeRequest": {
        "additionalProperties": true,
        "description": "Every key but model is forwarded to the backend's own /tokenize verbatim. Refused with 501 not_supported_error on any backend but a real llama-server — an id from a tokenizer the backend does not run would be a hidden approximation.",
        "properties": {
          "add_special": {
            "default": false,
            "type": "boolean"
          },
          "content": {
            "description": "A string, or a mixed array of strings and token ids."
          },
          "model": {
            "description": "Required: llama-server's router mode has no other way to pick a backend. A missing model is a 400 naming GET /v1/models.",
            "type": "string"
          },
          "parse_special": {
            "default": true,
            "type": "boolean"
          },
          "with_pieces": {
            "default": false,
            "type": "boolean"
          }
        },
        "required": [
          "model"
        ],
        "type": "object"
      },
      "TokenizeResponse": {
        "properties": {
          "tokens": {
            "description": "An array of integer token ids, or — with_pieces — an array of {id, piece} (piece a string, or a byte array when it is not valid UTF-8)."
          }
        },
        "required": [
          "tokens"
        ],
        "type": "object"
      },
      "ToolArgsFrame": {
        "description": "A fragment of a call's JSON arguments, in order.",
        "properties": {
          "fragment": {
            "type": "string"
          },
          "index": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "index",
          "fragment"
        ],
        "type": "object"
      },
      "ToolCallCaps": {
        "additionalProperties": false,
        "description": "Tool-calling support.",
        "properties": {
          "format": {
            "description": "The native syntax family the template renders (`qwen-xml`,\n`hermes-json`, …), `provider` for cloud, `unknown` when the template\nrenders tools with none of the known markers. Informational.",
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "description": "`native` (lmgw returns structured `tool_calls`), `none` (the template\nrenders no tools; aux/audio rows), `text` (the template renders tools\nin a syntax llama-server has no parser for, so calls may arrive as\nprose the caller must read itself).",
            "type": "string"
          },
          "parallel": {
            "description": "The template can render more than one call per turn. Absent for cloud\nmodels, which publish nothing about it.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "kind"
        ],
        "type": "object"
      },
      "ToolProgressFrame": {
        "description": "The `progress` event of a `tool` frame: a running image or audio call's\nstage, step and latest preview. Lossy: a reader that falls behind misses\nsome (the next one supersedes them), and they are not in the change\nfeed.",
        "properties": {
          "call_id": {
            "description": "The call's id, as its `ready` frame carries it.",
            "type": "string"
          },
          "cancel": {
            "$ref": "#/components/schemas/CancelKind",
            "description": "What a cancel would do now, while an image job runs; absent before\nthe job exists (a cancel then just stops the wait) and for audio."
          },
          "done_bytes": {
            "description": "`downloading`: compressed bytes downloaded so far.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "elapsed_ms": {
            "description": "Since the call started.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "free_bytes": {
            "description": "`waiting_for_room`: the memory free when it was last measured.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "image": {
            "description": "`downloading`: the image reference being downloaded.",
            "type": "string"
          },
          "model": {
            "description": "The model the phase is about: the one being unloaded for\n`unloading`, the call's own otherwise.",
            "type": "string"
          },
          "needs_bytes": {
            "description": "`waiting_for_room`: the memory the model needs, headroom included.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "pass": {
            "description": "The sampling pass (a batch item, a high- or low-noise stage, a hires\npass); a new pass starts its steps again.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "phase": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MediaPhase"
              },
              {
                "type": "null"
              }
            ]
          },
          "preview": {
            "description": "The latest preview as the image server drew it: base64, PNG. Its\npixel size depends on the row's preview mode (a quick sketch is the\nlatent's size, an eighth of the picture's side on the spike's\npipeline).",
            "type": "string"
          },
          "queue_position": {
            "description": "`queued`: the job's place in the image server's queue.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "size_note": {
            "description": "`downloading`: why the size is not known, when it is not (\"size not\nknown — …\").",
            "type": "string"
          },
          "step": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "total_bytes": {
            "description": "`downloading`: the download's whole size; absent when it is not\nknown.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "total_steps": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "call_id",
          "phase",
          "elapsed_ms"
        ],
        "type": "object"
      },
      "ToolReadyFrame": {
        "description": "A Chat `tool` frame whose `event` is `ready` (also the `data` of a bound\nrealtime session's `lmgw.chat.frame` for it): a call's arguments are\ncomplete, before it runs — what a host that shows the call's view at once\nneeds (client-apps design §7.5).",
        "properties": {
          "arguments": {
            "description": "The call's arguments."
          },
          "call_id": {
            "description": "The call's id, as its `result` frame carries it.",
            "type": [
              "string",
              "null"
            ]
          },
          "index": {
            "description": "The call's position in its turn.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "name": {
            "description": "The tool's exposed name, as the model called it.",
            "type": "string"
          },
          "needs_approval": {
            "description": "The call waits for an approval and does not run now: an `approval`\nframe follows. `false` for a call that runs (a resumed turn's decided\ncalls included). Absent from an lmgw before 2026-10-09.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "server_label": {
            "description": "The label the tool came from; `null` for a client's own function.",
            "type": [
              "string",
              "null"
            ]
          },
          "ui_resource": {
            "description": "The UI resource the tool links to, as on the result frame.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "index",
          "name",
          "arguments",
          "call_id",
          "server_label",
          "needs_approval",
          "ui_resource"
        ],
        "type": "object"
      },
      "ToolResultFrame": {
        "description": "A Chat `tool` frame whose `event` is `result` (also the `data` of a\nbound realtime session's `lmgw.chat.frame` for it), as an MCP Apps host\nreads it. MCP's `CallToolResult` for the view is `{content,\nstructuredContent: structured_content, isError: is_error}`.",
        "properties": {
          "attachments": {
            "description": "The files the call stored in the thread — an image or audio tool's\npictures and recordings in a Chat turn — so a page shows them\nwithout reading the thread again. Their bytes are at\n`GET /chat/api/attachments/{id}`; `content` names them as\n`lmgw:attachment/N` resources. Empty for every other call.",
            "items": {
              "$ref": "#/components/schemas/AttachmentMeta"
            },
            "type": "array"
          },
          "call_id": {
            "description": "The call's id, as its `ready` frame carries it.",
            "type": [
              "string",
              "null"
            ]
          },
          "content": {
            "description": "The MCP result's `content` blocks as the server sent them (resource\nURIs namespaced as `/mcp` sends them; images in full — no bound of\nlmgw's own, a device's result is bounded by `mcp.host_max_message_mb`\non its link); a tool lmgw runs itself, or a call that never reached\na server, says its result in the same shape. Absent from an lmgw\nbefore 2026-10-09: `output` as one text block then.",
            "items": true,
            "type": [
              "array",
              "null"
            ]
          },
          "index": {
            "description": "The call's position in its turn.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "is_error": {
            "type": "boolean"
          },
          "ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "name": {
            "description": "The tool's exposed name (`<prefix>__<tool>`).",
            "type": "string"
          },
          "output": {
            "description": "The result as text.",
            "type": "string"
          },
          "server_label": {
            "description": "The label the tool came from: a server's tool prefix (else its\nname), or a built-in toolset's (`lmgw`, `docs`, `kb`).",
            "type": [
              "string",
              "null"
            ]
          },
          "structured_content": {
            "description": "The MCP result's `structuredContent`, for the view. The model was\ngiven it only when `content` is empty."
          },
          "task": {
            "$ref": "#/components/schemas/ResultTask",
            "description": "For a call that started an MCP task: which. Absent otherwise."
          },
          "ui_resource": {
            "description": "The UI resource the tool links to (`_meta.ui.resourceUri`),\nnamespaced as `/mcp` serves it: `resources/read` it there.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "index",
          "name",
          "output",
          "is_error",
          "ms",
          "server_label",
          "ui_resource",
          "structured_content",
          "content",
          "call_id"
        ],
        "type": "object"
      },
      "ToolStartFrame": {
        "description": "A tool call starting to stream: its position and name.",
        "properties": {
          "id": {
            "description": "The model's id of the call; only a turn without tools says it.",
            "type": "string"
          },
          "index": {
            "description": "The call's position in its turn.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "name": {
            "description": "The tool's exposed name.",
            "type": "string"
          }
        },
        "required": [
          "index",
          "name"
        ],
        "type": "object"
      },
      "Transfer": {
        "description": "A transfer, as every route and `transfer.updated` answer it.",
        "properties": {
          "app_id": {
            "description": "The app id the offer names; the receiver declared it at pairing.",
            "type": "string"
          },
          "created_at": {
            "description": "RFC 3339 UTC.",
            "type": "string"
          },
          "end_reason": {
            "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
            "type": [
              "string",
              "null"
            ]
          },
          "ended_at": {
            "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
            "type": "string"
          },
          "filename": {
            "description": "The receiver's name for the file.",
            "type": "string"
          },
          "from": {
            "$ref": "#/components/schemas/TransferParty"
          },
          "id": {
            "description": "Opaque: 32 random lowercase hex digits.",
            "type": "string"
          },
          "kind": {
            "description": "The app's own word for what the file is.",
            "type": "string"
          },
          "received": {
            "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "sha256": {
            "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
            "type": "string"
          },
          "size": {
            "description": "The file's size in bytes.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "state": {
            "$ref": "#/components/schemas/TransferState"
          },
          "title": {
            "description": "What the card and the receiver show; may be empty.",
            "type": "string"
          },
          "to": {
            "$ref": "#/components/schemas/TransferParty"
          }
        },
        "required": [
          "id",
          "app_id",
          "kind",
          "title",
          "filename",
          "size",
          "sha256",
          "from",
          "to",
          "state",
          "received",
          "created_at",
          "expires_at",
          "ended_at",
          "end_reason"
        ],
        "type": "object"
      },
      "TransferParty": {
        "description": "One side of a transfer: the device by its key id, as the owner's\n`KeyRow` shows it, and its paired name without `device:`, as it was when\nthe offer was made.",
        "properties": {
          "device_id": {
            "format": "int64",
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "device_id",
          "name"
        ],
        "type": "object"
      },
      "TransferRole": {
        "description": "`GET /transfers/api/transfers`' `role` (a device's).",
        "oneOf": [
          {
            "const": "incoming",
            "description": "Offered to the caller (from `ready` on).",
            "type": "string"
          },
          {
            "const": "outgoing",
            "description": "Offered by the caller.",
            "type": "string"
          }
        ]
      },
      "TransferState": {
        "anyOf": [
          {
            "const": "uploading",
            "description": "Offered; the sender uploads its bytes. The receiver does not see it.",
            "type": "string"
          },
          {
            "const": "ready",
            "description": "Every byte arrived and its sha256 matched: offered to the receiver.",
            "type": "string"
          },
          {
            "const": "delivered",
            "description": "The receiver said it got the bytes; they are deleted.",
            "type": "string"
          },
          {
            "const": "declined",
            "description": "The receiver declined it; the bytes are deleted.",
            "type": "string"
          },
          {
            "const": "canceled",
            "description": "The sender or the owner canceled it, or a party device was disabled\nor deleted; the bytes are deleted.",
            "type": "string"
          },
          {
            "const": "expired",
            "description": "Not delivered by `expires_at`; the bytes are deleted.",
            "type": "string"
          },
          {
            "const": "failed",
            "description": "The uploaded bytes' sha256 was not the offer's; they are deleted.",
            "type": "string"
          }
        ],
        "description": "A transfer's state (§1)."
      },
      "TurnDetectionMode": {
        "anyOf": [
          {
            "const": "semantic_vad",
            "description": "A turn model decides when the speaker is done.",
            "type": "string"
          },
          {
            "const": "server_vad",
            "description": "Silence windows only.",
            "type": "string"
          },
          {
            "const": "push_to_talk",
            "description": "A turn is what is spoken while the talk key is held.",
            "type": "string"
          }
        ],
        "description": "How voice mode detects the end of the user's turn."
      },
      "UsedBy": {
        "description": "What uses a profile, computed when it is read: what a delete would\nclear.",
        "properties": {
          "folders": {
            "description": "Folders whose defaults name it.",
            "items": {
              "$ref": "#/components/schemas/FolderRef"
            },
            "type": "array"
          },
          "threads": {
            "description": "Stored threads that picked it, archived ones included.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "threads",
          "folders"
        ],
        "type": "object"
      },
      "VoiceModels": {
        "description": "The models one spoken turn went through.",
        "properties": {
          "asr": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ServedModel"
              },
              {
                "type": "null"
              }
            ]
          },
          "chat": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ServedModel"
              },
              {
                "type": "null"
              }
            ]
          },
          "tts": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ServedModel"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "asr",
          "chat",
          "tts"
        ],
        "type": "object"
      },
      "VoiceName": {
        "description": "The voice the text-to-speech model is asked for.",
        "properties": {
          "inherits": {
            "description": "Settings → Realtime's default voice, when no name is named: applied by\nvoice mode, never sent as the voice.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "The voice to ask for; `null`: none is named, and voice mode's own\nchain decides.",
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "description": "Why a voice set at a less specific level is not used here.",
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VoiceSource"
              },
              {
                "type": "null"
              }
            ],
            "description": "Where `name` came from. With no name, `realtime` when Settings →\nRealtime's default voice is where that chain starts, else `null`."
          }
        },
        "required": [
          "name",
          "source",
          "inherits",
          "note"
        ],
        "type": "object"
      },
      "VoiceProblem": {
        "description": "Something that blocks a voice feature.",
        "properties": {
          "code": {
            "description": "`not_configured`, `unresolved`, or `voice_needs_transcript` (a voice\nclip the text-to-speech model cannot clone without its transcript).",
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "stage": {
            "description": "`asr` or `tts`.",
            "type": "string"
          }
        },
        "required": [
          "stage",
          "code",
          "message"
        ],
        "type": "object"
      },
      "VoiceResolved": {
        "description": "A thread's voice, resolved.",
        "properties": {
          "asr": {
            "$ref": "#/components/schemas/Stage",
            "description": "The speech-to-text stage: dictation, voice mode, audio attachments."
          },
          "audio_input": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AudioInputShown"
              },
              {
                "type": "null"
              }
            ],
            "description": "Whether a voice turn goes to the chat model as audio, and why not."
          },
          "language": {
            "$ref": "#/components/schemas/Sourced_Nullable_string",
            "description": "The language the user speaks, ISO 639-1; `value: null` is none, the\nspeech-to-text model detects it."
          },
          "language_notes": {
            "description": "Where a stage's model does not take its language as set.",
            "items": {
              "$ref": "#/components/schemas/LanguageNote"
            },
            "type": "array"
          },
          "problems": {
            "description": "What blocks a voice feature now: a stage with no alias, or one whose\nalias no longer resolves.",
            "items": {
              "$ref": "#/components/schemas/VoiceProblem"
            },
            "type": "array"
          },
          "read_aloud": {
            "$ref": "#/components/schemas/Sourced_boolean",
            "description": "Whether replies are read aloud as they stream."
          },
          "realtime": {
            "$ref": "#/components/schemas/RealtimeAvailability",
            "description": "Whether voice mode may bind the thread."
          },
          "reply_language": {
            "$ref": "#/components/schemas/Sourced_Nullable_string",
            "description": "The language replies are in, ISO 639-1: the thread's, Settings', else\nthe spoken one (`source: speech_in`); `value: null` is none, the reply\nfollows the user."
          },
          "seed": {
            "description": "The thread's text-to-speech seed; `null` until its first use draws\none.",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "speech_style": {
            "$ref": "#/components/schemas/SpeechStyle",
            "description": "The speech instructions the read-aloud uses."
          },
          "tts": {
            "$ref": "#/components/schemas/Stage",
            "description": "The text-to-speech stage: read-aloud and voice mode."
          },
          "turn_detection": {
            "$ref": "#/components/schemas/Sourced_TurnDetectionMode",
            "description": "How voice mode detects the end of a turn."
          },
          "voice": {
            "$ref": "#/components/schemas/VoiceName",
            "description": "The voice the text-to-speech model is asked for."
          }
        },
        "required": [
          "asr",
          "tts",
          "voice",
          "speech_style",
          "language",
          "reply_language",
          "language_notes",
          "read_aloud",
          "turn_detection",
          "audio_input",
          "seed",
          "problems",
          "realtime"
        ],
        "type": "object"
      },
      "VoiceSource": {
        "anyOf": [
          {
            "const": "thread",
            "description": "The thread's own override.",
            "type": "string"
          },
          {
            "const": "profile",
            "description": "The thread's personality profile.",
            "type": "string"
          },
          {
            "const": "chat",
            "description": "Settings → Chat → Voice.",
            "type": "string"
          },
          {
            "const": "realtime",
            "description": "Settings → Realtime.",
            "type": "string"
          },
          {
            "const": "row",
            "description": "The text-to-speech model's own description of its voice (a speech\nstyle only).",
            "type": "string"
          },
          {
            "const": "speech_in",
            "description": "The reply language only: none is set for it, so it is the language the\nuser speaks.",
            "type": "string"
          }
        ],
        "description": "The level a value came from."
      },
      "VoiceTiming": {
        "description": "A spoken reply's timing: each stage measured from the one before,\n`to_first_audio_ms` their sum from the end of speech, `cold` the stages\nthat loaded during the turn.",
        "properties": {
          "asr_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "cold": {
            "description": "The stages that loaded during the turn.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "end_of_turn_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "first_audio_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "first_clause": {
            "description": "`announcement` when the first clause said was an announcement of a\nskipped block.",
            "type": "string"
          },
          "first_clause_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "first_token_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "input": {
            "$ref": "#/components/schemas/InputPath",
            "description": "How the turn reached the chat model; absent with audio input off."
          },
          "input_why": {
            "description": "Why the transcript went where audio input is on.",
            "type": "string"
          },
          "message_id": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "models": {
            "$ref": "#/components/schemas/VoiceModels"
          },
          "reasoning_ms": {
            "description": "How long the chat model reasoned before its first token (part of\n`first_token_ms`); absent when it did not reason.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "response_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "to_first_audio_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "total_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "transcript_wait_ms": {
            "description": "How long the first output was held for the turn's transcript; absent\non the transcript path.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "response_id",
          "message_id",
          "end_of_turn_ms",
          "asr_ms",
          "first_token_ms",
          "first_clause_ms",
          "first_audio_ms",
          "total_ms",
          "to_first_audio_ms",
          "cold",
          "models"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKeyHeader": {
        "description": "The same keys, in the header Anthropic SDKs send them in.",
        "in": "header",
        "name": "x-api-key",
        "type": "apiKey"
      },
      "bearer": {
        "description": "An lmgw API key: a client, owner or agent key. A paired device presents none: it authenticates by its client certificate on the device listener, which refuses a bearer there 400 credential_on_device_listener. A bearer key a device was paired with before TLS (lmgw-device-…) is refused 401 device_key_unknown on every listener: pair the device again.",
        "scheme": "bearer",
        "type": "http"
      },
      "session": {
        "description": "The dashboard's own session cookie. Same-origin only, and only ever an owner row.",
        "in": "cookie",
        "name": "lmgw_session",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "description": "What a developer builds on lmgw: the inference plane (OpenAI-, Anthropic- and llama.cpp-compatible routes, plus MCP), the device (Chat) API a paired client uses, and the run API an agent uses with its own token. The owner's admin plane, the dashboard that configures the gateway, is in the admin document, GET /api/openapi.json.",
    "title": "lmgw",
    "version": "0.6.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/agents/runs/{job_id}": {
      "get": {
        "description": "One run with its rows: the executor's live buffer while it is in flight, the stored result once it has ended. Ownership is checked before existence, so a run that belongs to another caller and a missing one get the same refusal.",
        "operationId": "get_api_agents_runs_job_id",
        "parameters": [
          {
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /api/agents/runs/{job_id}` — the job plus its rows.",
                  "properties": {
                    "batch": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentBatchShape"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The agent's current review shape, so the table can be drawn from a run\nalone — including one finished last week, which is what \"reopen this\nrun's review\" needs. For a ledger run its `columns` carry the undeclared\nkeys the events brought, appended after the declared ones in first-seen\norder."
                    },
                    "job": {
                      "$ref": "#/components/schemas/AgentRunSummary"
                    },
                    "log": {
                      "description": "The run log: `log` events, rejected events, and the lines lmgw itself\nwrote. Empty for an in-process run, which has none yet.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "result": {
                      "description": "The apply step's structured output and the run's usage total, once the\nrun has finished."
                    },
                    "rows": {
                      "description": "The reviewed rows: the executor's live buffer while running, the job\nresult after. Rows are deliberately **not** pushed through the generic\njobs feed.",
                      "items": true,
                      "type": "array"
                    }
                  },
                  "required": [
                    "job",
                    "rows",
                    "result",
                    "batch",
                    "log"
                  ],
                  "title": "AgentRunDetail",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Get one agent run",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "agent-self",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/api/agents/runs/{job_id}/close": {
      "post": {
        "description": "Closes a run this caller owns with its terminal status.",
        "operationId": "post_api_agents_runs_job_id_close",
        "parameters": [
          {
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentRunCloseBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer of a write that has nothing to report but that it\nhappened: `{\"ok\": true}`.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`; a failure is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "Ack",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Close an agent run",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "ledger",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/api/agents/runs/{job_id}/events": {
      "post": {
        "description": "Appends one ledger event, an array of them, or an NDJSON batch to a run this caller owns, straight into the run's live buffer, which the dashboard's Run tab reads.",
        "operationId": "post_api_agents_runs_job_id_events",
        "parameters": [
          {
            "in": "path",
            "name": "job_id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentRunEventsBody"
              }
            },
            "application/x-ndjson": {
              "schema": {
                "description": "Newline-delimited JSON: one value per line, each decoded as the application/json form's single-object case.",
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /api/agents/runs/{job_id}/events` — what became of the batch.",
                  "properties": {
                    "applied": {
                      "description": "How many events went into the run.",
                      "format": "uint",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "ok": {
                      "description": "Always `true`: rejected events are reported below, not failed.",
                      "type": "boolean"
                    },
                    "rejected": {
                      "description": "One line per event the run did not take (unparseable, or refused by\nthe run's rules), in the order they were sent.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "ok",
                    "applied",
                    "rejected"
                  ],
                  "title": "AgentEventsApplied",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Append agent run events",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "ledger",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/api/agents/{id}": {
      "get": {
        "description": "One agent's full definition: the complete document for owner credentials or, for the agent's own token, the same document with host paths substituted out.",
        "operationId": "get_api_agents_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /api/agents/{id}` — everything the detail page's three tabs need.",
                  "properties": {
                    "batch": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentBatchShape"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The run surface a `batch` or `container` agent offers. `None` for a\n`chat` agent."
                    },
                    "budget": {
                      "$ref": "#/components/schemas/AgentBudget",
                      "description": "The two Responses settings a turn is bounded by, shown next to Apply."
                    },
                    "config": {
                      "description": "Stored config values with every `secret` field replaced by\n`{ \"has_value\": bool }`. The value itself never leaves the process."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "currency": {
                      "description": "The gateway's display currency, so a run's cost is printed the way the\nUsage page prints every other one.",
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "dev_url": {
                      "description": "The dev-server override. While it is set, `/agents/<id>/app/**`\ngoes there and no container is started for the app; runs and applies\nstill use the image. Empty means \"served from the image\".",
                      "type": "string"
                    },
                    "effective_model": {
                      "type": "string"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "error": {
                      "description": "Set when the stored manifest could not be read at all — a row written by\na newer build. The document still comes back `200` with whatever could\nbe read, so the Definition editor stays reachable for the very manifest\nthat needs fixing; a `400` here would lock the client out of it.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "fields": {
                      "description": "The config schema flattened into form fields, in document order.",
                      "items": {
                        "$ref": "#/components/schemas/AgentField"
                      },
                      "type": "array"
                    },
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "last_run": {
                      "$ref": "#/components/schemas/AgentRunSummary",
                      "description": "The agent's most recent run, with its outcome (`status`, `error`, tokens,\ncost) — the same summary the catalog card carries. While a run is in\nflight it is that run. Absent when the agent has never run, when\nretention pruned its runs, and on a row this build cannot read."
                    },
                    "live_job": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentRunSummary"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The run in flight, if any."
                    },
                    "manifest": {
                      "description": "The manifest as stored: the canonical serialization, **as text** — what\nthe Definition editor loads and what Export writes.\n\nText and not a `serde_json::Value` on purpose. `serde_json::Map` is a\n`BTreeMap`, so a `Value` here would alphabetize the config schema's\nproperties and silently re-sort the form the author laid out.\nParse it client-side if a tree is needed, and post it back to\n`agent_set` as a **string**: an object argument is accepted but arrives\nalready re-sorted, and the import report says so.",
                      "type": "string"
                    },
                    "model_alias": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "portability": {
                      "$ref": "#/components/schemas/AgentPortability",
                      "description": "Whether an export of this agent would land on another box, and what the\nreceiver would have to do if not. The same answer the export file's\n`portability` key carries, on the page that offers the download."
                    },
                    "provenance": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentProvenance"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Where this row was installed from. `None` for a row that came\nfrom a pasted manifest rather than from an image."
                    },
                    "requires": {
                      "items": {
                        "$ref": "#/components/schemas/AgentRequirement"
                      },
                      "type": "array"
                    },
                    "requires_ok": {
                      "type": "boolean"
                    },
                    "resettable": {
                      "description": "A shipped manifest exists for this id, so \"Reset to shipped\" applies.",
                      "type": "boolean"
                    },
                    "runtime": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentRuntime"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "What a `container` agent runs under. `None` for every other kind."
                    },
                    "service": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AgentService"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Service mode, when the manifest declares it.\n`None` means no App tab, no proxy route and no `agent:<id>` MCP row."
                    },
                    "source": {
                      "type": "string"
                    },
                    "threads": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "token": {
                      "$ref": "#/components/schemas/AgentToken",
                      "description": "The agent's own token — its name, whether one has been minted, and the scope it\ncurrently carries. **Never the value**:\nthat comes from `agent_token_get`, which is what Copy token calls.",
                      "x-lmgw-secret": true
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "warnings": {
                      "description": "Warnings that are not tool gaps. Start is disabled while any of them carries\n`blocks_start`.",
                      "items": {
                        "$ref": "#/components/schemas/AgentWarning"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "version",
                    "kind",
                    "source",
                    "enabled",
                    "model_alias",
                    "effective_model",
                    "manifest",
                    "config",
                    "fields",
                    "requires",
                    "requires_ok",
                    "budget",
                    "live_job",
                    "threads",
                    "resettable",
                    "batch",
                    "warnings",
                    "runtime",
                    "token",
                    "service",
                    "provenance",
                    "dev_url",
                    "portability",
                    "currency",
                    "created_at",
                    "updated_at",
                    "error"
                  ],
                  "title": "AgentDetail",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Get an agent",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "agent-self",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/api/agents/{id}/runs": {
      "get": {
        "description": "This agent's run history. For the agent's own token, a run's error text has host paths substituted out the same way the detail read does.",
        "operationId": "get_api_agents_id_runs",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentRunSummary"
                  },
                  "title": "Array_of_AgentRunSummary",
                  "type": "array"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List an agent's runs",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "agent-self",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "Opens a run from outside lmgw, exactly as the manifest's own trigger would. An agent has at most one live run: a second open while one is live is refused with the running job's id.",
        "operationId": "post_api_agents_id_runs",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "phase": {
                    "default": null,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "rows": {
                    "default": [],
                    "items": {
                      "$ref": "#/components/schemas/Row"
                    },
                    "type": "array"
                  }
                },
                "title": "OpenBody",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /api/agents/{id}/runs` — a run opened from outside lmgw.",
                  "properties": {
                    "deadline_seconds": {
                      "description": "How long the run has before lmgw ends it; `0` is no deadline.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "run": {
                      "description": "The run's job id, for `/api/agents/runs/{job_id}` and its events and\nclose routes.",
                      "format": "int64",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "run",
                    "deadline_seconds"
                  ],
                  "title": "AgentRunOpened",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /api/agents/{id}/runs` refused with `409`: the agent already has a\nrun in flight, and `run` is its job id, so the caller can watch that one.",
                  "properties": {
                    "code": {
                      "description": "Always `already_running`.",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "run": {
                      "description": "The job id of the run that is in flight.",
                      "format": "int64",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "run"
                  ],
                  "title": "AgentRunConflict",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Open an agent run",
        "tags": [
          "agent-runtime"
        ],
        "x-lmgw-capability": "ledger",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/api/version": {
      "get": {
        "description": "The one /api read a page may do before it has a session: the dashboard's footer and its login view print this.",
        "operationId": "get_api_version",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /api/version` — build identity, also serves as the liveness probe.",
                  "properties": {
                    "version": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "version"
                  ],
                  "title": "VersionInfo",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {}
        ],
        "summary": "Get the gateway version",
        "tags": [
          "meta"
        ],
        "x-lmgw-capability": "public",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/attachments/{id}": {
      "get": {
        "description": "The stored file as uploaded, with the media type the bytes were sniffed as (image/png, application/pdf, audio/wav, ...); a text file is served as text/plain; charset=utf-8. The answer carries X-Content-Type-Options: nosniff and Content-Security-Policy: sandbox, so a file opened in a browser cannot run anything, and Accept-Ranges: bytes. One Range (bytes=a-b, bytes=a- or bytes=-n) answers 206 with Content-Range, as a media player resumes or seeks; a Range lmgw does not read (several ranges, another unit), or any If-Range, serves the whole file. 416 range_not_satisfiable, with Content-Range: bytes */size, for a range that names no byte of the file. 404 not_found for an attachment that is not there or not the caller's.",
        "operationId": "get_chat_api_attachments_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read an attachment's bytes",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/attachments/{id}/delete": {
      "post": {
        "description": "Removes an attachment that was not sent yet. 404 not_found for one that is not there or not the caller's; 409 attachment_sent once it was sent with a message (it belongs to that message then).",
        "operationId": "post_chat_api_attachments_id_delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer of a write that has nothing to report but that it\nhappened: `{\"ok\": true}`.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`; a failure is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "Ack",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Delete a draft attachment",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/attachments/{id}/media": {
      "post": {
        "description": "Runs one action on a picture of a thread, directly — no chat model is called: reroll draws it again with the same prompt and settings and a new seed (an edit is made again from the picture it started from), vary makes a variation of it on a model without instruction edits and edit changes it by an instruction on a model with them (prompt defaults to the picture's own, strength to its own for vary), upscale runs an ESRGAN upscaler (upscaler: a file stem of the image models dir's upscalers/, the server's first one when omitted; repeats 1 to 4) on a local image model — a resident one that can upscale, preferring the one that made the picture, else that one, else the smallest. The model rows are the caller's. The answer is SSE: `action` first (call_id act-<boot>-<n>, unique across restarts, the action, the model, the source attachment), `progress` frames while it runs (lossy: a newer one supersedes an older), then `done` with the stored picture's attachment metadata and a sentence about it, or `error`. The picture is stored as an attachment of the thread with source action, bound to the source's message, its meta.media naming parent; it is not shown to the thread's model, nor named to it by att:N, unless the user attaches it (a copy as an upload). The action goes on when the stream is closed; a key that is revoked stops it and ends the stream with an `error` frame (code revoked), a gateway that stops ends the stream with code gateway_stopping; a thread deleted or kept as a stored chat while it runs stops it, its `error` code thread_gone, and nothing of it is kept. An upscale whose result would exceed the chosen image model's max_upscale_width/height is refused with too_large, naming the numbers. Refused before any frame: 404 not_found for an attachment that is not there or not the caller's, 422 not_an_image, 409 not_sent for a picture of no message yet (a draft, a reply still being written), 422 no_model, model_unavailable, not_rerollable, source_missing, wrong_action, prompt_required, no_upscaler, no_image_model, unknown_upscaler or bad_request for what the picture or the body lacks.",
        "operationId": "post_chat_api_attachments_id_media",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/attachments/{id}/media` (design §8.3): run one action on\na picture of the thread. Every field but `action` is optional; what a\nfield does not say is the source picture's own (its prompt, its strength)\nor the server's (the upscaler, one repeat).",
                "properties": {
                  "action": {
                    "$ref": "#/components/schemas/MediaAction"
                  },
                  "prompt": {
                    "description": "`vary` and `edit`: the prompt, the source's own when omitted.",
                    "type": "string"
                  },
                  "repeats": {
                    "description": "`upscale`: how many times to run it, 1 to 4 (sd-server's bound).",
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "strength": {
                    "description": "`vary`: how far to move from the picture, 0 to 1; the source's own\nwhen omitted, else the row's default.",
                    "format": "double",
                    "type": "number"
                  },
                  "upscaler": {
                    "description": "`upscale`: the upscaler's name (a file stem of the image models dir's\n`upscalers/`); the server's first compatible one when omitted.",
                    "type": "string"
                  }
                },
                "required": [
                  "action"
                ],
                "title": "MediaActionRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "action": {
                "description": "The action stream's first frame (`event: action`): the id the action\nruns under — what its progress frames carry as `call_id`, and what the\nmedia cancel route takes — and the model it runs on.",
                "properties": {
                  "action": {
                    "description": "`reroll`, `vary`, `edit` or `upscale`.",
                    "type": "string"
                  },
                  "call_id": {
                    "description": "`act-<boot>-<n>`: `<boot>` 32 random bits (eight hex digits) drawn\nonce per gateway process, `<n>` a counter, so a later process repeats\nan id only if it draws the same bits.",
                    "type": "string"
                  },
                  "model": {
                    "description": "The model the action runs on (`image/z-image-turbo`); absent for an\nupscale, whose row the gateway picks when it runs (its `done` names\nit).",
                    "type": "string"
                  },
                  "source": {
                    "description": "The attachment the action started from.",
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "call_id",
                  "action",
                  "source"
                ],
                "title": "MediaActionStarted",
                "type": "object"
              },
              "done": {
                "description": "The action's last frame on success (`event: done`): the picture it made,\nstored as the thread's attachment (`source = \"action\"`, bound to the\nsource's message, `meta.media.parent` the source), and a sentence about\nit.",
                "properties": {
                  "attachment": {
                    "$ref": "#/components/schemas/AttachmentMeta"
                  },
                  "call_id": {
                    "type": "string"
                  },
                  "text": {
                    "description": "What happened, in words: `Made image att:58 (1024x1024) with …`.",
                    "type": "string"
                  }
                },
                "required": [
                  "call_id",
                  "attachment",
                  "text"
                ],
                "title": "MediaActionDone",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "progress": {
                "description": "The `progress` event of a `tool` frame: a running image or audio call's\nstage, step and latest preview. Lossy: a reader that falls behind misses\nsome (the next one supersedes them), and they are not in the change\nfeed.",
                "properties": {
                  "call_id": {
                    "description": "The call's id, as its `ready` frame carries it.",
                    "type": "string"
                  },
                  "cancel": {
                    "$ref": "#/components/schemas/CancelKind",
                    "description": "What a cancel would do now, while an image job runs; absent before\nthe job exists (a cancel then just stops the wait) and for audio."
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "elapsed_ms": {
                    "description": "Since the call started.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "free_bytes": {
                    "description": "`waiting_for_room`: the memory free when it was last measured.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image reference being downloaded.",
                    "type": "string"
                  },
                  "model": {
                    "description": "The model the phase is about: the one being unloaded for\n`unloading`, the call's own otherwise.",
                    "type": "string"
                  },
                  "needs_bytes": {
                    "description": "`waiting_for_room`: the memory the model needs, headroom included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "pass": {
                    "description": "The sampling pass (a batch item, a high- or low-noise stage, a hires\npass); a new pass starts its steps again.",
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "phase": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/MediaPhase"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "preview": {
                    "description": "The latest preview as the image server drew it: base64, PNG. Its\npixel size depends on the row's preview mode (a quick sketch is the\nlatent's size, an eighth of the picture's side on the spike's\npipeline).",
                    "type": "string"
                  },
                  "queue_position": {
                    "description": "`queued`: the job's place in the image server's queue.",
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not (\"size not\nknown — …\").",
                    "type": "string"
                  },
                  "step": {
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent when it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "total_steps": {
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "call_id",
                  "phase",
                  "elapsed_ms"
                ],
                "title": "ToolProgressFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Run an image card's action",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/attachments/{id}/mode": {
      "post": {
        "description": "Sets how a PDF whose every page has text goes to the model: mode text sends the extracted text, images sends the pages as images. Drafts only. 400 bad_request for another mode, 404 not_found for an attachment that is not there or not the caller's, 409 attachment_sent once it was sent, 422 mode_not_applicable for any file but a text-class PDF (scanned and hybrid ones, and every other kind, are sent automatically).",
        "operationId": "post_chat_api_attachments_id_mode",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/attachments/{id}/mode`'s body.",
                "properties": {
                  "mode": {
                    "description": "`text` sends the PDF's extracted text, `images` its pages as\nimages.",
                    "enum": [
                      "text",
                      "images"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "mode"
                ],
                "title": "ModeRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer to a mode change.",
                  "properties": {
                    "id": {
                      "description": "The attachment.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "mode": {
                      "description": "The mode now set, `text` or `images`.",
                      "type": "string"
                    },
                    "ok": {
                      "description": "Always `true`; a refusal is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "id",
                    "mode"
                  ],
                  "title": "ModeSet",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Choose how a PDF is sent",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/attachments/{id}/text": {
      "get": {
        "description": "A text file as it is, a PDF's or office file's extracted text, or an audio file's transcript, as text/plain; charset=utf-8, with X-Content-Type-Options: nosniff and Content-Security-Policy: sandbox. 404 not_found for an attachment that is not there or not the caller's, and 404 no_text for an image, or an audio file with no transcript yet.",
        "operationId": "get_chat_api_attachments_id_text",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain; charset=utf-8": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read what the model reads of an attachment",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/attachments/{id}/transcribe": {
      "post": {
        "description": "Runs the speech-to-text call again for an audio draft, after it failed at upload or once a model is set, and answers the attachment's new `meta` (the transcript's alias and token estimate in place of `transcript_error`). The body is empty. 404 not_found for an attachment that is not there or not the caller's, 409 attachment_sent once it was sent, 422 not_audio for any other kind, 422 stt_not_set when no speech-to-text model is set for the thread, 422 transcription_failed with the call's own message.",
        "operationId": "post_chat_api_attachments_id_transcribe",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer to a new transcription.",
                  "properties": {
                    "id": {
                      "description": "The attachment.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AttachmentFacts",
                      "description": "The attachment's `meta` now, the transcript's alias and token\nestimate in place of the earlier `transcript_error`. The same object\nas `AttachmentMeta::meta`."
                    },
                    "ok": {
                      "description": "Always `true`; a refusal is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "id",
                    "meta"
                  ],
                  "title": "Transcribed",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Transcribe an audio draft again",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/export": {
      "get": {
        "description": "A zip with one file per stored thread, in the format asked for (md or json, as for one thread), a directory per folder named after it, and a README.txt. archived=0 takes the active threads, 1 the archived ones, all (the default) both; another value is a 400 bad_request, as is a format other than md, markdown or json. The answer carries Content-Disposition: attachment (lmgw-chats-{date}.zip), Content-Length and Cache-Control: no-store; it is as large as the Chat is and not capped. Temporary threads are not part of a zip. A device key's zip leaves out Admin Chat threads.",
        "operationId": "get_chat_api_export",
        "parameters": [
          {
            "in": "query",
            "name": "archived",
            "required": false,
            "schema": {
              "default": "",
              "description": "Zips only: `0` active threads, `1` archived threads only, `all`\n(default) both.",
              "enum": [
                "0",
                "1",
                "all"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "default": "",
              "description": "`md` (default; `markdown` is accepted too) for a readable\ntranscript, `json` for the lossless `lmgw.chat.v1` file. A zip holds\none file of this format per thread.",
              "enum": [
                "md",
                "markdown",
                "json"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/zip": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Export every chat",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/feed": {
      "get": {
        "description": "One SSE stream per client. `hello` first: the epoch, the cursor the stream continues from, the keep-alive interval and the retention, who the feed is for, the hold, the turns and voice sessions live now, and open_approvals: every call still waiting for a decision at that cursor in a thread the reader may see (a thread's last reply's open calls), each as approval.requested renders it. For a device, hello also carries its own facts: urls (its row's lmgw URLs, https, in the owner's order: replace the stored list with them), cert ({not_after, notice_after}, RFC 3339 UTC, the dates of its certificate: show the notice from them) and dashboard_url (where the dashboard is, as a URL derived from bind_addr: sent to a device paired as this computer, and to any other only when bind_addr is not loopback; null otherwise). A device's feed also sets TCP_USER_TIMEOUT on its connection to its keep-alive, so a keep-alive a vanished device never acknowledges ends the stream within one more interval. Then stored events (thread.*, folder.*, folder.current, message.*, profile.*, approval.*, task.*, device.revoked), each with an `id:` that is its cursor \"<epoch>:<seq>:<tag>\" (opaque: hand it back as it came), rendered as the thread or folder is when it is delivered (message.added and message.updated carry the thread's id, its title now (thread_title) and the messages the change wrote, whole, as GET /chat/api/threads/{id} lists them now — a user message as stored, a reply once saved (never while it streams), a task result entering the thread, an edit, a continue, a resumed turn, a spoken reply cut to what was heard or annotated, a stored retrieval, a call a reply waits on decided — so a client shows the message or a notification without a fetch; a message gone by delivery is left out, and an event whose messages or thread are all gone is not sent; message.deleted names the ids that went (a delete, the cut of an edit's resend or a regenerate, a spoken reply nobody heard); a thread deleted whole is thread.deleted alone; a profile.* event names the profile's id and name as its write left them; every reader receives it, devices included; approval.requested and approval.decided name a call a turn waits on and its decision, with the call's call_id as the turn's ready, approval and result frames carry it, rendered from the reply (approval.requested with the thread's title now, thread_title, so a client shows it or a notification without a fetch), and are not delivered once the reply is gone (approval.requested neither once its call is decided: the decision follows); task.started names an MCP task a turn's tool call started, task.done its result entering the thread as a message of role tool, both as their write left them; device.revoked names a paired device whose key was deleted, as {kind: device, name}, so a client running work it started (a host of its MCP tasks) may cancel that work — the owner receives every one, a device only one about a device the feed showed it changes of, or that started a task it hosts that was still running; a disable, a rotate or an expiry is no delete and says nothing); and live events (turn.*, voice.*, hold, state, caught_up), which have no id. caught_up {cursor} comes once per stream, when every stored event up to the cursor hello named has been delivered (or passed as not for this reader): right after hello, and the resync and profile list a cursor may owe, when there was nothing to catch up, else right after the catch-up's last event. The approval.* events before it are already reflected in hello.open_approvals; from caught_up on, approval.requested adds to that set and approval.decided removes from it, as does the deletion of its thread or its reply. Every `state` carries open_approvals again, read when it is sent, and replaces that set, matched by approval_request_id (null when lmgw could not read it for a state sent for another reason: keep the set you have; one sent because the set moved ends the stream instead, and the reconnect's hello carries it); the feed sends one after any move of what a device may see, after a thread or folder came into a device's reach (its *.created), and after a resync that passed records — before caught_up when the retention pruned past a stream still catching up, so caught_up hands over the true set. Open the feed first, then load the list: a turn in `hello` may name a thread whose thread.created follows in the catch-up. Resume with ?since=<cursor> or Last-Event-ID (which wins: a browser reconnects with the URL it opened). A cursor the feed cannot honour — another database's, one whose event is not the one the gateway holds at that number now (its data restored from an older copy), older than the retention, newer than the newest — gets `resync` with the reason, then events from now; so does a stream still catching up when the retention prunes past it, and one at an event that cannot be read after a few attempts. Every `resync` is followed by the whole profile list again, as profile.created events without an id. A client that reads live events slower than they happen, past the live buffer, gets `state` instead of the events it missed. Keep-alive comments every keepalive_s seconds: the stream's own when the request asks for one (?keepalive_s=, from 1 to chat_feed_keepalive_max_s, Settings → Chat → Change feed → Longest keep-alive, default 900; outside that a 400 bad_request naming the bound and the setting), else the gateway's chat_feed_keepalive_s; hello.keepalive_s says which. Only the comments follow it: stored events are never held back by a long one. One may carry an `id:` and no data, which only moves the cursor. When the key is disabled, rotated, deleted or expires, `revoked` and the end. When the gateway shuts down, the stream ends without an event: reconnect with the last cursor once it is back. A device key never receives an event about an Admin Chat thread, nor about a folder a device deleted while it held threads the device could not see (until it is shown to devices again); and about a thread or folder with the self-admin toolset (lmgw) attached only while what the device's admin tools may do is above off (hello.self_admin: its level capped by the gateway's self-admin level). The gaps that leaves in the sequence are expected, and a thread in a folder the device does not see is in no folder for it. When a thread or folder leaves a device's reach (the toolset attached), the device receives its deletion, and a fresh `state` when that changed what is live for it; when it comes back (the toolset taken off, the folder shown again), its creation, and the same. When what the device's admin tools may do moves above off (its own level raised, or the gateway's self-admin level raised from off), the threads and folders with the toolset arrive as thread.created and folder.created (and its threads in such a folder as thread.updated), then a fresh `state`; when it moves to off, they go as thread.deleted and folder.deleted, in a delete's order, then a fresh `state`. `state` carries self_admin, what the device's admin tools may do now (its level capped by the gateway's self-admin level), and follows every change of the device's level and every change of the gateway's that moves it, so a connected device learns there that it changed. A device that resumes from a cursor older than a change above off or back gets `resync` at that point instead, and nothing about those threads and folders that it may not see now, or that was written while it could not see them: reload what you show.",
        "operationId": "get_chat_api_feed",
        "parameters": [
          {
            "in": "query",
            "name": "keepalive_s",
            "required": false,
            "schema": {
              "default": null,
              "description": "Seconds between this stream's keep-alive comments, from 1 to\n`chat_feed_keepalive_max_s` (Settings → Chat → Change feed → Longest\nkeep-alive, default 900); a value outside is a 400 `bad_request`\nnaming the bound and the setting. Without it the stream keeps the\ngateway's `chat_feed_keepalive_s`. `hello.keepalive_s` says the value\nthe stream keeps. Only the comments follow it: stored events are\nread at the gateway's own interval whatever this one is. A phone\nholding its feed in the background asks a long one (about 120), so\nits radio wakes less.",
              "format": "int64",
              "minimum": 1,
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "default": null,
              "description": "Resume after this cursor (`\"<epoch>:<seq>:<tag>\"`). A `Last-Event-ID`\nheader wins over it: a browser's `EventSource` reconnects with the\nURL it opened, so its `since` is the old one and the header the new.",
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "approval.decided": {
                "description": "`approval.decided`: a waiting call was decided — approved or declined\nby a client, or declined because a new message came\n(`chat_approvals::MOVED_ON`).",
                "properties": {
                  "approval_request_id": {
                    "type": "string"
                  },
                  "approve": {
                    "description": "Whether the call was approved — and, once that is known, could run:\n`false` with `not_run` for one approved whose turn could not\nstart.",
                    "type": "boolean"
                  },
                  "by": {
                    "description": "Who decided, as every author is named (\"the dashboard\", \"device\n'phone'\").",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "call_id": {
                    "description": "The call's id, as `approval.requested` has it. Absent from an lmgw\nbefore 2026-10-09.",
                    "type": "string"
                  },
                  "message_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "not_run": {
                    "description": "Approved, but the turn that was to run it could not start (its\nreply moved on, its starter went, its slot was refused), so it never\nran and its result says so. Recorded as a second `approval.decided`\nfor the call; both render this.",
                    "type": "boolean"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "message_id",
                  "approval_request_id",
                  "approve",
                  "by"
                ],
                "title": "ApprovalDecided",
                "type": "object"
              },
              "approval.requested": {
                "description": "`approval.requested`: a turn in the thread stopped on a call that waits\nfor an approval (client-apps design §6.5). Rendered from the reply's\npending state at delivery; a reply gone by then (deleted, regenerated),\nor a call decided by then (its `approval.decided` follows),\nis not delivered. With `thread_title`, `server_label`, `name` and\n`arguments` a client shows it, or a notification, without a fetch. Also\nthe shape of `Hello::open_approvals`' entries.",
                "properties": {
                  "approval_request_id": {
                    "type": "string"
                  },
                  "arguments": {
                    "description": "A JSON string.",
                    "type": "string"
                  },
                  "call_id": {
                    "description": "The call's id, as the turn's `ready`, `approval` and `result` frames\ncarry it. Absent from an lmgw before 2026-10-09.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply that waits.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "name": {
                    "description": "The tool's own name, as `chat_approvals::ApprovalRequest`.",
                    "type": "string"
                  },
                  "server_label": {
                    "type": "string"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "thread_title": {
                    "description": "The thread's title at delivery (in `hello`, at the head it read).",
                    "type": "string"
                  }
                },
                "required": [
                  "thread_id",
                  "thread_title",
                  "message_id",
                  "approval_request_id",
                  "server_label",
                  "name",
                  "arguments"
                ],
                "title": "ApprovalRequested",
                "type": "object"
              },
              "caught_up": {
                "description": "`caught_up`: the stream has delivered, or passed as not for this reader,\nevery stored event up to the head it opened at (`Hello::cursor` when\nthe client gave no cursor). Live, so no `id:`; sent once per stream: right\nafter `hello` (and the `resync` and profile list a cursor may owe) when\nthere was nothing to catch up, else right after the catch-up's last\nevent. From here on every `approval.*` changes `Hello::open_approvals`.",
                "properties": {
                  "cursor": {
                    "description": "Where the stream stands now (`\"<epoch>:<seq>:<tag>\"`): a client may\nresume from it, as from a keep-alive's `id:`.",
                    "type": "string"
                  }
                },
                "required": [
                  "cursor"
                ],
                "title": "CaughtUp",
                "type": "object"
              },
              "device.revoked": {
                "description": "`device.revoked`: a paired device's key was deleted, so the device is\ngone for good; a client that runs work it started — a host of MCP tasks\nwhose `lmgw/caller` named it — may cancel that work now (MCP Tasks\ndesign §4.1; client-apps design §2.2). Its tasks' results still enter\ntheir threads as they end.\n\nReceived by the dashboard and admin keys; by a device the feed showed\nthe deleted device's changes to (a stored event it may see carries the\ndeleted device's `by`), and by a device hosting a task the deleted\ndevice started that was still running. No other device hears of it: it\nnames no device the reader was not shown.\n\nOnly a delete is said: a disabled or expired key can be enabled or\nrenewed again, and its tasks wait meanwhile; a rotated one keeps its\nrow and pairs again under its name; a cleared hosting grant ends the\ndevice's own hosted tasks, each said by its `task.done` (`abandoned`).",
                "properties": {
                  "by": {
                    "description": "Who deleted it (\"the dashboard\").",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "device": {
                    "$ref": "#/components/schemas/FeedPrincipal",
                    "description": "The deleted device, as `Hello::principal` names a device (kind\n`device`, its paired name) and as `lmgw/caller` names it on a\nforwarded call; `FeedPrincipal::by` is the `by` its changes\ncarried."
                  }
                },
                "required": [
                  "device",
                  "by"
                ],
                "title": "DeviceRevoked",
                "type": "object"
              },
              "folder.created": {
                "description": "The folder as GET /chat/api/folders lists it now (its counts as the reader may see them), with `by` beside its fields; or, when the folder is gone by the time the event is delivered, {folder_id, deleted: true, by}. `deleted` tells the two apart.",
                "oneOf": [
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/FolderChanged"
                      },
                      {
                        "not": {
                          "required": [
                            "deleted"
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/FolderGone"
                      },
                      {
                        "properties": {
                          "deleted": {
                            "const": true
                          }
                        },
                        "required": [
                          "deleted"
                        ]
                      }
                    ]
                  }
                ]
              },
              "folder.current": {
                "description": "`folder.current`: an ongoing folder's current thread moved.",
                "properties": {
                  "by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "folder_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "previous_thread_id": {
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reason": {
                    "description": "Why it moved. To a new thread: `first` (the folder had none the\nreader can reach), `gone` (its thread could no longer be continued\nin it; only the dashboard and admin keys read this reason for a new\nthread), `idle` (no message for the folder's idle minutes) or\n`requested` (a client asked for a new thread, or created one in the\nfolder). To none: `gone` (the thread was deleted, moved out of the\nfolder or archived) or `not_ongoing` (the folder stopped being an\nongoing conversation).",
                    "type": "string"
                  },
                  "thread_id": {
                    "description": "The current thread now; `null` when the folder has none any more.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "folder_id",
                  "thread_id",
                  "previous_thread_id",
                  "reason",
                  "by"
                ],
                "title": "FolderCurrent",
                "type": "object"
              },
              "folder.deleted": {
                "description": "`folder.deleted`, and `folder.created` / `folder.updated` for a folder\nthat is gone by the time the event is delivered.",
                "properties": {
                  "by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "deleted": {
                    "type": "boolean"
                  },
                  "folder_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "folder_id",
                  "deleted",
                  "by"
                ],
                "title": "FolderGone",
                "type": "object"
              },
              "folder.updated": {
                "description": "The folder as GET /chat/api/folders lists it now (its counts as the reader may see them), with `by` beside its fields; or, when the folder is gone by the time the event is delivered, {folder_id, deleted: true, by}. `deleted` tells the two apart.",
                "oneOf": [
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/FolderChanged"
                      },
                      {
                        "not": {
                          "required": [
                            "deleted"
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/FolderGone"
                      },
                      {
                        "properties": {
                          "deleted": {
                            "const": true
                          }
                        },
                        "required": [
                          "deleted"
                        ]
                      }
                    ]
                  }
                ]
              },
              "hello": {
                "description": "The feed's first event.",
                "properties": {
                  "cert": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/HelloCert"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The dates of the certificate the device connected with (§5.3); `null`\non a feed that is not a device's."
                  },
                  "cursor": {
                    "description": "Where the stream continues from: the cursor the client resumed with,\nor the newest record when it gave none (or one the feed answers with\n`resync`).",
                    "type": "string"
                  },
                  "dashboard_url": {
                    "description": "Where the dashboard is, for a client that offers to open it: the\nplain listener's address as a URL (`http://127.0.0.1:8001/`), derived\nfrom `bind_addr`. Sent to a device paired as \"this computer\"\n(`local_only`) and to every other device when `bind_addr` is not\nloopback, since a loopback address reaches nothing from another host.\n`null` otherwise, and on a feed that is not a device's.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "epoch": {
                    "description": "This database's epoch.",
                    "type": "string"
                  },
                  "hold": {
                    "$ref": "#/components/schemas/FeedHold"
                  },
                  "hosts_label": {
                    "description": "The label a device may host MCP tools under; `null` without a\nhosting grant, and on a feed that is not a device's.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "keepalive_s": {
                    "description": "Seconds between keep-alive comments, fixed for this stream: the\n`keepalive_s` the request asked for, else the gateway's\n`chat_feed_keepalive_s`. A client derives its dead-link timeout from\nit. Stored events are never held back for it: the stream reads the\ntable at the gateway's own interval whatever this one is.",
                    "format": "uint32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "open_approvals": {
                    "description": "Every call still waiting for a decision at `cursor`, in the\nthreads this reader may see, oldest reply first and each reply's\ncalls in the model's order, as `approval.requested` renders it (the\nthread's title as it was then). Read with the head, so it is the open\nset there: the `approval.*` events of the catch-up up to `caught_up`\nare already reflected in it; after `caught_up`, `approval.requested`\nadds to it and `approval.decided` removes from it, as does the\nthread's deletion or its reply's, and every `state` replaces it\n(`LiveState::open_approvals`). A waiting call is one of the\nthread's last message: a reply a later message followed waits no\nmore (a new message declines its calls).",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequested"
                    },
                    "type": "array"
                  },
                  "principal": {
                    "$ref": "#/components/schemas/FeedPrincipal"
                  },
                  "retention_days": {
                    "description": "How many days the feed keeps its records (`chat_feed_retention_days`,\n`0` = all): a client away longer gets a `resync`.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "self_admin": {
                    "$ref": "#/components/schemas/AdminLevel",
                    "description": "What this device's admin tools may do now: `off`, `read_only` (read\nlmgw's configuration and state) or `full` (also change it) — the\nlevel set on the device, capped by the gateway's own self-admin\nlevel. Above `off` the device sees the threads and folders that\ncarry the self-admin toolset (`lmgw`), and at `full` it may attach it\nand change them; at `read_only` it reads them and sends to them only;\nat `off` it sees none of them. When this value moves above `off` or back while\nthe feed is open, whether the device's level or the gateway's moved\nit, those threads and folders arrive (`*.created`) or go\n(`*.deleted`) in order. A `state` with this value follows any change\nof the device's level, and any change of the gateway's that moves\nthis value. When this value moved above `off` or back within what a\nresumed feed catches up, the feed sends `resync` at that point\ninstead: reload what you show. `off` on a feed that is not a\ndevice's."
                  },
                  "turns": {
                    "description": "The turns running now.",
                    "items": {
                      "$ref": "#/components/schemas/LiveTurn"
                    },
                    "type": "array"
                  },
                  "urls": {
                    "description": "A device's lmgw URLs as its row holds them now: `https` base URLs in\nthe owner's order (device link design §7.2). The device replaces its\nlist with them (`lmgw-client`'s `refresh_urls`). Empty on a feed that\nis not a device's.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "voice": {
                    "description": "The realtime sessions bound now.",
                    "items": {
                      "$ref": "#/components/schemas/LiveVoice"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "epoch",
                  "cursor",
                  "keepalive_s",
                  "retention_days",
                  "principal",
                  "hosts_label",
                  "self_admin",
                  "hold",
                  "voice",
                  "turns",
                  "open_approvals",
                  "urls",
                  "cert",
                  "dashboard_url"
                ],
                "title": "Hello",
                "type": "object"
              },
              "hold": {
                "description": "The GPU hold: whether local models are paused. A held model answers with\nits own fallback, where one is set (each thread's model says which). The\n`hold` event and part of `Hello`.",
                "properties": {
                  "active": {
                    "description": "The owner's GPU hold is on: models on the graphics card are paused.",
                    "type": "boolean"
                  },
                  "benchmark": {
                    "description": "A benchmark run holds the graphics card: every local model waits\nuntil it ends, one on the CPU too, or answers with its fallback\n(chat-plane design D6).",
                    "type": "boolean"
                  }
                },
                "required": [
                  "active",
                  "benchmark"
                ],
                "title": "FeedHold",
                "type": "object"
              },
              "message.added": {
                "description": "`message.added` and `message.updated`: messages of a thread were written\n(client-apps design §2.2). Added: a user message as it is stored (typed,\ndictated or spoken in a bound session), a reply as it is saved, a late\nMCP task result entering the thread (role `tool`). Updated in place: an\nedit, a continue, a resumed turn saved onto its reply, a spoken reply\ncut to what was heard or annotated with how it was spoken, a user\nmessage's retrieval stored, a call the reply waits on decided (or\ndeclined by a new message, or closed as not run). A reply still being\ngenerated is in no event until it is saved: its tokens are the send\nstream's.\n\nRendered at delivery, so a catch-up never replays a stale copy: each\nmessage as `GET /chat/api/threads/{id}` lists it now, whole, so a client\nshows it, or a notification, without a fetch. A message gone by then is\nleft out (its `message.deleted` follows), and an event whose messages\nare all gone, or whose thread is, is not delivered. Two events may carry\nthe same state of a message: apply them by id.",
                "properties": {
                  "by": {
                    "description": "Who wrote them: the sender of a user message, the starter of the\nturn whose reply it is, the client that edited one or decided a call,\nthe client whose voice session cut or annotated a spoken reply (that\nsession's, even after another client took the thread over); `null`\nfor the gateway's own (a task result entering the thread, a call\nclosed as not run).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "messages": {
                    "description": "The messages written, oldest first, each as the thread lists it now.",
                    "items": {
                      "$ref": "#/components/schemas/Message"
                    },
                    "type": "array"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "thread_title": {
                    "description": "The thread's title at delivery, so a notification names the\nconversation without a fetch.",
                    "type": "string"
                  }
                },
                "required": [
                  "thread_id",
                  "thread_title",
                  "messages",
                  "by"
                ],
                "title": "MessagesChanged",
                "type": "object"
              },
              "message.deleted": {
                "description": "`message.deleted`: messages of a thread were deleted (client-apps design\n§2.2): one by itself, every one after a point (an edit's resend, a\nregenerate), or a spoken reply nobody heard. Their attachments went with\nthem. A thread deleted whole says so with `thread.deleted` alone.",
                "properties": {
                  "by": {
                    "description": "Who deleted them; `null` for the gateway's own.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "message_ids": {
                    "description": "The messages that went, ascending.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "message_ids",
                  "by"
                ],
                "title": "MessagesDeleted",
                "type": "object"
              },
              "message.updated": {
                "description": "`message.added` and `message.updated`: messages of a thread were written\n(client-apps design §2.2). Added: a user message as it is stored (typed,\ndictated or spoken in a bound session), a reply as it is saved, a late\nMCP task result entering the thread (role `tool`). Updated in place: an\nedit, a continue, a resumed turn saved onto its reply, a spoken reply\ncut to what was heard or annotated with how it was spoken, a user\nmessage's retrieval stored, a call the reply waits on decided (or\ndeclined by a new message, or closed as not run). A reply still being\ngenerated is in no event until it is saved: its tokens are the send\nstream's.\n\nRendered at delivery, so a catch-up never replays a stale copy: each\nmessage as `GET /chat/api/threads/{id}` lists it now, whole, so a client\nshows it, or a notification, without a fetch. A message gone by then is\nleft out (its `message.deleted` follows), and an event whose messages\nare all gone, or whose thread is, is not delivered. Two events may carry\nthe same state of a message: apply them by id.",
                "properties": {
                  "by": {
                    "description": "Who wrote them: the sender of a user message, the starter of the\nturn whose reply it is, the client that edited one or decided a call,\nthe client whose voice session cut or annotated a spoken reply (that\nsession's, even after another client took the thread over); `null`\nfor the gateway's own (a task result entering the thread, a call\nclosed as not run).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "messages": {
                    "description": "The messages written, oldest first, each as the thread lists it now.",
                    "items": {
                      "$ref": "#/components/schemas/Message"
                    },
                    "type": "array"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "thread_title": {
                    "description": "The thread's title at delivery, so a notification names the\nconversation without a fetch.",
                    "type": "string"
                  }
                },
                "required": [
                  "thread_id",
                  "thread_title",
                  "messages",
                  "by"
                ],
                "title": "MessagesChanged",
                "type": "object"
              },
              "profile.created": {
                "description": "`profile.created`, `profile.updated` and `profile.deleted`: a\npersonality profile (`GET /chat/api/profiles`) was created, changed or\ndeleted, named as that write left it. Every reader receives them,\ndevices included. After a `resync` the feed sends the whole list again\nas `profile.created` events (with no `id:`), so a client that keeps the\nnames (a menu of profiles) has them again without a request.",
                "properties": {
                  "by": {
                    "description": "Who made the change; `null` for the gateway's own, and on the list\nrepeated after a `resync`.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "description": "The profile's id.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "by"
                ],
                "title": "FeedProfile",
                "type": "object"
              },
              "profile.deleted": {
                "description": "`profile.created`, `profile.updated` and `profile.deleted`: a\npersonality profile (`GET /chat/api/profiles`) was created, changed or\ndeleted, named as that write left it. Every reader receives them,\ndevices included. After a `resync` the feed sends the whole list again\nas `profile.created` events (with no `id:`), so a client that keeps the\nnames (a menu of profiles) has them again without a request.",
                "properties": {
                  "by": {
                    "description": "Who made the change; `null` for the gateway's own, and on the list\nrepeated after a `resync`.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "description": "The profile's id.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "by"
                ],
                "title": "FeedProfile",
                "type": "object"
              },
              "profile.updated": {
                "description": "`profile.created`, `profile.updated` and `profile.deleted`: a\npersonality profile (`GET /chat/api/profiles`) was created, changed or\ndeleted, named as that write left it. Every reader receives them,\ndevices included. After a `resync` the feed sends the whole list again\nas `profile.created` events (with no `id:`), so a client that keeps the\nnames (a menu of profiles) has them again without a request.",
                "properties": {
                  "by": {
                    "description": "Who made the change; `null` for the gateway's own, and on the list\nrepeated after a `resync`.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "description": "The profile's id.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "by"
                ],
                "title": "FeedProfile",
                "type": "object"
              },
              "resync": {
                "description": "`resync`: the cursor cannot be honoured; reload what you show. The\nstream continues from now.",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "Resync",
                "type": "object"
              },
              "revoked": {
                "description": "`revoked`: the key was disabled, rotated, deleted or expired; the stream\nends after it.",
                "properties": {
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about it, the token a realtime session's 4003\nclose starts its reason with: `key_unknown` means pair the device\nagain. Every event this gateway sends carries it. An event without it\n(an older gateway's) is of an unknown kind, as a close reason without\na token is: tell the user the sentence in `message`."
                  },
                  "message": {
                    "description": "The reason in a sentence: \"device 'phone' was rotated — pair it\nagain\".",
                    "type": "string"
                  },
                  "reason": {
                    "description": "`disabled`, `rotated`, `deleted` or `expired`.",
                    "type": "string"
                  }
                },
                "required": [
                  "reason",
                  "message",
                  "kind"
                ],
                "title": "Revoked",
                "type": "object"
              },
              "state": {
                "description": "`state`: `Hello`'s live part again. Sent when the stream could not\nkeep a client's live events in order — it read slower than they\nhappened past `chat_feed_live_buffer`, or the buffer was resized — and\nto a device when what it may see or do changed: a thread it reaches took\nor lost the self-admin toolset, its own admin-tools level moved, or the\ngateway's self-admin level moved what its admin tools may do. Also after\na `resync` that passed records (the retention pruned past a stream still\ncatching up, which gets it before `caught_up`; a change that could not be\nread, after `caught_up`), and to a device after a thread or folder came\ninto its reach after `caught_up` (its `*.created`), so the open\napprovals in it arrive.\nStored events are never lost; `reason` says what happened and names the\nsetting.",
                "properties": {
                  "hold": {
                    "$ref": "#/components/schemas/FeedHold"
                  },
                  "open_approvals": {
                    "description": "The calls waiting for a decision as they are when this `state` is\nsent, in the threads this reader may see now, as\n`Hello::open_approvals` lists them: they replace the set a client\nkeeps. Read at sending, which may be a little past the stream's\ncursor: match by `approval_request_id`, and an `approval.*` event\nthat follows changes nothing it already says. `null` when lmgw\ncould not read them for a `state` sent for another reason (a lag, a\nresize, a refresh of what is live; said in its log): keep the set\nyou have. A `state` sent because the set may have moved never says\n`null`: lmgw ends the stream instead, and the reconnect's `hello`\ncarries the set.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequested"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "self_admin": {
                    "$ref": "#/components/schemas/AdminLevel",
                    "description": "`Hello::self_admin` as it is now: a device learns here that what\nits admin tools may do moved while the feed is open."
                  },
                  "turns": {
                    "items": {
                      "$ref": "#/components/schemas/LiveTurn"
                    },
                    "type": "array"
                  },
                  "voice": {
                    "items": {
                      "$ref": "#/components/schemas/LiveVoice"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "self_admin",
                  "hold",
                  "voice",
                  "turns",
                  "reason",
                  "open_approvals"
                ],
                "title": "LiveState",
                "type": "object"
              },
              "task.done": {
                "description": "`task.done`: a task's result entered the thread as message `message_id`\n(role `tool`). `by` names who cancelled it, for a cancel lmgw sent;\n`null` otherwise.",
                "properties": {
                  "by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "message_id": {
                    "description": "The result row.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "server_label": {
                    "type": "string"
                  },
                  "status": {
                    "description": "`completed`, `failed`, `cancelled` or `abandoned`.",
                    "enum": [
                      "completed",
                      "failed",
                      "cancelled",
                      "abandoned"
                    ],
                    "type": "string"
                  },
                  "task_id": {
                    "type": "string"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "tool": {
                    "type": "string"
                  }
                },
                "required": [
                  "thread_id",
                  "message_id",
                  "id",
                  "task_id",
                  "server_label",
                  "tool",
                  "status",
                  "by"
                ],
                "title": "TaskDone",
                "type": "object"
              },
              "task.started": {
                "description": "`task.started`: a tool call of a turn in the thread became an MCP task\n(MCP Tasks design §4.1); its result enters the thread later. Named as\nthe write left it, so it renders after the task is gone.",
                "properties": {
                  "by": {
                    "description": "Who started the turn that called it.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "description": "lmgw's id of the task (the cancel route's `{task}`).",
                    "format": "int64",
                    "type": "integer"
                  },
                  "server_label": {
                    "type": "string"
                  },
                  "task_id": {
                    "description": "The server's id of the task.",
                    "type": "string"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "tool": {
                    "description": "The name the model called.",
                    "type": "string"
                  }
                },
                "required": [
                  "thread_id",
                  "id",
                  "task_id",
                  "server_label",
                  "tool",
                  "by"
                ],
                "title": "TaskStarted",
                "type": "object"
              },
              "thread.created": {
                "description": "The thread as GET /chat/api/threads lists it now, with `by` beside its fields; or, when the thread is gone by the time the event is delivered, {thread_id, deleted: true, by}. `deleted` tells the two apart.",
                "oneOf": [
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/ThreadChanged"
                      },
                      {
                        "not": {
                          "required": [
                            "deleted"
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/ThreadGone"
                      },
                      {
                        "properties": {
                          "deleted": {
                            "const": true
                          }
                        },
                        "required": [
                          "deleted"
                        ]
                      }
                    ]
                  }
                ]
              },
              "thread.deleted": {
                "description": "`thread.deleted`, and `thread.created` / `thread.updated` for a thread\nthat is gone by the time the event is delivered.",
                "properties": {
                  "by": {
                    "description": "Who made the change; `null` for the gateway's own (the sweep).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "deleted": {
                    "type": "boolean"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "deleted",
                  "by"
                ],
                "title": "ThreadGone",
                "type": "object"
              },
              "thread.updated": {
                "description": "The thread as GET /chat/api/threads lists it now, with `by` beside its fields; or, when the thread is gone by the time the event is delivered, {thread_id, deleted: true, by}. `deleted` tells the two apart.",
                "oneOf": [
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/ThreadChanged"
                      },
                      {
                        "not": {
                          "required": [
                            "deleted"
                          ]
                        }
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/ThreadGone"
                      },
                      {
                        "properties": {
                          "deleted": {
                            "const": true
                          }
                        },
                        "required": [
                          "deleted"
                        ]
                      }
                    ]
                  }
                ]
              },
              "transfer.updated": {
                "description": "A transfer, as every route and `transfer.updated` answer it.",
                "properties": {
                  "app_id": {
                    "description": "The app id the offer names; the receiver declared it at pairing.",
                    "type": "string"
                  },
                  "created_at": {
                    "description": "RFC 3339 UTC.",
                    "type": "string"
                  },
                  "end_reason": {
                    "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "ended_at": {
                    "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "expires_at": {
                    "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                    "type": "string"
                  },
                  "filename": {
                    "description": "The receiver's name for the file.",
                    "type": "string"
                  },
                  "from": {
                    "$ref": "#/components/schemas/TransferParty"
                  },
                  "id": {
                    "description": "Opaque: 32 random lowercase hex digits.",
                    "type": "string"
                  },
                  "kind": {
                    "description": "The app's own word for what the file is.",
                    "type": "string"
                  },
                  "received": {
                    "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "sha256": {
                    "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                    "type": "string"
                  },
                  "size": {
                    "description": "The file's size in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "state": {
                    "$ref": "#/components/schemas/TransferState"
                  },
                  "title": {
                    "description": "What the card and the receiver show; may be empty.",
                    "type": "string"
                  },
                  "to": {
                    "$ref": "#/components/schemas/TransferParty"
                  }
                },
                "required": [
                  "id",
                  "app_id",
                  "kind",
                  "title",
                  "filename",
                  "size",
                  "sha256",
                  "from",
                  "to",
                  "state",
                  "received",
                  "created_at",
                  "expires_at",
                  "ended_at",
                  "end_reason"
                ],
                "title": "Transfer",
                "type": "object"
              },
              "turn.done": {
                "description": "`turn.done`: how a turn ended.",
                "properties": {
                  "code": {
                    "description": "The code of the last error the turn reported (`superseded`,\n`gpu_hold`, `not_saved`, …); `null` when it reported none.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "message_id": {
                    "description": "The reply row it saved or continued; `null` when it saved none.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "saved": {
                    "type": "boolean"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "message_id",
                  "saved",
                  "code"
                ],
                "title": "TurnDone",
                "type": "object"
              },
              "turn.started": {
                "description": "`turn.started`.",
                "properties": {
                  "by": {
                    "type": "string"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "voice": {
                    "description": "A bound realtime session's voice turn.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "thread_id",
                  "by",
                  "voice"
                ],
                "title": "TurnStarted",
                "type": "object"
              },
              "voice.bound": {
                "description": "`voice.bound`: a realtime session bound to the thread.",
                "properties": {
                  "by": {
                    "type": "string"
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "by"
                ],
                "title": "VoiceBound",
                "type": "object"
              },
              "voice.ended": {
                "description": "`voice.ended`: a bound session let its thread go.",
                "properties": {
                  "by": {
                    "description": "Who had bound the session that ended.",
                    "type": "string"
                  },
                  "reason": {
                    "description": "`closed`, `taken_over`, `thread_gone` (its thread was deleted while\nit was bound; a device's feed does not receive this event for a\ndeleted thread, only its `thread.deleted`, as for a thread taken out\nof its reach) or `revoked` (the binder's key was revoked, or the\nthread was taken out of the binding device's reach).",
                    "type": "string"
                  },
                  "taken_over_by": {
                    "description": "Who took it over, for `taken_over`.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "thread_id": {
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "thread_id",
                  "by",
                  "reason",
                  "taken_over_by"
                ],
                "title": "VoiceEnded",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Follow the Chat's changes",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/folders": {
      "get": {
        "description": "Every folder in the list's order: its defaults (what a new thread in it starts with), whether it is one ongoing conversation and which thread is current, its own retention, and its thread counts as the caller may see them. Folder names need not be unique, so a client that looks its folder up by name keeps the id it found.",
        "operationId": "get_chat_api_folders",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/folders`.",
                  "properties": {
                    "folders": {
                      "description": "In the list's order.",
                      "items": {
                        "$ref": "#/components/schemas/Folder"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "folders"
                  ],
                  "title": "FolderList",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List the Chat's folders",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "A new folder, last in the list, answered as the list carries it. `ongoing` marks it as one ongoing conversation, which needs a model in its defaults: without one the answer is a 400 naming defaults.model_alias. A device key writes only within its own scopes: a tool server or knowledge base its tool scope does not reach is a 403 tool_label_out_of_scope, an alias outside its alias scope a 403 key_scope, and the self-admin toolset (lmgw) is its to attach only when its admin tools are full: below that the answer is a 403 chat_toolset_needs_full, or tool_label_out_of_scope when they are off. A device key only tightens require_approval: a rule that gates fewer calls than the stored one or the owner's last (its floor, which a removed entry keeps) is a 403 approval_loosen_refused, naming the label and the tool; a turn runs each server under the strictest of its entries and that floor. For every caller, two mcp_tools entries that name one server (its tool prefix and its name) or a require_approval of another shape than OpenAI's are a 400 bad_request where the write changed the entry; labels are stored trimmed. A device key cannot set archive_days or purge_days (403 forbidden, naming the fields): a folder's own retention is set from the dashboard.",
        "operationId": "post_chat_api_folders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/folders`'s body.",
                "properties": {
                  "archive_days": {
                    "description": "Days without activity before one of its threads is archived; absent\nfor the Chat's setting, `0` never. A device key cannot set it (403\nforbidden): a folder's own retention is set from the dashboard.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "defaults": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/ThreadDefaultsInput"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "ongoing": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/OngoingInput"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Marks the folder as one ongoing conversation; its defaults must then\nname a model."
                  },
                  "purge_days": {
                    "description": "Days after archiving before one of its threads is deleted; absent\nfor the Chat's setting, `0` never. A device key cannot set it, as\n`archive_days`.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "name"
                ],
                "title": "FolderCreate",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A Chat folder as `GET /chat/api/folders` lists it, with its thread\ncounts as the caller may see them.",
                  "properties": {
                    "archive_days": {
                      "description": "Days without activity before one of its threads is archived; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "defaults": {
                      "$ref": "#/components/schemas/ThreadDefaults"
                    },
                    "devices_hidden": {
                      "description": "Set when a device deleted this folder while it held threads that\ndevice could not see: the folder stays for them, hidden from every\ndevice, until it is shown to devices again from the dashboard. Always\n`false` for a device key, which never sees such a folder.",
                      "type": "boolean"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "name": {
                      "description": "Folder names need not be unique.",
                      "type": "string"
                    },
                    "ongoing": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/FolderOngoing"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`null` for a folder that is not one ongoing conversation."
                    },
                    "purge_days": {
                      "description": "Days after archiving before one of its threads is deleted; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "sort": {
                      "description": "The folder's place in the list.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "threads_active": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "threads_archived": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "sort",
                    "defaults",
                    "ongoing",
                    "archive_days",
                    "purge_days",
                    "devices_hidden",
                    "created_at",
                    "updated_at",
                    "threads_active",
                    "threads_archived"
                  ],
                  "title": "Folder",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Create a folder",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/folders/{id}": {
      "post": {
        "description": "A patch: a field left out is unchanged. Answers the folder as the list carries it, with `applied`: for an ongoing-conversation folder whose defaults changed (and apply_to_current not false), the current thread and the settings that reached it, otherwise null. The folder's other threads are never touched. defaults replaces the defaults whole; defaults_patch changes the fields it names (null unsets one) so a client never writes back what another changed meanwhile; both together are a 400 bad_request. ongoing needs a model in the defaults. What reaches the current thread passes the checks of a thread settings write, and a field the thread refuses fails the whole patch. A device key's default mcp_tools pass its tool scope, as on a folder create; it cannot set archive_days or purge_days, nor devices_hidden (403 forbidden). devices_hidden: false shows a folder to devices again that a device's delete hid from them; true is a 400. A folder the caller cannot see is a 404 not_found.",
        "operationId": "post_chat_api_folders_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/folders/{id}`'s body: a **patch**. An absent field is\nunchanged. Unknown fields are a 422 bad_request.",
                "properties": {
                  "apply_to_current": {
                    "description": "For an ongoing folder: also apply the defaults' changes to its\ncurrent thread. Default `true`.",
                    "type": "boolean"
                  },
                  "archive_days": {
                    "description": "The folder's own retention in days before an inactive thread is\narchived; `null` goes back to the Chat's setting, `0` never. A device\nkey cannot set it (403 `forbidden`).",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "defaults": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/ThreadDefaultsInput"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Replaces the folder's defaults whole (`{}` clears them). Not beside\n`defaults_patch`."
                  },
                  "defaults_patch": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/ThreadDefaultsInput"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Changes the defaults field by field instead: each field given\nreplaces the stored one (`null` unsets it), the others stay as\nstored, so a save of the fields one client changed never writes back\nwhat another changed meanwhile. `voice` is laid field by field the\nsame way (`voice: null` unsets the whole voice). Not beside\n`defaults`."
                  },
                  "devices_hidden": {
                    "description": "`false` shows a folder that a device's delete hid from devices to\nthem again; the owner's alone. `true` is refused (400): a device's\ndelete is what hides a folder.",
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "name": {
                    "description": "The new name; names need not be unique.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "ongoing": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/OngoingInput"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "An object marks the folder as one ongoing conversation (or changes\nits idle minutes; its defaults must name a model); `null` ends that."
                  },
                  "purge_days": {
                    "description": "Days after archiving before a thread is deleted; as `archive_days`.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "sort": {
                    "description": "The folder's place in the list.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "title": "FolderPatch",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/folders/{id}`'s answer: the folder as the list carries\nit, and what the patch applied to its current thread.",
                  "properties": {
                    "applied": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AppliedToCurrent"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "For an ongoing folder whose defaults changed: the current thread\nand the settings that reached it; `null` otherwise."
                    },
                    "archive_days": {
                      "description": "Days without activity before one of its threads is archived; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "defaults": {
                      "$ref": "#/components/schemas/ThreadDefaults"
                    },
                    "devices_hidden": {
                      "description": "Set when a device deleted this folder while it held threads that\ndevice could not see: the folder stays for them, hidden from every\ndevice, until it is shown to devices again from the dashboard. Always\n`false` for a device key, which never sees such a folder.",
                      "type": "boolean"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "name": {
                      "description": "Folder names need not be unique.",
                      "type": "string"
                    },
                    "ongoing": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/FolderOngoing"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`null` for a folder that is not one ongoing conversation."
                    },
                    "purge_days": {
                      "description": "Days after archiving before one of its threads is deleted; `null`\nfor the Chat's setting, `0` never. Set from the dashboard: a device\nkey cannot change it.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "sort": {
                      "description": "The folder's place in the list.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "threads_active": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "threads_archived": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "sort",
                    "defaults",
                    "ongoing",
                    "archive_days",
                    "purge_days",
                    "devices_hidden",
                    "created_at",
                    "updated_at",
                    "threads_active",
                    "threads_archived",
                    "applied"
                  ],
                  "title": "FolderPatched",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Change a folder",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/folders/{id}/current": {
      "post": {
        "description": "The thread every client of an ongoing-conversation folder continues in. A new one starts when the folder has none the caller can reach (first), when no message came for the folder's idle minutes while no turn runs there (idle), or on new: true (requested) — except that a current thread with no message yet is answered instead, so no empty threads pile up. The body may be left out: it is new: false. A new thread starts from the folder's defaults, and every client hears of it as the feed's folder.current. Two clients asking at once get the same thread. A folder that is not an ongoing conversation is a 409 not_ongoing, one whose defaults name no model a 409 folder_no_model, and one the caller may not see a 404.",
        "operationId": "post_chat_api_folders_id_current",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/folders/{id}/current`'s body.",
                "properties": {
                  "new": {
                    "default": false,
                    "description": "Start a new thread now. A current thread without any message is\nanswered instead, so no empty threads pile up.",
                    "type": "boolean"
                  }
                },
                "title": "CurrentRequest",
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/folders/{id}/current`'s answer.",
                  "properties": {
                    "note": {
                      "description": "The same in a sentence that names the folder setting behind it (the\nidle minutes, for `idle`); `null` when this call did not start it.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/CurrentReason"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why this call started it; `null` when it did not."
                    },
                    "rolled_over": {
                      "description": "Whether this call started it.",
                      "type": "boolean"
                    },
                    "thread": {
                      "$ref": "#/components/schemas/Thread",
                      "description": "The current thread, as `GET /chat/api/threads/{id}` answers its\n`thread`."
                    }
                  },
                  "required": [
                    "thread",
                    "rolled_over",
                    "reason",
                    "note"
                  ],
                  "title": "CurrentThread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Get an ongoing conversation's current thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/folders/{id}/delete": {
      "post": {
        "description": "threads: keep leaves the folder's threads in no folder, threads: delete deletes them with it; there is no default for destroying conversations. A device key's delete touches only the threads it can see: a folder that also holds Admin Chat or self-admin threads it cannot reach stays for them, hidden from every device from then on, and the answer is the same ok. A folder the caller cannot see is a 404 not_found.",
        "operationId": "post_chat_api_folders_id_delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/folders/{id}/delete`'s body. The choice is required:\nthere is no default for destroying conversations.",
                "properties": {
                  "threads": {
                    "$ref": "#/components/schemas/ThreadsFate"
                  }
                },
                "required": [
                  "threads"
                ],
                "title": "FolderDelete",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer of a write that has nothing to report but that it\nhappened: `{\"ok\": true}`.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`; a failure is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "Ack",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Delete a folder",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/folders/{id}/export": {
      "get": {
        "description": "A zip with one file per stored thread of the folder, in the format asked for (md or json, as for one thread), and a README.txt. archived=0 takes the active threads, 1 the archived ones, all (the default) both; another value is a 400 bad_request, as is a format other than md, markdown or json. The answer carries Content-Disposition: attachment (lmgw-folder-{name}-{date}.zip), Content-Length and Cache-Control: no-store; it is as large as the folder is and not capped. Temporary threads are not part of a zip. A device key's zip leaves out Admin Chat threads; a folder that is not there, or not the caller's to see, is a 404 not_found.",
        "operationId": "get_chat_api_folders_id_export",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "archived",
            "required": false,
            "schema": {
              "default": "",
              "description": "Zips only: `0` active threads, `1` archived threads only, `all`\n(default) both.",
              "enum": [
                "0",
                "1",
                "all"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "default": "",
              "description": "`md` (default; `markdown` is accepted too) for a readable\ntranscript, `json` for the lossless `lmgw.chat.v1` file. A zip holds\none file of this format per thread.",
              "enum": [
                "md",
                "markdown",
                "json"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/zip": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Export a folder",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/knowledge/bases": {
      "get": {
        "description": "Every knowledge base with its file counts and whether its embedding model still resolves (without one a search is by keyword only), for a thread's Knowledge section and the composer's # picker. A thread's bases are its own choice, so a base's MCP visibility does not narrow the list. A device key reads the bases only with kb__search within its tool scope, the tool a thread's base is searched with: without it the answer is 403 tool_label_out_of_scope, naming the tool and no base.",
        "operationId": "get_chat_api_knowledge_bases",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/knowledge/bases`: the knowledge bases a thread may\nsearch, for the Chat's Knowledge section, its `#` picker and its chips.",
                  "properties": {
                    "bases": {
                      "items": {
                        "$ref": "#/components/schemas/ChatKnowledgeBase"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "bases"
                  ],
                  "title": "ChatKnowledgeBases",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List the knowledge bases a thread may search",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/knowledge/files/{id}/original": {
      "get": {
        "description": "The uploaded bytes, with the media type they were sniffed as and Content-Disposition: attachment under the file's name (an ASCII fallback plus the RFC 5987 filename*). The owner's: a device key is refused (403 forbidden, said before the file is looked up), since the original carries more than any kb tool hands out; it reads the extracted text. 404 not_found for a file that does not exist or whose original is gone from disk.",
        "operationId": "get_chat_api_knowledge_files_id_original",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Download a knowledge file's original",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/knowledge/files/{id}/text": {
      "get": {
        "description": "The source viewer a citation opens: the file's extracted text (null until it has been ingested once), every chunk's byte range in it, and the chunk named by `chunk` as `highlight`; a citation whose chunk id a re-ingest renamed is found again by its stored span_start, span_end and sha, and `notice` says so. The file is described by what the viewer shows (name, kind, status, pages), without its ingest record; `original` says whether the caller may download the original. A device key reads it only with kb__search and kb__read within its tool scope and kb__read switched on by the owner (403 tool_label_out_of_scope otherwise, said before the file is looked up). 400 op_failed for a file that does not exist.",
        "operationId": "get_chat_api_knowledge_files_id_text",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "chunk",
            "required": false,
            "schema": {
              "default": null,
              "description": "The chunk to highlight (a citation's chunk id).",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "sha",
            "required": false,
            "schema": {
              "default": null,
              "description": "... and the file's sha256 when it was cited.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "span_end",
            "required": false,
            "schema": {
              "default": null,
              "description": "... its end ...",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "span_start",
            "required": false,
            "schema": {
              "default": null,
              "description": "What a citation stored besides the chunk id, for one whose chunk id a\nre-ingest renamed: the passage's start (byte offset into the text) ...",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/knowledge/files/{id}/text`: a cited file's extracted text,\nas the Chat's source viewer shows it. The Knowledge page's own answer\n(`KnowledgeSource`) also carries the file's ingest record — its error,\nits notes, its size and digest — which can name the models and upstreams\nthat ingested it; the Chat's carries what the viewer shows.",
                  "properties": {
                    "chunks": {
                      "description": "Every chunk's span, in file order.",
                      "items": {
                        "$ref": "#/components/schemas/ChunkSpan"
                      },
                      "type": "array"
                    },
                    "file": {
                      "$ref": "#/components/schemas/ChatKnowledgeFile"
                    },
                    "highlight": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/ChunkSpan"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The cited chunk (or the one found by the citation's position)."
                    },
                    "kb_name": {
                      "description": "The base the file is in.",
                      "type": "string"
                    },
                    "notice": {
                      "description": "Said when the highlight is not the cited chunk itself: it was found by\nthe citation's stored position because the chunk id no longer exists.",
                      "type": "string"
                    },
                    "original": {
                      "description": "Whether this caller may download the file's original\n(`GET /chat/api/knowledge/files/{id}/original`): the owner may, a\ndevice key not yet.",
                      "type": "boolean"
                    },
                    "text": {
                      "description": "The extracted text; `null` until the file has been ingested once.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "file",
                    "kb_name",
                    "text",
                    "chunks",
                    "highlight",
                    "original"
                  ],
                  "title": "ChatKnowledgeSource",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read a knowledge file's extracted text",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/media/defaults": {
      "get": {
        "description": "Which model image__generate, image__edit, audio__speak and audio__transcribe use when a call leaves out `model`, and the voice audio__speak uses when it leaves out `voice`. Three levels, the narrowest that says something winning: a thread's own (its settings' media_defaults), its folder's (the folder defaults' media_defaults, read at each turn rather than copied), Settings → Chat's (chat_media_defaults). In a thread or a folder an absent field inherits and an empty one is no default. The answer has Settings' always, ?folder=<id> adds a folder's and ?thread=<id> a thread's and its folder's; `inherited` is what the narrowest level asked takes from above it, `resolved` what a call uses now, and `choices` every model each tool's `model` enum offers this caller (a device key's alias scope narrows it), with a label and each speech row's voices. A stored default that no longer resolves — its model switched off or deleted, an alias that lost the route, a model outside the caller's key scope, a voice its model does not have — is listed under `unavailable` with the reason and is no default: the tool requires `model` again, and no other model is put in its place. A folder or thread the caller does not reach is 404 not_found.",
        "operationId": "get_chat_api_media_defaults",
        "parameters": [
          {
            "in": "query",
            "name": "folder",
            "required": false,
            "schema": {
              "default": null,
              "description": "A folder: its own defaults, and what it inherits from Settings.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "thread",
            "required": false,
            "schema": {
              "default": null,
              "description": "A thread: its own, its folder's (when it is in one), and what it\ninherits. Wins over `folder`.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/media/defaults`: the media tools' defaults at each level\nasked for, what they resolve to, and what the pickers offer.",
                  "properties": {
                    "choices": {
                      "$ref": "#/components/schemas/MediaChoices",
                      "description": "What each tool can use, for the caller."
                    },
                    "folder": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/MediaDefaults"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The folder's own, when a folder (or a thread in one) was asked for."
                    },
                    "inherited": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "What the narrowest level asked for takes from the levels above it,\nas stored there (a name that no longer resolves included; see\n`unavailable`). For Settings itself, nothing."
                    },
                    "resolved": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "What a call that leaves the argument out uses now at the narrowest\nlevel asked for: a field absent here has no default, and the tool\nrequires the argument."
                    },
                    "settings": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "Settings → Chat's defaults, as stored."
                    },
                    "thread": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/MediaDefaults"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The thread's own, when a thread was asked for."
                    },
                    "unavailable": {
                      "description": "Every stored name in the levels above that does not resolve, with\nthe reason. Never replaced by another model: it is no default until\nit is picked again or the model comes back.",
                      "items": {
                        "$ref": "#/components/schemas/MediaUnavailable"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "choices",
                    "settings",
                    "inherited",
                    "resolved",
                    "unavailable"
                  ],
                  "title": "MediaDefaultsView",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "The image and audio tools' default models",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/profiles": {
      "get": {
        "description": "Every personality profile in name order — how a thread's model talks, in text and in voice: a persona, a length rule, example exchanges, the voice turn's block, reasoning on or off, and the speech voice — each with used_by (the threads and folders that use it, as far as the caller may see them), and default_profile_id, the profile new threads start with (null: none). \"Default\" is no profile: a thread with profile_id null. A thread picks one with its settings' profile_id, a folder with its defaults' profile_id. The feed's profile.created, profile.updated and profile.deleted keep this list current.",
        "operationId": "get_chat_api_profiles",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/profiles`.",
                  "properties": {
                    "default_profile_id": {
                      "description": "The profile new threads start with (Settings → Chat), `null` for\nnone.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "profiles": {
                      "description": "In name order.",
                      "items": {
                        "$ref": "#/components/schemas/Profile"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "profiles",
                    "default_profile_id"
                  ],
                  "title": "ProfileList",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List the personality profiles",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "A new profile from a name and any content fields (an absent one is unset), answered as the list carries it; or {builtin: \"concise\"} alone, which creates that built-in profile again after it was deleted (409 profile_builtin_exists while it exists). A name is unique in any case (409 profile_name_taken) and never \"default\" (400 profile_name_reserved). An example's sides must not be empty. No length or count is bounded; the request's body limit is. A voice.tts_alias must name a text-to-speech model. A device key may list, create, change, reset and delete profiles; a voice.tts_alias it writes must be within its alias scope (403 key_scope), unless the profile already had it. A profile that Admin Chat or the self-admin toolset uses (a thread, or a folder's defaults) is changed, reset or deleted by a device only while the device may use lmgw's admin tools with writes, its own level and the gateway's (403 profile_in_admin_use, which counts the use and names no thread).",
        "operationId": "post_chat_api_profiles",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/profiles`'s body: a `name` with any content fields (an\nabsent one is unset), or a `builtin` key alone to create that built-in\nprofile again after it was deleted (`409` while it exists).",
                "properties": {
                  "builtin": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "examples": {
                    "default": [],
                    "items": {
                      "$ref": "#/components/schemas/Example"
                    },
                    "type": "array"
                  },
                  "length_rule": {
                    "default": "",
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "persona": {
                    "default": "",
                    "type": "string"
                  },
                  "reasoning": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reasoning"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "default": null
                  },
                  "voice": {
                    "$ref": "#/components/schemas/ProfileVoiceInput",
                    "default": {
                      "speech_style": null,
                      "tts_alias": null,
                      "voice": null
                    }
                  },
                  "voice_block": {
                    "default": null,
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "title": "ProfileCreate",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A profile as `GET /chat/api/profiles` lists it.",
                  "properties": {
                    "builtin": {
                      "description": "The built-in profile this row is (`concise`); `null` for one of the\nowner's own. Read only.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "examples": {
                      "description": "Static example exchanges, in order.",
                      "items": {
                        "$ref": "#/components/schemas/Example"
                      },
                      "type": "array"
                    },
                    "follows_builtin": {
                      "description": "The fields a built-in row takes from the built-in text, so they\nfollow its improvements. Read only.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "length_rule": {
                      "description": "How long replies are; empty for none.",
                      "type": "string"
                    },
                    "name": {
                      "description": "Unique in any case; never `default`.",
                      "type": "string"
                    },
                    "persona": {
                      "description": "Who the model is and how it sounds; empty for none. When set, it\ntakes the thread's system prompt's place.",
                      "type": "string"
                    },
                    "reasoning": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Reasoning"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reasoning on or off; `null` inherits."
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "used_by": {
                      "$ref": "#/components/schemas/UsedBy"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ProfileVoice"
                    },
                    "voice_block": {
                      "description": "The voice turn's block: `null` for the generic one, `\"\"` for none, a\ntext to use as it is.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "builtin",
                    "persona",
                    "length_rule",
                    "examples",
                    "voice_block",
                    "reasoning",
                    "voice",
                    "follows_builtin",
                    "used_by",
                    "created_at",
                    "updated_at"
                  ],
                  "title": "Profile",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Create a personality profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/preview": {
      "post": {
        "description": "The system messages an unsaved draft assembles to, as a send builds them: the static part (persona or thread prompt, length rule, examples), a text turn's and a voice turn's (with the voice block, the language and the tag hint of the text-to-speech model the draft resolves to). thread_id assembles as that thread would, the draft in place of its own profile; without it, an empty chat thread with Settings' defaults. With model, the three are counted on that alias through the universal token counter (as POST /v1/count_tokens counts), with its approximation flags; counting on a local model loads it. Nothing is stored. A draft is checked as a create's content is (an example's empty side is 400 bad_request).",
        "operationId": "post_chat_api_profiles_preview",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/profiles/preview`'s body.",
                "properties": {
                  "model": {
                    "default": null,
                    "description": "Count the tokens on this alias; absent: no count.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "profile": {
                    "$ref": "#/components/schemas/ProfileDraft",
                    "default": {
                      "examples": [],
                      "length_rule": "",
                      "persona": "",
                      "reasoning": null,
                      "voice": {
                        "speech_style": null,
                        "tts_alias": null,
                        "voice": null
                      },
                      "voice_block": null
                    }
                  },
                  "thread_id": {
                    "default": null,
                    "description": "Assemble as this thread would, with the draft in place of its own\nprofile; absent: an empty thread with Settings' defaults.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "title": "PreviewRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/profiles/preview`'s answer: the system messages the\ndraft assembles to.",
                  "properties": {
                    "static": {
                      "description": "The part that does not depend on the turn: persona or thread prompt,\nlength rule, examples.",
                      "type": "string"
                    },
                    "text_turn": {
                      "type": "string"
                    },
                    "tokens": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/PreviewTokens"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "voice_turn": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "static",
                    "text_turn",
                    "voice_turn",
                    "tokens"
                  ],
                  "title": "PreviewAnswer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Preview an unsaved profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/speak": {
      "post": {
        "description": "Says text with the voice the draft resolves to (its text-to-speech model, voice and speech style, after the thread's own, before the Chat's settings), through the read-aloud's pipeline, and answers one WAV (PCM16 mono, 24 kHz). Refused before any audio as the Chat's read-aloud refuses, in flat JSON: tts_not_configured, voice_not_found, voice_not_configured, instructions_required; a voice that fails while it speaks is 502 with its code. It writes one text-to-speech row; a thread's seed is used, none is drawn into it.",
        "operationId": "post_chat_api_profiles_speak",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/profiles/speak`'s body: the text spoken with the draft's\nvoice, answered as one WAV.",
                "properties": {
                  "profile": {
                    "$ref": "#/components/schemas/ProfileDraft",
                    "default": {
                      "examples": [],
                      "length_rule": "",
                      "persona": "",
                      "reasoning": null,
                      "voice": {
                        "speech_style": null,
                        "tts_alias": null,
                        "voice": null
                      },
                      "voice_block": null
                    }
                  },
                  "text": {
                    "default": "",
                    "type": "string"
                  },
                  "thread_id": {
                    "default": null,
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "title": "SpeakRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "audio/wav": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Speak a sample with an unsaved profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/test": {
      "post": {
        "description": "One model call on model with the system message the draft assembles to (a text turn's, or with voice: true a voice turn's) and text as the user's message: no history, no max_tokens, no tools. The answer carries the system message sent, the reply, its reasoning, the reasoning note, the usage, first_token_ms and reasoning_ms, total_ms, and answered_by when a fallback answered. It writes the call's request row (a device's call is its key's) and stores nothing else. The model's refusals answer with their status and code.",
        "operationId": "post_chat_api_profiles_test",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/profiles/test`'s body: one model call with the draft,\nstoring nothing.",
                "properties": {
                  "model": {
                    "default": "",
                    "type": "string"
                  },
                  "profile": {
                    "$ref": "#/components/schemas/ProfileDraft",
                    "default": {
                      "examples": [],
                      "length_rule": "",
                      "persona": "",
                      "reasoning": null,
                      "voice": {
                        "speech_style": null,
                        "tts_alias": null,
                        "voice": null
                      },
                      "voice_block": null
                    }
                  },
                  "text": {
                    "default": "",
                    "description": "The user's message.",
                    "type": "string"
                  },
                  "thread_id": {
                    "default": null,
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "voice": {
                    "default": false,
                    "description": "Assemble a voice turn rather than a text turn.",
                    "type": "boolean"
                  }
                },
                "title": "TestRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/profiles/test`'s answer.",
                  "properties": {
                    "answered_by": {
                      "description": "The alias that answered, when it was not the one asked (a fallback).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "first_token_ms": {
                      "format": "uint64",
                      "minimum": 0,
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning": {
                      "description": "The reply's reasoning; empty when it did not reason.",
                      "type": "string"
                    },
                    "reasoning_ms": {
                      "format": "uint64",
                      "minimum": 0,
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_note": {
                      "description": "Why reasoning was or was not asked as it was, in a sentence.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reply": {
                      "type": "string"
                    },
                    "system": {
                      "description": "The system message that was sent.",
                      "type": "string"
                    },
                    "total_ms": {
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "usage": {
                      "$ref": "#/components/schemas/TestUsage"
                    }
                  },
                  "required": [
                    "system",
                    "reply",
                    "reasoning",
                    "reasoning_note",
                    "usage",
                    "first_token_ms",
                    "total_ms",
                    "reasoning_ms",
                    "answered_by"
                  ],
                  "title": "TestAnswer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Test an unsaved profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/{id}": {
      "get": {
        "description": "The profile as the list carries it; 404 not_found when there is none.",
        "operationId": "get_chat_api_profiles_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A profile as `GET /chat/api/profiles` lists it.",
                  "properties": {
                    "builtin": {
                      "description": "The built-in profile this row is (`concise`); `null` for one of the\nowner's own. Read only.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "examples": {
                      "description": "Static example exchanges, in order.",
                      "items": {
                        "$ref": "#/components/schemas/Example"
                      },
                      "type": "array"
                    },
                    "follows_builtin": {
                      "description": "The fields a built-in row takes from the built-in text, so they\nfollow its improvements. Read only.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "length_rule": {
                      "description": "How long replies are; empty for none.",
                      "type": "string"
                    },
                    "name": {
                      "description": "Unique in any case; never `default`.",
                      "type": "string"
                    },
                    "persona": {
                      "description": "Who the model is and how it sounds; empty for none. When set, it\ntakes the thread's system prompt's place.",
                      "type": "string"
                    },
                    "reasoning": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Reasoning"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reasoning on or off; `null` inherits."
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "used_by": {
                      "$ref": "#/components/schemas/UsedBy"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ProfileVoice"
                    },
                    "voice_block": {
                      "description": "The voice turn's block: `null` for the generic one, `\"\"` for none, a\ntext to use as it is.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "builtin",
                    "persona",
                    "length_rule",
                    "examples",
                    "voice_block",
                    "reasoning",
                    "voice",
                    "follows_builtin",
                    "used_by",
                    "created_at",
                    "updated_at"
                  ],
                  "title": "Profile",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Get a personality profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "The fields to change: an absent field stays, null unsets it, voice is replaced whole. On a built-in profile a field written with the built-in text follows the built-in again (follows_builtin). The change applies from the next turn of every thread using the profile, a bound voice session's included. The same refusals as a create. A device key may list, create, change, reset and delete profiles; a voice.tts_alias it writes must be within its alias scope (403 key_scope), unless the profile already had it. A profile that Admin Chat or the self-admin toolset uses (a thread, or a folder's defaults) is changed, reset or deleted by a device only while the device may use lmgw's admin tools with writes, its own level and the gateway's (403 profile_in_admin_use, which counts the use and names no thread).",
        "operationId": "post_chat_api_profiles_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/profiles/{id}`'s body: the fields to change. An absent\nfield stays as it is; `null` unsets it. On a built-in row, a field\nwritten with the built-in text follows the built-in again.",
                "properties": {
                  "examples": {
                    "items": {
                      "$ref": "#/components/schemas/Example"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "length_rule": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "persona": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reasoning": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reasoning"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "voice": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/ProfileVoiceInput"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The whole voice object; `null` unsets all three."
                  },
                  "voice_block": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "title": "ProfilePatch",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A profile as `GET /chat/api/profiles` lists it.",
                  "properties": {
                    "builtin": {
                      "description": "The built-in profile this row is (`concise`); `null` for one of the\nowner's own. Read only.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "examples": {
                      "description": "Static example exchanges, in order.",
                      "items": {
                        "$ref": "#/components/schemas/Example"
                      },
                      "type": "array"
                    },
                    "follows_builtin": {
                      "description": "The fields a built-in row takes from the built-in text, so they\nfollow its improvements. Read only.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "length_rule": {
                      "description": "How long replies are; empty for none.",
                      "type": "string"
                    },
                    "name": {
                      "description": "Unique in any case; never `default`.",
                      "type": "string"
                    },
                    "persona": {
                      "description": "Who the model is and how it sounds; empty for none. When set, it\ntakes the thread's system prompt's place.",
                      "type": "string"
                    },
                    "reasoning": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Reasoning"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reasoning on or off; `null` inherits."
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "used_by": {
                      "$ref": "#/components/schemas/UsedBy"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ProfileVoice"
                    },
                    "voice_block": {
                      "description": "The voice turn's block: `null` for the generic one, `\"\"` for none, a\ntext to use as it is.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "builtin",
                    "persona",
                    "length_rule",
                    "examples",
                    "voice_block",
                    "reasoning",
                    "voice",
                    "follows_builtin",
                    "used_by",
                    "created_at",
                    "updated_at"
                  ],
                  "title": "Profile",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Change a personality profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/{id}/delete": {
      "post": {
        "description": "Deletes the profile and, in the same transaction, sets every thread using it to none, removes it from every folder's defaults, and empties the profile new threads start with when it was that one. The answer says what was cleared (threads and folders as far as the caller may see them). A built-in profile can be created again afterwards. A device key may list, create, change, reset and delete profiles; a voice.tts_alias it writes must be within its alias scope (403 key_scope), unless the profile already had it. A profile that Admin Chat or the self-admin toolset uses (a thread, or a folder's defaults) is changed, reset or deleted by a device only while the device may use lmgw's admin tools with writes, its own level and the gateway's (403 profile_in_admin_use, which counts the use and names no thread).",
        "operationId": "post_chat_api_profiles_id_delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/profiles/{id}/delete`'s answer: what the delete cleared,\nin the one transaction it ran in.",
                  "properties": {
                    "default_cleared": {
                      "description": "Whether it was the profile new threads start with (Settings → Chat),\nwhich is now none.",
                      "type": "boolean"
                    },
                    "deleted": {
                      "description": "The deleted profile's id.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "folders_cleared": {
                      "description": "Folders whose defaults named it and no longer do.",
                      "items": {
                        "$ref": "#/components/schemas/FolderRef"
                      },
                      "type": "array"
                    },
                    "threads_cleared": {
                      "description": "Threads that used it and now use none.",
                      "format": "int64",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "deleted",
                    "threads_cleared",
                    "folders_cleared",
                    "default_cleared"
                  ],
                  "title": "ProfileDeleted",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Delete a personality profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/profiles/{id}/reset": {
      "post": {
        "description": "Resets a built-in profile to its built-in texts: every content field follows the built-in again (follows_builtin lists them all), so later improvements to it apply, and the voice is unset. The name stays. 400 profile_not_builtin for one of the owner's own profiles, 404 not_found when there is none. Recorded as profile.updated in the feed. A device key may list, create, change, reset and delete profiles; a voice.tts_alias it writes must be within its alias scope (403 key_scope), unless the profile already had it. A profile that Admin Chat or the self-admin toolset uses (a thread, or a folder's defaults) is changed, reset or deleted by a device only while the device may use lmgw's admin tools with writes, its own level and the gateway's (403 profile_in_admin_use, which counts the use and names no thread).",
        "operationId": "post_chat_api_profiles_id_reset",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A profile as `GET /chat/api/profiles` lists it.",
                  "properties": {
                    "builtin": {
                      "description": "The built-in profile this row is (`concise`); `null` for one of the\nowner's own. Read only.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "examples": {
                      "description": "Static example exchanges, in order.",
                      "items": {
                        "$ref": "#/components/schemas/Example"
                      },
                      "type": "array"
                    },
                    "follows_builtin": {
                      "description": "The fields a built-in row takes from the built-in text, so they\nfollow its improvements. Read only.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "length_rule": {
                      "description": "How long replies are; empty for none.",
                      "type": "string"
                    },
                    "name": {
                      "description": "Unique in any case; never `default`.",
                      "type": "string"
                    },
                    "persona": {
                      "description": "Who the model is and how it sounds; empty for none. When set, it\ntakes the thread's system prompt's place.",
                      "type": "string"
                    },
                    "reasoning": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Reasoning"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reasoning on or off; `null` inherits."
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "used_by": {
                      "$ref": "#/components/schemas/UsedBy"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ProfileVoice"
                    },
                    "voice_block": {
                      "description": "The voice turn's block: `null` for the generic one, `\"\"` for none, a\ntext to use as it is.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "builtin",
                    "persona",
                    "length_rule",
                    "examples",
                    "voice_block",
                    "reasoning",
                    "voice",
                    "follows_builtin",
                    "used_by",
                    "created_at",
                    "updated_at"
                  ],
                  "title": "Profile",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Reset a built-in profile",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/search": {
      "get": {
        "description": "Full-text search over thread titles, message text and the names of sent attachments, in pages of 50 threads, each with up to three of its best hits. Temporary threads are never searched. A device key's search leaves out Admin Chat threads, and names no thread as being in a folder it cannot see. A query shorter than two characters, or archived other than 0, 1 or all, is a 400 bad_request.",
        "operationId": "get_chat_api_search",
        "parameters": [
          {
            "in": "query",
            "name": "archived",
            "required": false,
            "schema": {
              "default": "",
              "description": "`0` (default) active threads, `1` archived only, `all` both.",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "folder",
            "required": false,
            "schema": {
              "default": null,
              "description": "Only threads in this folder.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "default": null,
              "description": "How many threads to skip: the previous page's `next_offset`.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "q",
            "required": false,
            "schema": {
              "default": "",
              "description": "The words to find: at least two characters. Words match as prefixes\nand all must match; a `\"quoted phrase\"` matches as a phrase.",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/search`'s answer: one page of matching threads.",
                  "properties": {
                    "next_offset": {
                      "description": "The `offset` of the next page; `null` on the last.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "threads": {
                      "description": "This page's threads, best match first.",
                      "items": {
                        "$ref": "#/components/schemas/SearchThread"
                      },
                      "type": "array"
                    },
                    "total_threads": {
                      "description": "How many threads match in all.",
                      "format": "int64",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "total_threads",
                    "threads",
                    "next_offset"
                  ],
                  "title": "SearchPage",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Search the Chat",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/settings": {
      "get": {
        "description": "The gateway settings a Chat client reads, and only those: the knowledge excerpt budget a thread without its own uses, the global archive and purge days an ongoing folder's empty fields fall back to, the Chat's and the realtime voice's text-to-speech alias (a thread inherits the first that is not empty), the largest request body (a dictation's recording is one), the seconds between two reads of an MCP task's status, and a realtime session's pre-roll and ping interval. No secret is among them, and every caller reads the same values. They change only through Settings, and a client reads them again when it needs them.",
        "operationId": "get_chat_api_settings",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/settings`: the gateway settings the Chat reads, and only\nthose. None is a secret, and every caller reads the same values.",
                  "properties": {
                    "archive_days": {
                      "description": "Days after its last activity a thread is archived; `0`: never. A\nfolder's own retention overrides it.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "Tokens of knowledge-base excerpts a turn carries when its thread sets\nno budget of its own (Settings → Chat → Knowledge budget).",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "max_body_mb": {
                      "description": "The largest request body the gateway reads, in MiB; `0`: no bound.\nA dictation's recording is one such body.",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "purge_days": {
                      "description": "Days after it was archived a thread is deleted; `0`: never. A\nfolder's own retention overrides it.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "realtime_ping_interval_s": {
                      "description": "Seconds between the gateway's pings on a realtime session.",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "realtime_prefix_padding_ms": {
                      "description": "The audio a realtime session keeps from before speech starts, in\nmilliseconds: push-to-talk's pre-roll.",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "realtime_tts_alias": {
                      "description": "The realtime voice's text-to-speech alias.",
                      "type": "string"
                    },
                    "task_poll_interval_s": {
                      "description": "Seconds between two reads of an MCP task's status (Settings → MCP);\n`0`: none is set.",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "tts_alias": {
                      "description": "The Chat's text-to-speech alias; empty: `realtime_tts_alias`\nis the one a thread inherits.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "kb_budget_tokens",
                    "archive_days",
                    "purge_days",
                    "tts_alias",
                    "realtime_tts_alias",
                    "max_body_mb",
                    "task_poll_interval_s",
                    "realtime_prefix_padding_ms",
                    "realtime_ping_interval_s"
                  ],
                  "title": "ChatSettings",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read the settings the Chat uses",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/threads": {
      "get": {
        "description": "The stored threads, pinned first and then the most recently active; the temporary threads in a list of their own; how many threads are archived; and every folder with its thread counts. ?archived=1 lists the archived threads instead, the most recently archived first, and ?archived=all both. A device key's lists and counts leave out every Admin Chat thread, and every thread that carries the self-admin toolset (lmgw) unless the device may use lmgw's admin tools. Open the change feed first, then load this list: the feed's thread.* and folder.* events keep it current from then on.",
        "operationId": "get_chat_api_threads",
        "parameters": [
          {
            "in": "query",
            "name": "archived",
            "required": false,
            "schema": {
              "default": "",
              "description": "`1` lists the archived threads instead, the most recently archived\nfirst; `all` lists active and archived threads together, in the\nactive list's order. Absent (or `0`): the active threads.",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/threads`.",
                  "properties": {
                    "archived_count": {
                      "description": "How many threads are archived, whichever list was asked for.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "folders": {
                      "description": "Every folder, as `GET /chat/api/folders` lists them.",
                      "items": {
                        "$ref": "#/components/schemas/Folder"
                      },
                      "type": "array"
                    },
                    "temporary": {
                      "description": "Temporary threads, the most recently active first.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadRow"
                      },
                      "type": "array"
                    },
                    "threads": {
                      "description": "Stored threads: pinned first, then the most recently active; with\n`?archived=1` the archived ones, the most recently archived first.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadRow"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "threads",
                    "archived_count",
                    "temporary",
                    "folders"
                  ],
                  "title": "ThreadList",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List the Chat's threads",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "A new thread, answered as the thread list carries it, with `voice_resolved`. A plain chat thread starts from the Chat's default system prompt and personality profile; an Admin Chat thread (kind: admin) has its built-in prompt. temporary: true creates a temporary thread kept in memory only, with a negative id; it is a chat thread whatever kind says. folder_id starts the thread from that folder's defaults laid over the Chat's own, and in an ongoing-conversation folder it becomes the current thread. A temporary thread in a folder is a 400 bad_request; a folder the caller cannot see a 404 not_found. A device key cannot create an Admin Chat thread (403 forbidden), and the model alias must be within its alias scope (403 key_scope).",
        "operationId": "post_chat_api_threads",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads`'s body.",
                "properties": {
                  "folder_id": {
                    "default": null,
                    "description": "Create the thread in this folder, starting from the folder's\ndefaults laid over the Chat's own.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "kind": {
                    "default": "",
                    "description": "`chat` (the default) or `admin`, a thread that drives the gateway's\nown configuration (not for a device key: 403 `forbidden`).",
                    "type": "string"
                  },
                  "model_alias": {
                    "default": "",
                    "description": "The alias the thread's turns go to. In a folder, the folder's\ndefaults may name the model instead.",
                    "type": "string"
                  },
                  "temporary": {
                    "default": false,
                    "description": "A temporary chat: kept in memory only, with a negative id, and gone\nat the gateway's next start unless it is kept\n(`POST /chat/api/threads/{id}/persist`). Always a `chat` thread,\nwhatever `kind` says, and not with `folder_id`.",
                    "type": "boolean"
                  }
                },
                "title": "ThreadCreate",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
                  "properties": {
                    "agent_id": {
                      "description": "The agent the thread was opened from, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "archived_at": {
                      "description": "When the thread was archived; `null` while it is active.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "folder_id": {
                      "description": "The folder the thread is in; `null` for none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "frequency_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Negative for a temporary thread.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "kb_ids": {
                      "description": "Knowledge bases the thread searches, by id.",
                      "items": {
                        "format": "int64",
                        "type": "integer"
                      },
                      "type": "array"
                    },
                    "kb_mode": {
                      "$ref": "#/components/schemas/KbMode"
                    },
                    "kind": {
                      "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
                      "type": "string"
                    },
                    "last_message_at": {
                      "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "max_tokens": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "mcp_tools": {
                      "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadMcp"
                      },
                      "type": "array"
                    },
                    "media_defaults": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
                    },
                    "min_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "model_alias": {
                      "description": "The alias the thread's turns go to.",
                      "type": "string"
                    },
                    "pinned": {
                      "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
                      "type": "boolean"
                    },
                    "presence_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "profile_id": {
                      "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "purge_at": {
                      "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_budget": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_effort": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_enabled": {
                      "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "repeat_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "seed": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "stop": {
                      "description": "Stop sequences; empty leaves the route's default.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "system_prompt": {
                      "type": "string"
                    },
                    "temperature": {
                      "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "temporary": {
                      "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
                      "type": "boolean"
                    },
                    "title": {
                      "type": "string"
                    },
                    "top_k": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "top_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "updated_at": {
                      "description": "Moves with every change to the thread and every new message.",
                      "type": "string"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice"
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "model_alias",
                    "system_prompt",
                    "temperature",
                    "max_tokens",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "stop",
                    "kind",
                    "mcp_tools",
                    "reasoning_enabled",
                    "reasoning_effort",
                    "reasoning_budget",
                    "agent_id",
                    "pinned",
                    "archived_at",
                    "folder_id",
                    "profile_id",
                    "kb_ids",
                    "kb_mode",
                    "kb_budget_tokens",
                    "voice",
                    "media_defaults",
                    "created_at",
                    "updated_at",
                    "last_message_at",
                    "purge_at",
                    "temporary",
                    "voice_resolved"
                  ],
                  "title": "Thread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Create a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/rows": {
      "get": {
        "description": "The rows of the threads named in `ids` (comma-separated, as 3,7), each exactly as GET /chat/api/threads lists it, active or archived, in the active list's order. For a client that follows the change feed and wants only the rows its message.* events named, instead of the whole list: a message written moved its thread's updated_at and last_message_at and nothing else the list shows, so read these rows and sort the list again. Only stored threads are answered: a temporary id, one that is not there and one out of the caller's reach are left out, so a missing row is never an error. There is no cap on `ids` beyond the 64 KiB a request line may be (about 9,000 ids; more is a 414, and the whole list is then the read to fall back to). A part of `ids` that is not a number is a 400 bad_request. A device key's answer leaves out the threads it may not see, as its list does.",
        "operationId": "get_chat_api_threads_rows",
        "parameters": [
          {
            "in": "query",
            "name": "ids",
            "required": false,
            "schema": {
              "default": "",
              "description": "The thread ids, comma-separated (`3,7`). A temporary id, one that is\nnot there and one out of the caller's reach are left out of the\nanswer; a part that is not a number is a 400.",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/threads/rows`.",
                  "properties": {
                    "threads": {
                      "description": "The rows found, each as `GET /chat/api/threads` lists it, in the\nactive list's order.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadRow"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "threads"
                  ],
                  "title": "ThreadRows",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read some of the thread list's rows",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/threads/{id}": {
      "get": {
        "description": "The thread with its settings, `voice_resolved` and `continue` (whether its last reply can be continued), every message oldest first, each with its attachments, the draft attachments that wait for the next message, and the thread's MCP tasks still running or waiting to enter it. A message of a gated turn lists the calls it still waits on as `pending_approvals`; POST /chat/api/threads/{id}/approvals decides them. A thread that is not there, or not the caller's to see, is a 404 not_found; a read that failed a 500 internal, never an empty history. Read the thread again on every change the feed reports.",
        "operationId": "get_chat_api_threads_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/threads/{id}`'s answer: the thread with its whole\nhistory.",
                  "properties": {
                    "draft_attachments": {
                      "description": "Files attached to the next message, not sent yet.",
                      "items": {
                        "$ref": "#/components/schemas/AttachmentMeta"
                      },
                      "type": "array"
                    },
                    "messages": {
                      "description": "Every message, oldest first.",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      },
                      "type": "array"
                    },
                    "tasks": {
                      "description": "The thread's MCP tasks still running, and the results waiting to\nenter it.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadTask"
                      },
                      "type": "array"
                    },
                    "thread": {
                      "$ref": "#/components/schemas/Thread",
                      "description": "The thread with `voice_resolved` and `continue`: whether its last\nreply can be continued."
                    }
                  },
                  "required": [
                    "thread",
                    "messages",
                    "draft_attachments",
                    "tasks"
                  ],
                  "title": "ThreadDetail",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read a thread whole",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/threads/{id}/answer": {
      "post": {
        "description": "A tool whose MCP server runs it as a task (its execution.taskSupport is required) answers the turn at once: its result frame's output is `started, job <task_id>` and carries task {id, task_id, server_label}, and the turn goes on. lmgw follows the task; when it ends, its result enters the thread as a message of role `tool` with task {task_id, server_label, tool, status: completed | failed | cancelled | abandoned, ended_by}, its content the result as text — only while no turn of the thread runs (a turn that runs takes it in when it ends; one that starts, before it reads the history), and not while the thread's last reply waits for approvals or for the turn that runs the calls decided on it. The feed records task.started and task.done. Every later turn sees it as a call of lmgw__job_result and its result, in chronological order: where it is stored among the thread's messages, so a message sent after it follows it; an edit or a regenerate keeps it, and the reply after it answers it again. lmgw starts no turn for a result: this route asks for one, a continuation with no new user message, streaming the frames a send streams; a send answers it too. It needs a result nothing answered yet (a result row with no reply after it, or one waiting to enter the thread), else 409 nothing_to_answer; while a turn of the thread runs it is 409 turn_running (that turn's end lets the results in, and its reply may answer them). It runs on the thread's alias with its configured fallbacks, as every turn does. The body may be empty; speak reads the answer aloud as a send's does. GET /chat/api/threads/{id} lists the thread's tasks still running or waiting to enter it as `tasks` (ThreadTask: id, task_id, server_label, tool, status, status_message, ttl_ms, started_at, by, waiting_for). A temporary thread's calls wait for their task instead, within the server's timeout_ms.",
        "operationId": "post_chat_api_threads_id_answer",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/answer`'s body, which may be empty.",
                "properties": {
                  "speak": {
                    "default": false,
                    "description": "Read the answer aloud as it streams, as a send's `speak`.",
                    "type": "boolean"
                  }
                },
                "title": "AnswerRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Answer a thread's job results",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/approvals": {
      "post": {
        "description": "A thread's MCP tools may wait for an approval (the thread's mcp_tools entry's require_approval: \"never\", \"always\" or {always: {tool_names}, never: {tool_names}}, as OpenAI's; any other shape, read_only included, is refused, and a device key may only tighten it, 403 approval_loosen_refused). A turn that calls one stops: it streams a tool frame {event: approval, approval_request_id, server_label, name, arguments, call_id} for each waiting call (call_id the id the call's ready and result frames carry) and done {pending_approvals}, and saves its reply with them; the other calls of that model turn wait with them. The thread's messages list them as the reply's pending_approvals, and the feed records approval.requested, each with the call_id. This route takes a verdict for every waiting call and resumes the turn as a continuation, streaming the frames a send streams (delta, reasoning, tool, usage, stop, error, done): the declined calls are answered \"The user declined this tool call: <reason>\", the approved ones and the calls that waited with them run, and the model answers; what it adds is appended to the same reply. The resumed turn runs as the principal that started it — its scope, key policy and attribution — whoever approves. The approver is on each approved call's request row (approved_by), in the feed's approval.decided, and in _meta[\"lmgw/approval\"] {decision: approved, by: {kind, name}} of a call forwarded to a device-hosted server; a call nobody approved carries null there. The first decision wins: a call decided already is 409 approval_decided, naming who decided. A body that is not JSON is 400 bad_request, JSON of another shape 422 bad_request. A waiting call without a verdict is 400 approval_missing, naming each; an id nothing waits under 404 approval_not_found; a starter whose key is gone or disabled 409 approval_starter_unavailable, naming it (nothing is decided then; nor when the starter's key is at its concurrency limit, its 429 key_rate); a reply that is no longer the thread's last message 409 approval_moved_on. A device approves only within its own reach: a call its key's tool scope does not admit, or one of lmgw's admin tools unless its own admin tools may do everything (full, capped by the gateway's level), is 403 approval_out_of_scope, naming each, and nothing of the request is decided; declining is open to any client that sees the thread. A decided turn that never starts closes its calls as not run, and the feed's approval.decided says approve: false, not_run: true for an approved one. A new message in the thread declines whatever still waits, \"the user moved on without deciding\", so every call is answered. speak reads the resumed reply aloud as a send's does.",
        "operationId": "post_chat_api_threads_id_approvals",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/approvals`: a verdict for every call the\nthread's last reply waits on.",
                "properties": {
                  "decisions": {
                    "items": {
                      "$ref": "#/components/schemas/ApprovalDecision"
                    },
                    "type": "array"
                  },
                  "speak": {
                    "description": "Read the resumed reply aloud as it streams, as a send's `speak`.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "decisions"
                ],
                "title": "ApprovalsRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Decide the calls a turn waits on",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/archive": {
      "post": {
        "description": "archived: true archives the thread by hand; false restores it. Answers the thread as the list carries it. A temporary thread is discarded, not archived: 409 temporary_thread. A thread the caller cannot reach is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_archive",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/archive`'s body.",
                "properties": {
                  "archived": {
                    "description": "Archive (`true`) the thread by hand, or restore it.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "archived"
                ],
                "title": "ArchiveRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
                  "properties": {
                    "agent_id": {
                      "description": "The agent the thread was opened from, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "archived_at": {
                      "description": "When the thread was archived; `null` while it is active.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "folder_id": {
                      "description": "The folder the thread is in; `null` for none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "frequency_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Negative for a temporary thread.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "kb_ids": {
                      "description": "Knowledge bases the thread searches, by id.",
                      "items": {
                        "format": "int64",
                        "type": "integer"
                      },
                      "type": "array"
                    },
                    "kb_mode": {
                      "$ref": "#/components/schemas/KbMode"
                    },
                    "kind": {
                      "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
                      "type": "string"
                    },
                    "last_message_at": {
                      "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "max_tokens": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "mcp_tools": {
                      "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadMcp"
                      },
                      "type": "array"
                    },
                    "media_defaults": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
                    },
                    "min_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "model_alias": {
                      "description": "The alias the thread's turns go to.",
                      "type": "string"
                    },
                    "pinned": {
                      "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
                      "type": "boolean"
                    },
                    "presence_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "profile_id": {
                      "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "purge_at": {
                      "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_budget": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_effort": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_enabled": {
                      "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "repeat_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "seed": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "stop": {
                      "description": "Stop sequences; empty leaves the route's default.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "system_prompt": {
                      "type": "string"
                    },
                    "temperature": {
                      "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "temporary": {
                      "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
                      "type": "boolean"
                    },
                    "title": {
                      "type": "string"
                    },
                    "top_k": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "top_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "updated_at": {
                      "description": "Moves with every change to the thread and every new message.",
                      "type": "string"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice"
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "model_alias",
                    "system_prompt",
                    "temperature",
                    "max_tokens",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "stop",
                    "kind",
                    "mcp_tools",
                    "reasoning_enabled",
                    "reasoning_effort",
                    "reasoning_budget",
                    "agent_id",
                    "pinned",
                    "archived_at",
                    "folder_id",
                    "profile_id",
                    "kb_ids",
                    "kb_mode",
                    "kb_budget_tokens",
                    "voice",
                    "media_defaults",
                    "created_at",
                    "updated_at",
                    "last_message_at",
                    "purge_at",
                    "temporary",
                    "voice_resolved"
                  ],
                  "title": "Thread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Archive or restore a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/attachments": {
      "post": {
        "description": "The body is the file's bytes, not multipart; ?name= is its name. The kind is sniffed from the bytes (image, text, pdf, office, audio), never taken from the name or the Content-Type. The file is stored as a draft of the thread, to be sent with the next message (`attachments` of POST /chat/api/threads/{id}/send), and answered as its metadata, with `blockers` and `hints` saying what the thread's current model cannot take. A PDF is read at upload (text-class, scanned or hybrid in `meta.class`; a text-class one starts with the Chat's PDF mode, or none to ask), an office file likewise, and an audio file is transcribed at once when its model cannot hear it and a speech-to-text model is set (a failure is `meta.transcript_error`, not a refusal). The body is bounded by max_body_mb (413 body_limit naming it, for a declared or a chunked body). 400 empty_attachment for an empty file, 404 not_found for a thread that is not there or not the caller's, 415 unsupported_attachment for bytes of no supported kind, 422 extract_failed (the file could not be read) or tool_missing (the PDF reader is not installed).",
        "operationId": "post_chat_api_threads_id_attachments",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "name",
            "required": true,
            "schema": {
              "description": "The file's name, shown on its chip and kept in an export. The kind\nis sniffed from the bytes, never taken from the name or a content\ntype. Blank is stored as `untitled`.",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One attachment's metadata, never its bytes.",
                  "properties": {
                    "blockers": {
                      "description": "For a draft: why it cannot be sent to the thread's current model.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "call_id": {
                      "description": "The tool call that made a `tool` file, or the card action that made\nan `action` file (its `act-<boot>-<n>` id, the one its stream's\nframes carried); absent for an upload.",
                      "type": "string"
                    },
                    "extracted_tokens": {
                      "description": "The extracted text's token estimate; `null` when there is none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "hints": {
                      "description": "For a draft: what it becomes on the way, sent all the same (an image\nas a placeholder, a PDF's pages as its text) under a fallback that\ncannot see.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "kind": {
                      "description": "`image`, `pdf`, `text`, `audio`, ... as the upload was classified.",
                      "type": "string"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AttachmentFacts",
                      "description": "What extraction found: pages, text-less pages, class, sheets,\ntranscript alias or error, tokens. `{}` for an image."
                    },
                    "mime": {
                      "type": "string"
                    },
                    "mode": {
                      "description": "A text-class PDF's choice, `text` or `images`; `null` when it does\nnot apply or is not chosen yet.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "size": {
                      "description": "Size in bytes.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "source": {
                      "description": "Where the file came from: `upload` (the user sent it), `tool` (an\nimage or audio tool of a turn made it) or `action` (an image card's\naction made it).",
                      "enum": [
                        "upload",
                        "tool",
                        "action"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "name",
                    "mime",
                    "size",
                    "mode",
                    "meta",
                    "extracted_tokens",
                    "source"
                  ],
                  "title": "AttachmentMeta",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Upload an attachment",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/continue": {
      "post": {
        "description": "The model continues the thread's last reply (an assistant prefill) and streams the continuation only: the delta frames are what is added, done's message_id is the continued reply, and the stored reply's text and reasoning grow by what came (its token counts become this call's). The body is optional (a body that is not JSON is 400 bad_request, JSON of another shape 422 bad_request); with `speak` the continuation is read aloud as it streams, from the clause the reply broke off in. 409 continue_unavailable when the thread's `continue` state says no (its reason is the message): there is no reply yet, the last message is not a reply, the reply ran tools, or the thread's model cannot take a prefill. The same code answers a reply that stopped being the last message meanwhile. A route the request is re-routed to that cannot take a prefill is refused in the stream, with an error frame. 404 not_found, and a device key's own refusals. The frames are those of a send, without the `turn` frame.",
        "operationId": "post_chat_api_threads_id_continue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "The optional body of a continue and of a regenerate; an empty request is\naccepted.",
                "properties": {
                  "speak": {
                    "description": "Read the answer aloud as it streams.",
                    "type": "boolean"
                  }
                },
                "title": "TurnRequest",
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Continue the thread's last reply",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/delete": {
      "post": {
        "description": "Deletes the thread with its messages and attachments. The owner's delete of a thread that is not there still answers ok; a device key's delete of a thread it cannot reach (gone, or Admin Chat) is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer of a write that has nothing to report but that it\nhappened: `{\"ok\": true}`.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`; a failure is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "Ack",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Delete a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/export": {
      "get": {
        "description": "The thread as one file. format=md (the default) is a readable Markdown transcript, text/markdown; charset=utf-8, with its attachments listed by name; format=json is the lossless lmgw.chat.v1 file, application/json, with every thread column, every message, and each attachment's metadata, extracted text and base64 bytes (the `format` field of the file says lmgw.chat.v1). The answer carries Content-Disposition: attachment with a file name lmgw-chat-{id}-{title}.md or .json (a temporary thread's id reads temp{n}) and Cache-Control: no-store. A temporary thread is exported from memory. A format other than md, markdown or json is a 400 bad_request; a thread that is not there, or not the caller's to see, is a 404 not_found.",
        "operationId": "get_chat_api_threads_id_export",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "archived",
            "required": false,
            "schema": {
              "default": "",
              "description": "Zips only: `0` active threads, `1` archived threads only, `all`\n(default) both.",
              "enum": [
                "0",
                "1",
                "all"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "default": "",
              "description": "`md` (default; `markdown` is accepted too) for a readable\ntranscript, `json` for the lossless `lmgw.chat.v1` file. A zip holds\none file of this format per thread.",
              "enum": [
                "md",
                "markdown",
                "json"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The `lmgw.chat.v1` file of one thread: every thread column, every\nmessage, and every attachment with its bytes.",
                  "properties": {
                    "draft_attachments": {
                      "description": "The attachments not yet sent with a message.",
                      "items": {
                        "$ref": "#/components/schemas/ExportAttachment"
                      },
                      "type": "array"
                    },
                    "exported_at": {
                      "description": "When the file was written (RFC 3339, UTC).",
                      "type": "string"
                    },
                    "folder": {
                      "$ref": "#/components/schemas/ExportRef",
                      "description": "The thread's folder; absent when it is in none."
                    },
                    "format": {
                      "description": "Always `lmgw.chat.v1`.",
                      "type": "string"
                    },
                    "messages": {
                      "description": "Oldest first.",
                      "items": {
                        "$ref": "#/components/schemas/ExportMessage"
                      },
                      "type": "array"
                    },
                    "profile": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/ExportRef"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The thread's personality profile; `null` for none."
                    },
                    "thread": {
                      "$ref": "#/components/schemas/ExportThread"
                    }
                  },
                  "required": [
                    "format",
                    "exported_at",
                    "thread",
                    "profile",
                    "messages",
                    "draft_attachments"
                  ],
                  "title": "ChatExport",
                  "type": "object"
                }
              },
              "text/markdown; charset=utf-8": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Export a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/threads/{id}/media/{call_id}/cancel": {
      "post": {
        "description": "Stops the image or audio tool call {call_id} (the call_id of its tool frames) of the turn that runs in the thread, as the turn's Stop stops it, without stopping the turn: the call's result tells the model the picture was not made, and the turn goes on. It also stops a card action of the thread (POST /chat/api/attachments/{id}/media), named by the act-<boot>-<n> id of its stream's action frame; the action's stream then ends with an error frame and nothing is stored. A running image job is cancelled by what its image server can do, which the call's last `progress` frame named as `cancel` and the answer repeats: native, the server's own cancel (the model stays loaded); restart, the server cannot stop a running picture and this call is the model's only request, so lmgw stops its container and the next picture loads it again; abandon, another request uses the model, so the call stops waiting and the picture finishes in the background and is thrown away. An upscale has no job: restart or abandon by the same rule, an abandoned one holding its claim until the image server is done. No `cancel` in the answer: no job ran yet (the call was loading its model or waiting for room, and stops waiting), or an audio call. The body is ignored. A thread the caller does not reach is 404 not_found; a call that is not running, 404 not_running.",
        "operationId": "post_chat_api_threads_id_media_call_id_cancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "call_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "What `POST /chat/api/threads/{id}/media/{call_id}/cancel` did.",
                  "properties": {
                    "cancel": {
                      "$ref": "#/components/schemas/CancelKind",
                      "description": "What the cancel does to the running image job; absent when no job\nruns yet (the call was still loading its model or waiting for room,\nand stops waiting) and for an audio call."
                    },
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "MediaCancelled",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Cancel a running picture or recording",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/messages/{mid}/delete": {
      "post": {
        "description": "Deletes that one message with its attachments; nothing after it moves. A device key below full admin level changes no message of a thread with lmgw's admin tools (403 chat_toolset_needs_full). A thread or message that is not there is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_messages_mid_delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "mid",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "The answer of a write that has nothing to report but that it\nhappened: `{\"ok\": true}`.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`; a failure is an error answer instead.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "title": "Ack",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Delete a message",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/messages/{mid}/edit": {
      "post": {
        "description": "What the answer is depends on the message. A reply is rewritten in place and nothing is sent: its reasoning, token counts and tool record are cleared, since they no longer describe the text, and so are a spoken reply's unheard rest and timing; the answer is JSON, `ok` and the message as the thread lists it. A user message is rewritten in place (its attachments stay bound), every later message is deleted, and it is answered again: the answer is the event stream of a send, opening with a `turn` frame. An empty text is a 400 empty_message unless the message carries files. Its stored knowledge retrieval goes with the old text, so auto mode searches again; kb_refs, when sent, replaces its `#` picks. A dictated message whose text changed becomes a typed one. Everything that can refuse happens before anything is written. Any other role is a 400 bad_request. A device key below full admin level edits no message of a thread with lmgw's admin tools (403 chat_toolset_needs_full); its kb_refs pass its tool scope. A thread or message that is not there is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_messages_mid_edit",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "mid",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/messages/{mid}/edit`'s body.",
                "properties": {
                  "content": {
                    "description": "The new text.",
                    "type": "string"
                  },
                  "kb_refs": {
                    "description": "A user message's knowledge bases for itself (`#`), replacing the\nones it had; absent keeps them. Ignored for a reply.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "origin": {
                    "description": "A user message's new origin (`origin` of a send): where the user\nwrites the edit from. Absent, or blank, keeps the one it had.\nIgnored for a reply.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "speak": {
                    "description": "Read the new answer aloud as it streams. Ignored for a reply, which\nis not answered again.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "content"
                ],
                "title": "MessageEdit",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/messages/{mid}/edit`'s JSON answer, for a\nreply: rewritten in place, nothing sent.",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/Message",
                      "description": "The reply as `GET /chat/api/threads/{id}` lists it."
                    },
                    "ok": {
                      "description": "Always `true`.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "message"
                  ],
                  "title": "ReplyEdited",
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "turn": {
                "description": "`turn`: the first frame of a turn that wrote a user message (a send, an\nedit of a user message).",
                "properties": {
                  "user_message_id": {
                    "description": "The user message the answer follows.",
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "user_message_id"
                ],
                "title": "TurnStarted",
                "type": "object"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Edit a message",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/messages/{mid}/regenerate": {
      "post": {
        "description": "Cuts the thread at the message and streams a new answer. On a reply, it and every later message are deleted and the model answers the history before it, which has to end with a user message (or a job's result): 409 nothing_to_answer otherwise, and nothing is deleted. On a user message, every later message is deleted, it is answered again, and the stream opens with a `turn` frame carrying its id. Any other role is 400 bad_request; 404 not_found for a thread or message that is not there; a device key below full admin level changes no message of a thread with lmgw's admin tools (403 chat_toolset_needs_full). The model's capabilities are read before anything is cut. The body is optional (a body that is not JSON is 400 bad_request, JSON of another shape 422 bad_request); with `speak` the answer is read aloud as it streams. The frames are those of a send.",
        "operationId": "post_chat_api_threads_id_messages_mid_regenerate",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "mid",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "The optional body of a continue and of a regenerate; an empty request is\naccepted.",
                "properties": {
                  "speak": {
                    "description": "Read the answer aloud as it streams.",
                    "type": "boolean"
                  }
                },
                "title": "TurnRequest",
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "turn": {
                "description": "`turn`: the first frame of a turn that wrote a user message (a send, an\nedit of a user message).",
                "properties": {
                  "user_message_id": {
                    "description": "The user message the answer follows.",
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "user_message_id"
                ],
                "title": "TurnStarted",
                "type": "object"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Answer a message again",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/messages/{mid}/speak": {
      "post": {
        "description": "Reads the reply as it is shown (its content, then a spoken reply's unheard rest) with the thread's text-to-speech model and voice, and streams the audio as it is made: `state` while the speech model is not resident (loading, then ready, fallback, held or failed), `voice` once its route is open, a `speech` frame per clause (seq counting from 0, the text said, pcm: base64 PCM16 little-endian, 24 kHz, mono) and `speech_done` with the totals. A thread that cannot speak (no speech model, no such voice, a voice that needs instructions) and a voice that fails mid-way end with a `speech_error` frame (codes tts_not_configured, voice_not_found, voice_not_configured, instructions_required, or the failure's kind). One speech row is written per call. Closing the stream stops the synthesis at its next step; POST /chat/api/threads/{id}/speech/stop stops every read-aloud of the thread. A device or owner key that is disabled, rotated, deleted or expired while it streams, and a gateway that stops, end the stream with a last `error` frame (code revoked, with `kind`, or gateway_stopping). Refused before any frame: 404 not_found (thread or message), 400 bad_request (the message is not a reply), 400 empty_message (a reply with no text).",
        "operationId": "post_chat_api_threads_id_messages_mid_speak",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "mid",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read a stored reply aloud",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/move": {
      "post": {
        "description": "Moves the thread into the folder, or out of any folder with folder_id: null, and answers the thread as the list carries it. The change reaches every client as a thread.updated event. A temporary thread has no folder until it is kept: 409 temporary_thread. A thread or folder the caller cannot reach is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_move",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/move`'s body.",
                "properties": {
                  "folder_id": {
                    "description": "The target folder; `null` takes the thread out of any folder.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "title": "MoveRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
                  "properties": {
                    "agent_id": {
                      "description": "The agent the thread was opened from, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "archived_at": {
                      "description": "When the thread was archived; `null` while it is active.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "folder_id": {
                      "description": "The folder the thread is in; `null` for none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "frequency_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Negative for a temporary thread.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "kb_ids": {
                      "description": "Knowledge bases the thread searches, by id.",
                      "items": {
                        "format": "int64",
                        "type": "integer"
                      },
                      "type": "array"
                    },
                    "kb_mode": {
                      "$ref": "#/components/schemas/KbMode"
                    },
                    "kind": {
                      "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
                      "type": "string"
                    },
                    "last_message_at": {
                      "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "max_tokens": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "mcp_tools": {
                      "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadMcp"
                      },
                      "type": "array"
                    },
                    "media_defaults": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
                    },
                    "min_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "model_alias": {
                      "description": "The alias the thread's turns go to.",
                      "type": "string"
                    },
                    "pinned": {
                      "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
                      "type": "boolean"
                    },
                    "presence_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "profile_id": {
                      "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "purge_at": {
                      "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_budget": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_effort": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_enabled": {
                      "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "repeat_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "seed": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "stop": {
                      "description": "Stop sequences; empty leaves the route's default.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "system_prompt": {
                      "type": "string"
                    },
                    "temperature": {
                      "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "temporary": {
                      "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
                      "type": "boolean"
                    },
                    "title": {
                      "type": "string"
                    },
                    "top_k": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "top_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "updated_at": {
                      "description": "Moves with every change to the thread and every new message.",
                      "type": "string"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice"
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "model_alias",
                    "system_prompt",
                    "temperature",
                    "max_tokens",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "stop",
                    "kind",
                    "mcp_tools",
                    "reasoning_enabled",
                    "reasoning_effort",
                    "reasoning_budget",
                    "agent_id",
                    "pinned",
                    "archived_at",
                    "folder_id",
                    "profile_id",
                    "kb_ids",
                    "kb_mode",
                    "kb_budget_tokens",
                    "voice",
                    "media_defaults",
                    "created_at",
                    "updated_at",
                    "last_message_at",
                    "purge_at",
                    "temporary",
                    "voice_resolved"
                  ],
                  "title": "Thread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Move a thread into a folder",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/persist": {
      "post": {
        "description": "Writes a temporary thread (messages, attachments, settings) to the database as an ordinary thread and drops it from memory. Answers the stored thread and its new, positive id; the temporary id is gone. A thread that is already stored is a 409 not_temporary; a keep of the same thread already running a 409 keep_in_progress; a keep while a realtime voice session is bound to the thread a 409 voice_session_active. An unknown temporary thread is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_persist",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/persist`'s answer.",
                  "properties": {
                    "id": {
                      "description": "The stored thread's new, positive id.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "thread": {
                      "$ref": "#/components/schemas/Thread",
                      "description": "The stored thread."
                    }
                  },
                  "required": [
                    "id",
                    "thread"
                  ],
                  "title": "ThreadKept",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Keep a temporary thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/pin": {
      "post": {
        "description": "Pinned threads are listed first and are never archived or deleted by the retention sweep. Pinning an archived thread also restores it. Answers the thread as the list carries it. A temporary thread has nothing to pin until it is kept: 409 temporary_thread. A thread the caller cannot reach is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_pin",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/pin`'s body.",
                "properties": {
                  "pinned": {
                    "description": "Pin (`true`) or unpin the thread. Pinning an archived thread also\nrestores it.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "pinned"
                ],
                "title": "PinRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
                  "properties": {
                    "agent_id": {
                      "description": "The agent the thread was opened from, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "archived_at": {
                      "description": "When the thread was archived; `null` while it is active.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "folder_id": {
                      "description": "The folder the thread is in; `null` for none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "frequency_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Negative for a temporary thread.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "kb_ids": {
                      "description": "Knowledge bases the thread searches, by id.",
                      "items": {
                        "format": "int64",
                        "type": "integer"
                      },
                      "type": "array"
                    },
                    "kb_mode": {
                      "$ref": "#/components/schemas/KbMode"
                    },
                    "kind": {
                      "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
                      "type": "string"
                    },
                    "last_message_at": {
                      "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "max_tokens": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "mcp_tools": {
                      "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadMcp"
                      },
                      "type": "array"
                    },
                    "media_defaults": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
                    },
                    "min_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "model_alias": {
                      "description": "The alias the thread's turns go to.",
                      "type": "string"
                    },
                    "pinned": {
                      "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
                      "type": "boolean"
                    },
                    "presence_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "profile_id": {
                      "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "purge_at": {
                      "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_budget": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_effort": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_enabled": {
                      "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "repeat_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "seed": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "stop": {
                      "description": "Stop sequences; empty leaves the route's default.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "system_prompt": {
                      "type": "string"
                    },
                    "temperature": {
                      "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "temporary": {
                      "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
                      "type": "boolean"
                    },
                    "title": {
                      "type": "string"
                    },
                    "top_k": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "top_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "updated_at": {
                      "description": "Moves with every change to the thread and every new message.",
                      "type": "string"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice"
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "model_alias",
                    "system_prompt",
                    "temperature",
                    "max_tokens",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "stop",
                    "kind",
                    "mcp_tools",
                    "reasoning_enabled",
                    "reasoning_effort",
                    "reasoning_budget",
                    "agent_id",
                    "pinned",
                    "archived_at",
                    "folder_id",
                    "profile_id",
                    "kb_ids",
                    "kb_mode",
                    "kb_budget_tokens",
                    "voice",
                    "media_defaults",
                    "created_at",
                    "updated_at",
                    "last_message_at",
                    "purge_at",
                    "temporary",
                    "voice_resolved"
                  ],
                  "title": "Thread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Pin or unpin a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/send": {
      "post": {
        "description": "Writes the user message (with the draft attachments it binds and the knowledge bases it picks) and streams the model's answer. The message is stored before the model is called, so a client that goes away has still recorded what it asked; an untitled thread is titled from it. `content` may be empty when attachments are bound. A dictated message names its origin in `voice` (via: dictation); with `speak`, the reply is read aloud as it streams and the stream also carries voice, speech, speech_done and speech_error frames (the speech frames' audio is base64 PCM16, 24 kHz, mono). The first frame is `turn` with the user message's id. Refused before anything is written: 400 empty_message (no text and no attachment), 400 bad_request (a knowledge base that does not exist), 400 attachment_not_draft (an id that is no draft of the thread), 400 model_no_vision (a new image and a model that cannot see), 422 attachment_blocked (a file the thread's model cannot take, named), 404 not_found and a device key's own refusals (its scope, its budget). A body that is not JSON is 400 bad_request, JSON of another shape (an unknown or mistyped field, `voice` included) 422 bad_request, and a `voice.via` other than dictation (realtime, say) 400 bad_request. 409 attachment_not_draft: a concurrent send took a draft first. A turn that fails after the stream began says so in an error frame. The answer is a server-sent event stream; every frame's data is JSON of the type its event name has below. state: a model stage loading, held, falling back or failing (the thread's model); retrieval: what the knowledge bases found for the user message, before the model answers; delta: a piece of the answer; reasoning: a piece of the model's reasoning; tool: a tool call of the turn, by its `event` (start, args, ready, approval, result); usage: the token counts so far; stop: why the model stopped; stats: a local model's timings; error: a failure, the stream goes on to done — one per MCP label the thread or its folder attached that offers the turn no tools, with its server_label and a code (tool_unreachable: a paired device's tools the caller is not granted, or a server its tool scope keeps out; tool_offline; tool_disabled; tool_unknown; tool_failed), the turn going on without it, as a plain chat turn when every such label is an offline or ungranted device's; done: the end, naming the reply it saved and its token counts, and `pending_approvals` when it stopped on calls that wait for a decision. A turn that is refused before it says anything streams error and done {aborted: true}. A client that closes the stream stops the turn; the partial reply is saved.",
        "operationId": "post_chat_api_threads_id_send",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/send`'s body.",
                "properties": {
                  "attachments": {
                    "description": "Draft attachment ids this message binds, in the order the files are\nread in; a repeated id counts once.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "content": {
                    "description": "The message's text; may be empty when `attachments` is not (a message\ncan be just a file).",
                    "type": "string"
                  },
                  "kb_refs": {
                    "description": "Knowledge bases picked for this message alone, on top of the thread's\nown.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "origin": {
                    "description": "Where the user writes from, in one sentence the client words (a\nbrowser sidebar: \"Typed in Kai's sidebar in Firefox, beside the tab\n“Example” (https://example.org/).\"). Stored on the user message and\nput before its text in the model's input on every turn, marked as\nwhat the client says rather than the user's words; the thread reads\nit back as the message's `origin`. Absent, or blank: the message\nsays nothing of where it was written.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "speak": {
                    "description": "Read the reply aloud as it streams: the stream then carries the\nspeech frames too.",
                    "type": "boolean"
                  },
                  "voice": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/DictatedVoice"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "How a dictated message was dictated, stored on the user message."
                  }
                },
                "required": [
                  "content"
                ],
                "title": "SendRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "delta": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "done": {
                "description": "`done`: the turn's last frame. `aborted` is `true` when the turn ended\nearly (refused, stopped, failed before it said anything); a turn that\nsaved nothing says only that, with no `message_id`.",
                "properties": {
                  "aborted": {
                    "type": "boolean"
                  },
                  "answered_by": {
                    "description": "The alias that answered in its place (a fallback, a candidate\nalias's pick), when one did.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "images_note": {
                    "description": "A fallback that cannot see answered and got the images as\nplaceholders: who, in a sentence. Only when it did.",
                    "type": "string"
                  },
                  "message_id": {
                    "description": "The reply the turn saved or appended to; `0` when it saved none.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "model": {
                    "description": "The thread's model alias.",
                    "type": "string"
                  },
                  "pending_approvals": {
                    "description": "The calls the turn stopped on and waits for a decision about; only\nwhen there are some.",
                    "items": {
                      "$ref": "#/components/schemas/ApprovalRequest"
                    },
                    "type": "array"
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_ignored": {
                    "description": "The thread's reasoning and sampling overrides this route did not send.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "reasoning_note": {
                    "description": "The model reasoned although off was asked, in a sentence.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "saved": {
                    "description": "Whether the reply is stored. `false`: its bubble is not a row, and no\naction on it can work.",
                    "type": "boolean"
                  },
                  "timings": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Timings"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The authoritative final timings of a local model; `null` for a cloud\nupstream."
                  },
                  "total_ms": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "ttfb_ms": {
                    "description": "Milliseconds to the first byte of the upstream's answer.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "aborted"
                ],
                "title": "DoneFrame",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "reasoning": {
                "description": "`delta` (a piece of the answer) and `reasoning` (a piece of the model's\nreasoning, kept apart from the answer).",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "text"
                ],
                "title": "TextFrame",
                "type": "object"
              },
              "retrieval": {
                "description": "`retrieval`: what the knowledge bases found for the user message, before\nthe model answers.",
                "properties": {
                  "budget_tokens": {
                    "description": "The budget the retrieval ran with.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "dropped": {
                    "description": "Excerpts that ranked but did not fit the budget.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "excerpts": {
                    "items": {
                      "$ref": "#/components/schemas/ContextExcerpt"
                    },
                    "type": "array"
                  },
                  "kb_ids": {
                    "description": "The bases asked for: the thread's and the message's, as they were\nthen.",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": "array"
                  },
                  "message_id": {
                    "description": "The user message the retrieval belongs to.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "ms": {
                    "description": "How long the retrieval took.",
                    "format": "double",
                    "type": "number"
                  },
                  "notes": {
                    "description": "Why something was not searched, or not fully: one sentence each.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "query": {
                    "description": "What was searched for.",
                    "type": "string"
                  },
                  "reused": {
                    "description": "The message's stored retrieval was used again instead of searching.",
                    "type": "boolean"
                  },
                  "searched": {
                    "description": "The bases that were searched, by name.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "tokens": {
                    "description": "Tokens the excerpts use, heading paths included.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "excerpts",
                  "tokens",
                  "dropped",
                  "budget_tokens",
                  "notes",
                  "searched",
                  "kb_ids",
                  "query",
                  "ms",
                  "message_id",
                  "reused"
                ],
                "title": "RetrievalFrame",
                "type": "object"
              },
              "speech": {
                "description": "`speech`: one clause as said, with its audio.",
                "properties": {
                  "pcm": {
                    "description": "The clause's audio, base64 of PCM16 little-endian, 24 kHz, mono.",
                    "type": "string"
                  },
                  "seq": {
                    "description": "Counts from 0.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "seq",
                  "text",
                  "pcm"
                ],
                "title": "SpeechFrame",
                "type": "object"
              },
              "speech_done": {
                "description": "`speech_done`: the read-aloud ended, whole or stopped.",
                "properties": {
                  "audio_ms": {
                    "description": "Length of the audio sent.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "chars": {
                    "description": "Characters spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "first_audio_ms": {
                    "description": "From the request's start to the first `speech` frame; `null` when\nnothing was spoken.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stopped": {
                    "description": "Stopped (`POST .../speech/stop`, or the reader went away) before the\ntext ended.",
                    "type": "boolean"
                  },
                  "tts": {
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "chars",
                  "audio_ms",
                  "first_audio_ms",
                  "tts",
                  "tts_answered_by",
                  "stopped"
                ],
                "title": "SpeechDone",
                "type": "object"
              },
              "speech_error": {
                "description": "`speech_error`: the read-aloud cannot speak or failed; it ends the\nspeech. Codes: `tts_not_configured`, `voice_not_found`,\n`voice_not_configured`, `instructions_required`, a device key's own\nrefusals, or the failure's kind.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ],
                "title": "SpeechError",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              },
              "stats": {
                "description": "Server-measured prefill and decode timings of a local model: the `stats`\nframe (live per token while it streams) and the `done` frame's final\n`timings`.",
                "properties": {
                  "cache_n": {
                    "description": "Prompt tokens served from the KV cache.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n": {
                    "description": "Draft tokens proposed (speculative or MTP decoding).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "draft_n_accepted": {
                    "description": "Draft tokens accepted.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_ms": {
                    "description": "Milliseconds spent generating; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "predicted_n": {
                    "description": "Tokens generated so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "predicted_per_second": {
                    "description": "Tokens generated per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_ms": {
                    "description": "Milliseconds spent on the prompt; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  },
                  "prompt_n": {
                    "description": "Prompt tokens actually processed this turn (the cache excluded).",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "prompt_per_second": {
                    "description": "Prompt tokens processed per second; absent when llama.cpp gave no finite number.",
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "prompt_n",
                  "predicted_n"
                ],
                "title": "Timings",
                "type": "object"
              },
              "stop": {
                "description": "`stop`: why the model stopped, in OpenAI's words (`stop`, `length`,\n`tool_calls`, ...).",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "title": "StopFrame",
                "type": "object"
              },
              "tool": {
                "description": "`tool`: a tool call of the turn, told apart by `event`. `start` and\n`args` while the model writes the call; `ready` when its arguments are\ncomplete (a call that waits for an approval says `needs_approval`);\n`approval` for a call that waits for a decision\n(`POST /chat/api/threads/{id}/approvals`); `result` when it has run. A\nresult's `task` says which MCP task a call started: its output is then\n`started, job <task_id>`, and the result enters the thread later.\n`progress` while an image or audio tool runs: its stage, step and latest\npreview (`ToolProgressFrame`), lossy and not in the change feed; a\nresult's `attachments` are the files the call stored in the thread.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ToolStartFrame",
                    "properties": {
                      "event": {
                        "const": "start",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolArgsFrame",
                    "properties": {
                      "event": {
                        "const": "args",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolReadyFrame",
                    "properties": {
                      "event": {
                        "const": "ready",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ApprovalRequest",
                    "properties": {
                      "event": {
                        "const": "approval",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolResultFrame",
                    "properties": {
                      "event": {
                        "const": "result",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  },
                  {
                    "$ref": "#/components/schemas/ToolProgressFrame",
                    "properties": {
                      "event": {
                        "const": "progress",
                        "type": "string"
                      }
                    },
                    "required": [
                      "event"
                    ],
                    "type": "object"
                  }
                ],
                "title": "ToolFrame"
              },
              "turn": {
                "description": "`turn`: the first frame of a turn that wrote a user message (a send, an\nedit of a user message).",
                "properties": {
                  "user_message_id": {
                    "description": "The user message the answer follows.",
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "user_message_id"
                ],
                "title": "TurnStarted",
                "type": "object"
              },
              "usage": {
                "description": "`usage`: the tokens the model reported for the turn so far.",
                "properties": {
                  "completion_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "prompt_tokens": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "prompt_tokens",
                  "completion_tokens"
                ],
                "title": "UsageFrame",
                "type": "object"
              },
              "voice": {
                "description": "`voice` (speech): the read-aloud's route is open.",
                "properties": {
                  "tts": {
                    "description": "The text-to-speech alias.",
                    "type": "string"
                  },
                  "tts_answered_by": {
                    "description": "The alias that answers in the TTS alias's place (a fallback).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "voice": {
                    "description": "The voice every clause is sent with.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "tts",
                  "voice",
                  "tts_answered_by"
                ],
                "title": "VoiceFrame",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Send a message and stream the answer",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/settings": {
      "post": {
        "description": "A patch: a field left out stays as it is, and for the settings that can be unset, null clears it back to the route's default. Settings that contradict each other (the reasoning and sampling overrides, the knowledge settings, a voice alias that cannot do what it is for) are a 400 bad_request and nothing is written; an unknown profile_id is a 400 unknown_profile. The answer re-judges `continue` under the new settings, and carries the voice as stored and what it resolves to now. A device key's mcp_tools and knowledge bases pass its tool scope first (403 tool_label_out_of_scope), its model and voice aliases its alias scope (403 key_scope); a device below full admin level changes no setting of a thread with lmgw's admin tools (403 chat_toolset_needs_full). A thread that is gone is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_settings",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /chat/api/threads/{id}/settings`'s body: a **patch**. An absent\nfield leaves that setting alone; for the settings that can be unset,\n`null` clears it back to the route's default. The thread's title is not\nhere: it names itself on the first send, and `POST …/title` renames it.",
                "properties": {
                  "frequency_penalty": {
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "kb_budget_tokens": {
                    "description": "The retrieval budget of `auto` mode in tokens; `null` takes the\nChat's setting.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "kb_ids": {
                    "description": "The thread's knowledge bases, as a whole selection (`[]` clears it).",
                    "items": {
                      "format": "int64",
                      "type": "integer"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "kb_mode": {
                    "description": "`auto` or `tool`: how the bases reach the model.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "max_tokens": {
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "mcp_tools": {
                    "description": "The tool servers the thread uses, as a whole list (`[]` detaches\nall). A device key's labels pass its tool scope first.",
                    "items": {
                      "$ref": "#/components/schemas/ThreadMcpInput"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "media_defaults": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/MediaDefaults"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The image and audio tools' default models, as a whole object (`{}`\ninherits everything): a field names a model of the tool's `model`\nenum (`\"\"` for none), or the voice. A name the tool cannot use for\nthis caller is a 400 `bad_request`; one the thread already holds\npasses, so a model switched off since does not block other changes."
                  },
                  "min_p": {
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "model_alias": {
                    "description": "The alias the thread's turns go to.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "presence_penalty": {
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "profile_id": {
                    "description": "The personality profile, an id from `GET /chat/api/profiles`; `null`\nfor none. An unknown id is a 400 `unknown_profile`.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_budget": {
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "reasoning_effort": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reasoning_enabled": {
                    "description": "Reasoning overrides sent with every turn; `null` clears one.",
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "repeat_penalty": {
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "seed": {
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "stop": {
                    "description": "The whole list of stop sequences; `[]` clears it.",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "system_prompt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "temperature": {
                    "description": "Sampling overrides sent with every turn: a number sets one, `null`\nclears it.",
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "top_k": {
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "top_p": {
                    "format": "double",
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "voice": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/ThreadVoice"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "The thread's voice overrides as a whole object; `null` clears them.\nAn unknown key or value is a 400 `bad_request`."
                  }
                },
                "title": "SettingsPatch",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/settings`'s answer.",
                  "properties": {
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued under the new settings (a\nmodel switch or a reasoning toggle changes it)."
                    },
                    "ok": {
                      "description": "Always `true`.",
                      "type": "boolean"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice",
                      "description": "The thread's own voice settings as stored now."
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the voice resolves to now, as `voice_resolved` of\n`GET /chat/api/threads/{id}`: `asr` and `tts` (alias, whether it runs\non this machine, what answers for it while the GPU is held), `voice`,\n`speech_style`, `language`, `reply_language`, `language_notes`,\n`read_aloud`, `turn_detection`, `audio_input`, `seed`, the `problems`\nthat block a voice feature now, and `realtime`."
                    }
                  },
                  "required": [
                    "ok",
                    "continue",
                    "voice",
                    "voice_resolved"
                  ],
                  "title": "SettingsAck",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Change a thread's settings",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/speech/stop": {
      "post": {
        "description": "Stops the thread's running read-alouds (a message spoken on request, or a reply read aloud as it streams); `stopped` counts them, 0 when nothing was playing. A thread the caller cannot reach is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_speech_stop",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/speech/stop`'s answer.",
                  "properties": {
                    "ok": {
                      "description": "Always `true`.",
                      "type": "boolean"
                    },
                    "stopped": {
                      "description": "How many read-alouds of the thread were running and are stopped; `0`\nwhen none ran.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "ok",
                    "stopped"
                  ],
                  "title": "SpeechStopped",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Stop a thread's read-aloud",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/tasks": {
      "get": {
        "description": "The thread's MCP tasks still running or waiting to enter it, oldest first, as GET /chat/api/threads/{id} lists them as `tasks` (ThreadTask), without the history: the Chat page's strip re-reads them at mcp.task_poll_interval_s. A thread the caller does not reach is 404 not_found, as everywhere in Chat; a temporary thread has none (an empty list).",
        "operationId": "get_chat_api_threads_id_tasks",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ThreadTask"
                  },
                  "title": "Array_of_ThreadTask",
                  "type": "array"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List a thread's jobs",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/threads/{id}/tasks/{task}/cancel": {
      "post": {
        "description": "Cancels task {task} (ThreadTask.id, the feed's task.started id) of the thread: lmgw sends tasks/cancel. The answer is the task as the cancel left it, whether its result is in the thread now, and what happened: the server cancelled it (its result says `cancelled by <who>`), it finished before the cancel (its real result), or the server was not connected (it ends cancelled at once and the server is told when it connects), or the server was asked and has not ended it yet (it is followed until it says it ended). The body is ignored. A thread the caller does not reach is 404 not_found; a task of another thread, or one whose result entered the thread already (it is gone then), 404 task_not_found; one that ended and whose result waits to enter the thread 409 task_ended; a server that does not declare tasks.cancel 409 task_cancel_unsupported, one that answers the cancel with an error 502 task_cancel_refused — the task goes on in both. Deleting the thread cancels its running tasks too.",
        "operationId": "post_chat_api_threads_id_tasks_task_cancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/tasks/{task}/cancel`'s answer.",
                  "properties": {
                    "delivered": {
                      "description": "Its result is in the thread now (a message of role `tool`); `false`\nwhile it waits for a turn that runs, or while the server has not\nended the task yet.",
                      "type": "boolean"
                    },
                    "note": {
                      "description": "What happened, in a sentence.",
                      "type": "string"
                    },
                    "task": {
                      "$ref": "#/components/schemas/ThreadTask",
                      "description": "The task as the cancel left it."
                    }
                  },
                  "required": [
                    "task",
                    "delivered",
                    "note"
                  ],
                  "title": "TaskCancelled",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Cancel a thread's job",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/title": {
      "post": {
        "description": "Sets the thread's title, trimmed, and answers the thread as the list carries it. The change reaches every client as a thread.updated event. A thread named this way keeps its title: the first send names only a thread still called \"New chat\". An empty title is a 400 bad_request. A temporary thread has no stored title to set until it is kept: 409 temporary_thread. A thread the caller cannot reach is a 404 not_found.",
        "operationId": "post_chat_api_threads_id_title",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/threads/{id}/title`'s body.",
                "properties": {
                  "title": {
                    "description": "The new title. Trimmed; empty after that is a 400. A thread named\nthis way is never named again by its first send.",
                    "type": "string"
                  }
                },
                "required": [
                  "title"
                ],
                "title": "TitleRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "One Chat thread with what an open thread shows: its list row, what its\nvoice resolves to now, and (where it is read whole) whether its last\nreply can be continued.",
                  "properties": {
                    "agent_id": {
                      "description": "The agent the thread was opened from, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "archived_at": {
                      "description": "When the thread was archived; `null` while it is active.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continue": {
                      "$ref": "#/components/schemas/ContinueState",
                      "description": "Whether the last reply can be continued. Present where the thread\nis read whole, as `POST /chat/api/folders/{id}/current` answers it."
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "folder_id": {
                      "description": "The folder the thread is in; `null` for none.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "frequency_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Negative for a temporary thread.",
                      "format": "int64",
                      "type": "integer"
                    },
                    "kb_budget_tokens": {
                      "description": "The retrieval budget of `auto` mode in tokens; `null` for the Chat's\nsetting.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "kb_ids": {
                      "description": "Knowledge bases the thread searches, by id.",
                      "items": {
                        "format": "int64",
                        "type": "integer"
                      },
                      "type": "array"
                    },
                    "kb_mode": {
                      "$ref": "#/components/schemas/KbMode"
                    },
                    "kind": {
                      "description": "`chat`, or `admin` for a thread that drives the gateway's own\nconfiguration (never listed for a device key).",
                      "type": "string"
                    },
                    "last_message_at": {
                      "description": "When its newest message was written, in unix seconds; `null` for a\nthread without messages. An ongoing folder's idle rollover is\nmeasured from it: a client that shows when the conversation moves\non reads it here rather than timing the turns it saw.",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "max_tokens": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "mcp_tools": {
                      "description": "The tool servers the thread's turns use; empty for a plain chat. A\nthread with `lmgw` (the self-admin toolset) among them is listed for a\ndevice key only when the device may use lmgw's admin tools.",
                      "items": {
                        "$ref": "#/components/schemas/ThreadMcp"
                      },
                      "type": "array"
                    },
                    "media_defaults": {
                      "$ref": "#/components/schemas/MediaDefaults",
                      "description": "The thread's own default models of the image and audio tools; an\nabsent field inherits its folder's, then Settings → Chat's, and an\nempty one is no default (`GET /chat/api/media/defaults` says what\nthey resolve to)."
                    },
                    "min_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "model_alias": {
                      "description": "The alias the thread's turns go to.",
                      "type": "string"
                    },
                    "pinned": {
                      "description": "Pinned threads are listed first and are never archived or deleted\nby the sweep.",
                      "type": "boolean"
                    },
                    "presence_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "profile_id": {
                      "description": "The personality profile the thread talks with\n(`GET /chat/api/profiles`); `null` for none (\"Default\").",
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "purge_at": {
                      "description": "When an archived thread will be deleted; `null` while it is active,\npinned, or when deleting is switched off.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_budget": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reasoning_effort": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_enabled": {
                      "description": "Reasoning overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "repeat_penalty": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "seed": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "stop": {
                      "description": "Stop sequences; empty leaves the route's default.",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "system_prompt": {
                      "type": "string"
                    },
                    "temperature": {
                      "description": "Sampling overrides sent with every turn; `null` leaves the route's\ndefault.",
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "temporary": {
                      "description": "The thread lives in memory only and is gone at the gateway's next\nstart unless it is kept.",
                      "type": "boolean"
                    },
                    "title": {
                      "type": "string"
                    },
                    "top_k": {
                      "format": "int64",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "top_p": {
                      "format": "double",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "updated_at": {
                      "description": "Moves with every change to the thread and every new message.",
                      "type": "string"
                    },
                    "voice": {
                      "$ref": "#/components/schemas/ThreadVoice"
                    },
                    "voice_resolved": {
                      "$ref": "#/components/schemas/VoiceResolved",
                      "description": "What the thread's voice resolves to now, field by field with the\nlevel each value comes from (the thread, the Chat's settings, the\nrealtime settings): the speech-to-text and text-to-speech stages\n(`asr`, `tts`: alias, whether it runs on this machine, what answers\nfor it while the GPU is held), `voice`, `speech_style`, `language`,\n`reply_language`, `read_aloud`, `turn_detection`, `audio_input`,\n`seed`, the `problems` that block a voice feature now, and\n`realtime`: whether voice mode can bind the thread."
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "model_alias",
                    "system_prompt",
                    "temperature",
                    "max_tokens",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "stop",
                    "kind",
                    "mcp_tools",
                    "reasoning_enabled",
                    "reasoning_effort",
                    "reasoning_budget",
                    "agent_id",
                    "pinned",
                    "archived_at",
                    "folder_id",
                    "profile_id",
                    "kb_ids",
                    "kb_mode",
                    "kb_budget_tokens",
                    "voice",
                    "media_defaults",
                    "created_at",
                    "updated_at",
                    "last_message_at",
                    "purge_at",
                    "temporary",
                    "voice_resolved"
                  ],
                  "title": "Thread",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Rename a thread",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/transcribe": {
      "post": {
        "description": "The body is a recording, its container named by Content-Type: audio/wav (also audio/wave, audio/x-wav, audio/vnd.wave, none, application/octet-stream), audio/webm, audio/ogg (audio/opus), audio/mpeg (audio/mp3), audio/mp4 (audio/m4a, audio/x-m4a) or audio/flac (audio/x-flac); another is 415 unsupported_media_type. It is transcribed by the thread's speech-to-text model and written nowhere: dictation, and a spoken answer to an approval, which must stay out of the conversation (a new message declines a waiting call). The answer names the alias, the one that answered in its place (a GPU-hold or outside-VRAM fallback, also in x-lmgw-fallback), the call's time, the recording's length (WAV only) and the language heard. The body is bounded by max_body_mb (413 body_limit naming it). 400 empty_audio, 422 asr_not_configured, 503 gpu_hold, and a device key's own refusals. A failure of the transcription itself names the fallback that had the audio in x-lmgw-fallback: the audio may have left this machine although nothing came back.",
        "operationId": "post_chat_api_threads_id_transcribe",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "audio/wav": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /chat/api/threads/{id}/transcribe`'s answer (chat-voice design\n§5): a recording transcribed by the thread's speech-to-text model —\ndictation, and a voice answer to an approval that must stay out of the\nconversation (client-apps design §6.4).",
                  "properties": {
                    "alias": {
                      "description": "The speech-to-text alias the thread resolves to.",
                      "type": "string"
                    },
                    "asr_answered_by": {
                      "description": "The alias that answered in its place (a GPU-hold or outside-VRAM\nfallback); `null` when it answered itself.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "asr_ms": {
                      "description": "The transcription call, admission included.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "audio_ms": {
                      "description": "The recording's length, from its WAV header; `null` for any other\ncontainer.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "language": {
                      "description": "What the model says it heard, in its own spelling, else the language\nthe thread's user speaks; `null` when neither is known.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "text",
                    "alias",
                    "asr_answered_by",
                    "asr_ms",
                    "audio_ms",
                    "language"
                  ],
                  "title": "Dictation",
                  "type": "object"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Transcribe a recording",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/threads/{id}/voice/warm": {
      "post": {
        "description": "A press of the microphone (or the start of a call) warms the models the voice turn will use before the request it announces. `stages` names them (asr, tts, chat: the thread's own model), each once; they are the thread's resolved aliases, warmed as one group through the request admission, so the warm may evict idle models exactly as the request would, and a group that does not fit together is warmed without evicting. The stream sends one `state` frame per change of each stage (loading, then ready with the time it took, or held, fallback, skipped, failed), then `done` with no fields once every stage has settled. A device or owner key that is disabled, rotated, deleted or expired while it streams, and a gateway that stops, end the stream with an `error` frame (code revoked, with `kind`, or gateway_stopping) instead of `done`. Closing the stream drops what still waits for admission; a container start already in flight finishes. Refused before anything is warmed: 404 not_found, 400 bad_request (no stages, or an unknown name), 422 asr_not_configured or tts_not_configured (no alias for the stage at any level), and, for a device key, its own refusal (scope, budget) for a stage whose alias it may not use — nothing starts then.",
        "operationId": "post_chat_api_threads_id_voice_warm",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /chat/api/threads/{id}/voice/warm`'s body. Unknown fields are\nrefused.",
                "properties": {
                  "stages": {
                    "description": "The stages to warm, each named once and in this order: `asr`, `tts`\nand `chat` (the thread's own model). Empty or an unknown name is\n400 bad_request.",
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "stages"
                ],
                "title": "WarmRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "done": {
                "additionalProperties": false,
                "description": "`done` of a voice warm-up: every stage has settled. No fields.",
                "title": "WarmDone",
                "type": "object"
              },
              "error": {
                "description": "`error`: something went wrong; the stream goes on to `done`. `code` is\nwhat a client branches on (`gpu_hold`, `context_length_exceeded`,\n`vram_queue_timeout`, `not_saved`, `superseded`, ...); a failure that has\nnone sends only the message. A stream whose key was disabled, rotated,\ndeleted or expired, or whose gateway stops, ends with a last `error`\nframe instead of `done`: `revoked` (with `kind`) or `gateway_stopping`.\nAn MCP label the thread or its folder attached that offers the turn no\ntools gets one frame each, with `server_label` and a `LabelCode`\n(`tool_unreachable`, `tool_offline`, `tool_disabled`, `tool_unknown`,\n`tool_failed`), and the turn goes on without it.",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/RevokeKind",
                    "description": "What a client does about a `revoked` frame, the token a realtime\nsession's 4003 close starts its reason with (`key_unknown` means pair\nthe device again). Sent with `revoked` only."
                  },
                  "message": {
                    "type": "string"
                  },
                  "server_label": {
                    "description": "The MCP label the frame is about, as the thread or folder attached\nit; sent with a `LabelCode` only.",
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "title": "ErrorFrame",
                "type": "object"
              },
              "state": {
                "description": "A voice stage's model state: a chat stream's `state` frame and a bound\nrealtime session's `lmgw.model.state` event.\nRead leniently: a field a client does not know of is ignored, a missing\none is empty. Written as the gateway sends it: `ms` always, the other\noptional facts only when the state has them.",
                "properties": {
                  "alias": {
                    "type": "string"
                  },
                  "answered_by": {
                    "description": "`fallback`: the alias that answers in its place.",
                    "type": "string"
                  },
                  "capacity_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the group could have together,\nin bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "cause": {
                    "description": "`held`: `gpu_hold` or `benchmark`.",
                    "type": "string"
                  },
                  "done_bytes": {
                    "description": "`downloading`: compressed bytes downloaded so far.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "image": {
                    "description": "`downloading`: the image the model runs in, being downloaded before\nits first start (machine-check design §5). A client says the\ndownload in plain words; the reference is a detail.",
                    "type": "string"
                  },
                  "message": {
                    "description": "The sentence a client shows.",
                    "type": "string"
                  },
                  "ms": {
                    "description": "How long the load took, for `ready`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "needed_bytes": {
                    "description": "`skipped` with `does_not_fit`: what the stage's group needs on the\ncard, in bytes.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "description": "`skipped`: `full`, `does_not_fit` or `cannot_speak`.",
                    "type": "string"
                  },
                  "size_note": {
                    "description": "`downloading`: why the size is not known, when it is not.",
                    "type": "string"
                  },
                  "stage": {
                    "description": "`asr`, `chat` or `tts`.",
                    "type": "string"
                  },
                  "state": {
                    "description": "`loading`, `downloading`, `ready`, `held`, `fallback`, `skipped` or\n`failed`.",
                    "type": "string"
                  },
                  "total_bytes": {
                    "description": "`downloading`: the download's whole size; absent while it is not\nknown.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "stage",
                  "alias",
                  "state",
                  "ms"
                ],
                "title": "ModelState",
                "type": "object"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Warm a thread's speech models",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/chat/api/tools": {
      "get": {
        "description": "For a thread's tool picker: lmgw's built-in toolsets first (lmgw, docs, kb, image, audio, in that order), each with its tools, then the registered MCP servers and service agents by label, each with its connection's status and how many of its tools, as last listed, the caller may tick. Connects nothing; GET /chat/api/tools/{label} lists a server's tools. Under the caller's tool scope: the owner is listed every built-in toolset, one that offers nothing now with the reason (status unavailable), and every enabled server; a device key is listed what GET /v1/mcp/servers lists it — the toolsets that offer it tools and the enabled servers its scope reaches — and the self-admin toolset (lmgw) only while its admin tools are at full, since below that a device uses the threads that carry it and attaches it to none. A tool the owner switched off is never listed or counted.",
        "operationId": "get_chat_api_tools",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/tools`: the toolsets the caller may attach to a thread,\nfor the Chat's tool picker. Built-in toolsets first, in a fixed order,\nthen the registered servers and service agents by label.",
                  "properties": {
                    "sources": {
                      "items": {
                        "$ref": "#/components/schemas/ChatToolSource"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "sources"
                  ],
                  "title": "ChatToolList",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List the toolsets a thread may attach",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/chat/api/tools/{label}": {
      "get": {
        "description": "The tools a thread attaching `label` alone gets, under their exposed names (the spelling a thread's allowed_tools and require_approval store), the owner's switched-off tools and those outside the caller's tool scope left out — the same resolution a turn runs. Connects that one server when it is not up, but starts no service agent: one whose app is not running is a 502 mcp_list_tools_failed saying so, and a turn that attaches it starts it. A label the caller may not attach (unknown, disabled, outside its scope, or lmgw for a device below full) is a 404 not_found in the resolver's words; a server that cannot be listed a 502 mcp_list_tools_failed.",
        "operationId": "get_chat_api_tools_label",
        "parameters": [
          {
            "in": "path",
            "name": "label",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /chat/api/tools/{label}`: one toolset's tools the caller may tick.",
                  "properties": {
                    "server_label": {
                      "type": "string"
                    },
                    "tools": {
                      "items": {
                        "$ref": "#/components/schemas/ChatTool"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "server_label",
                    "tools"
                  ],
                  "title": "ChatToolDetail",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List one toolset's tools",
        "tags": [
          "chat"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/devices/enrol": {
      "post": {
        "description": "A device sends the pairing link's one-time token with its public key (an EC P-256 key as its DER SubjectPublicKeyInfo, standard base64) and the client it is, over TLS 1.3 pinned to the link's fp and without a client certificate (one presented anyway, and any credential header, is ignored: the token decides). It gets its certificate (clientAuth, for that key, valid devices.client_cert_days), lmgw's device CA, the dates, its URLs and the confirmation code of its key, 201 Created. Every request of the device is then refused 403 device_unconfirmed until the owner confirms that code on the Devices card. The same key presenting the same token again while it lives (devices.token_minutes from its minting, unless the owner ended it) gets the same answer; another key gets 410 pairing_token_used and the device is marked contested. Refusals: 400 bad_request (not this shape), 400 public_key_unsupported (not a canonical EC P-256 SubjectPublicKeyInfo), 401 pairing_token_unknown, 401 device_disabled (the token stays unused), 409 public_key_in_use (another device enrolled the key), 410 pairing_token_used, 410 pairing_token_expired (lapsed or ended; the message says which and names devices.token_minutes), 413 body_too_large (over 16 KiB), 429 pairing_rate_limited with Retry-After (failed enrolments from the address, an IPv6 address by its /64, past devices.enrol_refuse_per_min in a minute), 503 devices_ca_unavailable. Served on the device listener only: the plain listener answers it 404. While no token lives, the device listener's handshake requires a client certificate, so a device without one meets the TLS alert certificate_required instead (lmgw-client: this pairing link has ended).",
        "operationId": "post_devices_enrol",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /devices/enrol`'s body.",
                "properties": {
                  "app_id": {
                    "description": "The app this install is, as a lowercase reverse-DNS name\n(`dev.example.storyplayer`, `transfer::APP_ID_RULE`):\nwhat other devices of the same app offer files to (device transfers\ndesign §2). Optional; a device without one receives no transfer. A\nmalformed one is refused 400 `bad_request` before the token is used.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "client": {
                    "description": "Free text naming the client, shown on the Devices card\n(\"Kai mobile 0.1.0 (Android 16)\"). Optional, and never trusted for\nanything.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "device_name": {
                    "description": "The device's own name, as its user chose it on the device (\"Anna's\nphone\"): free text, shown on the Devices card beside the name the\nowner gave the link (*added 2026-10-23*). Named `device_name` here,\nas the card's field is, because the answer's `device.name` is the\nowner's name for the link. Optional, and never trusted for anything.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "public_key": {
                    "description": "The device's public key: standard base64 (RFC 4648 §4, padded) of its\nDER SubjectPublicKeyInfo, an EC P-256 key.",
                    "type": "string"
                  },
                  "token": {
                    "description": "The link's `token`: `lmgw-enrol-` and 32 lowercase hex digits. Secret\nuntil used.",
                    "type": "string",
                    "x-lmgw-secret": true
                  }
                },
                "required": [
                  "token",
                  "public_key"
                ],
                "title": "EnrolRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`POST /devices/enrol`'s `201 Created`: the device's certificate for the\nkey it sent, and what it keeps beside it. The same key presenting the\nsame used token again within its life gets this answer again (§3.3).",
                  "properties": {
                    "ca_certificate": {
                      "description": "lmgw's device CA certificate: standard base64 of its DER. Its\nSubjectPublicKeyInfo hashes to the link's `fp`; a client keeps it only\nthen.",
                      "type": "string"
                    },
                    "certificate": {
                      "description": "The device's certificate: standard base64 of its DER. `clientAuth`\nonly, issued by the device CA for the key the body sent.",
                      "type": "string"
                    },
                    "confirm_code": {
                      "description": "The confirmation code (`confirm_code`): the device shows it, and\nthe owner confirms the same code on the Devices card (§3.5).",
                      "type": "string"
                    },
                    "confirmed": {
                      "description": "Whether the owner confirmed this enrolment already (an answer asked\nagain after the Confirm). Until then every request of the device is\nrefused 403 `code::DEVICE_UNCONFIRMED`.",
                      "type": "boolean"
                    },
                    "device": {
                      "$ref": "#/components/schemas/EnrolledDevice",
                      "description": "The device row the token belongs to."
                    },
                    "not_after": {
                      "description": "When the certificate lapses (RFC 3339, UTC).",
                      "type": "string"
                    },
                    "notice_after": {
                      "description": "From when the client says \"this device's certificate lapses on\n`<date>`; pair it again before then\": the issue plus two thirds of the\nvalidity (RFC 3339, UTC; §2.3).",
                      "type": "string"
                    },
                    "urls": {
                      "description": "The device's lmgw URLs, `https`, in the owner's order (§3.1).",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "device",
                    "certificate",
                    "ca_certificate",
                    "not_after",
                    "notice_after",
                    "urls",
                    "confirm_code",
                    "confirmed"
                  ],
                  "title": "Enrolment",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {}
        ],
        "summary": "Enrol a device's key with a pairing token",
        "tags": [
          "devices"
        ],
        "x-lmgw-capability": "public",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/mcp": {
      "delete": {
        "description": "Ends a session.",
        "operationId": "delete_mcp",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          },
          {
            "description": "MCP Streamable HTTP requires the client accept both JSON and server-sent events.",
            "example": "application/json, text/event-stream",
            "in": "header",
            "name": "Accept",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-prefill": true
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "End an MCP session",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "jsonrpc",
        "x-lmgw-writes": true
      },
      "get": {
        "description": "Opens the server→client notification stream for a valid session (a session-less GET is 400/404): pushes notifications/tools/list_changed and notifications/resources/list_changed when the aggregate's composition changes, and notifications/resources/list_changed when a server says its resources changed. The stream ends, without a frame (MCP has no notification for it), when the API key that opened it is disabled, rotated, deleted or expires.",
        "operationId": "get_mcp",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          },
          {
            "description": "MCP Streamable HTTP requires the client accept both JSON and server-sent events.",
            "example": "application/json, text/event-stream",
            "in": "header",
            "name": "Accept",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-prefill": true
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "An event stream.",
            "x-lmgw-sse-events": {
              "notification": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Open the MCP notification stream",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "jsonrpc",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "MCP Streamable HTTP: single JSON-RPC request/notification/response per POST, no batching. initialize negotiates MCP-Protocol-Version and assigns Mcp-Session-Id, which every later request on the session must carry; a notification answers 202 with no body. tools/list and tools/call reach the registered southbound MCP servers' tools, namespaced <prefix>__. resources/list, resources/templates/list (one page; a cursor is -32602) and resources/read pass their resources through, a prefixed server's URIs namespaced before the authority (ui://weather/card from prefix p is ui://p__weather/card) — in tools' _meta.ui.resourceUri and in tool results' resource links too; a read of a URI no server has, or of a server the caller's tool scope does not reach, is -32002. initialize advertises resources {listChanged} and the MCP Apps extension io.modelcontextprotocol/ui (mimeTypes [text/html;profile=mcp-app]); every tool is listed with its _meta, and app-only ones (_meta.ui.visibility without \"model\") only to a session whose initialize declared that extension. Every tool of a registered server also carries _meta[\"lmgw/server\"] {label, name, tool}: the server's label (its tool prefix, else its name), its name, and the tool's name as the server lists it — so a host routes a view's call of its server's tool to the listed name, also one a name collision moved to <server name>__<tool> or the owner renamed; lmgw sets it, replacing anything the server put there.",
        "operationId": "post_mcp",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          },
          {
            "description": "MCP Streamable HTTP requires the client accept both JSON and server-sent events.",
            "example": "application/json, text/event-stream",
            "in": "header",
            "name": "Accept",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-prefill": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest",
                "example": {
                  "id": 1,
                  "jsonrpc": "2.0",
                  "method": "initialize",
                  "params": {
                    "capabilities": {},
                    "clientInfo": {
                      "name": "example-client",
                      "version": "0.1.0"
                    },
                    "protocolVersion": "2025-11-25"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Call the aggregate MCP endpoint",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "jsonrpc",
        "x-lmgw-writes": true
      }
    },
    "/mcp/host": {
      "get": {
        "description": "A paired device offers its own MCP server over this WebSocket, and lmgw lists its tools under the device's hosting label (<label>__<tool>) while the link is open, as it lists a registered server's. Needs a device key with a hosting grant (403 host_not_granted otherwise) and no Origin header (403 cross_origin_refused: a browser page never hosts tools). Every tools/call lmgw forwards carries _meta with lmgw/caller ({kind: owner | gateway | device | key | agent, name}: who the call runs as), lmgw/approval (null, or {decision: approved, by}) and lmgw/timeout_ms (the row's timeout_ms, when lmgw stops waiting). lmgw sends notifications/cancelled {requestId, reason} for every call it stops waiting on: at the timeout, when its caller stops waiting, and before it closes the link. Tasks (MCP 2025-11-25): a tool whose execution.taskSupport is required, on a device that declares capabilities.tasks.requests.tools.call, is called with task: {} and _meta lmgw/task ({delivery: thread | wait, thread_id}); lmgw/timeout_ms then bounds the wait for the CreateTaskResult only. lmgw follows the task with tasks/get at its pollInterval (else mcp.task_poll_interval_s), acts on notifications/tasks/status, fetches tasks/result, and sends tasks/cancel (never notifications/cancelled) for a task; a link drop ends no task, and -32602 for its id ends it abandoned. A device's notifications/tools/list_changed makes lmgw list again. Sampling requests are refused -32601. Pings every mcp.host_ping_interval_s seconds; a missed pong closes 1011 naming the setting. A frame or message over mcp.host_max_frame_mb / mcp.host_max_message_mb closes 1009 naming the setting; a binary frame, a batch or text that is no JSON-RPC message closes 1002. A second link of the same device takes over: the older one closes 4000 (\"another connection of device '<name>' took over\"). The key's revocation closes 4003 with the realtime session's token and sentence (device_disabled, key_expired, key_unknown); the hosting grant cleared or the row switched off closes 1000; a stopping gateway closes 1001. Who may call the hosted tools: the owner, the gateway's own runs, the device itself, keys and devices whose policy's device_tools grants the label (their tool scope then filtering its tools as any server's), and agents whose manifest names it — never an anonymous caller, and never a key through its tool scope alone.",
        "operationId": "get_mcp_host",
        "responses": {
          "101": {
            "description": "Switching Protocols: the connection is now a WebSocket. Each frame is one JSON-RPC 2.0 message as text, no batches. The roles are reversed at the message level: lmgw is the MCP client and the device the server. lmgw sends initialize, the device answers, lmgw sends notifications/initialized and pages through tools/list."
          },
          "426": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Upgrade Required: the request carried no WebSocket upgrade headers."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error, before the upgrade."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Host a device's MCP tools",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "chat",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/tokenize": {
      "post": {
        "description": "llama.cpp's own /tokenize, for llama.cpp clients: the client object is forwarded to the backend's own /tokenize with model rewritten, and the answer — token ids, or {id,piece} with with_pieces — comes back verbatim, the backend's own errors included (but an upstream 401/403 is a 502: that is lmgw's credential). The body is read as JSON whatever its Content-Type, as llama-server reads it. 501 not_supported_error on any backend that is not a real llama-server: an id from a tokenizer the backend does not run would be a hidden approximation. Enforces the key's alias scope (a logged 403 key_scope); no budget applies. Errors are llama.cpp-shaped, except the shared /v1 layers' own: the gate's 401, 403 and 429, and the 413 for a declared Content-Length over max_body_mb, which are OpenAI-shaped.",
        "operationId": "post_tokenize",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenizeRequest",
                "example": {
                  "content": "Hello, world!",
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenizeResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlamaCppError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Tokenize text",
        "tags": [
          "llamacpp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "llamacpp",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/transfers/api/targets": {
      "get": {
        "description": "A device's: its other devices that declared app_id at pairing and can receive now (enabled, confirmed, not past their key's expiry), never itself, each with whether it holds its Chat feed open (online) and when it was last seen; with free_bytes, the largest offer lmgw takes now (the free space of its data directory less what uploads in progress still need, the only size bound), and expiry_days, how long an offer made now lasts (devices.transfer_expiry_days). 400 bad_request for an app_id that is no lowercase reverse-DNS name; 403 transfer_device_only for the owner.",
        "operationId": "get_transfers_api_targets",
        "parameters": [
          {
            "in": "query",
            "name": "app_id",
            "required": true,
            "schema": {
              "description": "The app id the offer will name (`APP_ID_RULE`).",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /transfers/api/targets`' answer.",
                  "properties": {
                    "expiry_days": {
                      "description": "Days an offer made now lasts (`devices.transfer_expiry_days`).",
                      "format": "uint32",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "free_bytes": {
                      "description": "The largest offer lmgw takes now, in bytes: the data directory's\nfree space less what the uploads in progress still need. The only\nsize bound there is.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "targets": {
                      "description": "The caller's other devices that declared the app id and can receive\nnow (enabled, confirmed, not expired); never the caller.",
                      "items": {
                        "$ref": "#/components/schemas/Target"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "targets",
                    "free_bytes",
                    "expiry_days"
                  ],
                  "title": "Targets",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Who this device can offer a file to",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/transfers/api/transfers": {
      "get": {
        "description": "Newest first, the ended ones included for chat_feed_retention_days after they ended. A device lists its outgoing ones (role=outgoing), the incoming ones it was offered (role=incoming, from ready on), or both; the owner every one, without role (400 bad_request with one). A receiver lists its pending offers at its start and follows the Chat feed's transfer.updated for the rest. stored_bytes is what the files of transfers in progress hold, free_bytes the largest offer lmgw takes now.",
        "operationId": "get_transfers_api_transfers",
        "parameters": [
          {
            "in": "query",
            "name": "role",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/TransferRole"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "description": "A device's: only its incoming or its outgoing transfers; both\nwithout. The owner is no party, and is refused one."
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`GET /transfers/api/transfers`' answer.",
                  "properties": {
                    "free_bytes": {
                      "description": "The largest offer lmgw takes now (`Targets::free_bytes`).",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "stored_bytes": {
                      "description": "Bytes the files of the transfers in progress hold on disk now.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "transfers": {
                      "description": "Newest first, the ended ones included for as long as\n`chat_feed_retention_days` keeps them.",
                      "items": {
                        "$ref": "#/components/schemas/Transfer"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "transfers",
                    "stored_bytes",
                    "free_bytes"
                  ],
                  "title": "TransferList",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "List transfers",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "post": {
        "description": "A device offers a file to to_device, a target for app_id: 201 Created with the transfer, uploading and nothing received; upload its bytes next. The receiver does not see it until every byte is there and matched sha256. It lasts devices.transfer_expiry_days (expires_at). 400 bad_request for a malformed field (kind required, filename without '/', '\\' or control characters, size at least 1, sha256 64 lowercase hex digits), 403 transfer_device_only for the owner, 413 body_too_large over 16 KiB, 422 transfer_target_invalid when to_device is no target for app_id (the message says which part failed), 507 transfer_storage_full with free_bytes when size is above the space left for new offers. A sender disabled or deleted while its offer was read is answered as the device listener answers its next request: 401 device_disabled or 401 device_key_unknown.",
        "operationId": "post_transfers_api_transfers",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "`POST /transfers/api/transfers`' body.",
                "properties": {
                  "app_id": {
                    "description": "The app id the receiver declared (`APP_ID_RULE`).",
                    "type": "string"
                  },
                  "filename": {
                    "description": "The receiver's name for the file: no `/`, `\\`, control or invisible\ncharacters, not `.` or `..`.",
                    "type": "string"
                  },
                  "kind": {
                    "description": "The app's own word for what the file is (required; no control or\ninvisible characters).",
                    "type": "string"
                  },
                  "sha256": {
                    "description": "The file's sha256: 64 lowercase hex digits.",
                    "type": "string"
                  },
                  "size": {
                    "description": "The file's size in bytes: at least 1, at most `free_bytes`.",
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "title": {
                    "default": "",
                    "description": "What the card and the receiver show (may be empty).",
                    "type": "string"
                  },
                  "to_device": {
                    "description": "The receiver: a target's `device_id` for `app_id`.",
                    "format": "int64",
                    "type": "integer"
                  }
                },
                "required": [
                  "to_device",
                  "app_id",
                  "kind",
                  "filename",
                  "size",
                  "sha256"
                ],
                "title": "TransferCreate",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A transfer, as every route and `transfer.updated` answer it.",
                  "properties": {
                    "app_id": {
                      "description": "The app id the offer names; the receiver declared it at pairing.",
                      "type": "string"
                    },
                    "created_at": {
                      "description": "RFC 3339 UTC.",
                      "type": "string"
                    },
                    "end_reason": {
                      "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ended_at": {
                      "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "expires_at": {
                      "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                      "type": "string"
                    },
                    "filename": {
                      "description": "The receiver's name for the file.",
                      "type": "string"
                    },
                    "from": {
                      "$ref": "#/components/schemas/TransferParty"
                    },
                    "id": {
                      "description": "Opaque: 32 random lowercase hex digits.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "The app's own word for what the file is.",
                      "type": "string"
                    },
                    "received": {
                      "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "sha256": {
                      "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                      "type": "string"
                    },
                    "size": {
                      "description": "The file's size in bytes.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState"
                    },
                    "title": {
                      "description": "What the card and the receiver show; may be empty.",
                      "type": "string"
                    },
                    "to": {
                      "$ref": "#/components/schemas/TransferParty"
                    }
                  },
                  "required": [
                    "id",
                    "app_id",
                    "kind",
                    "title",
                    "filename",
                    "size",
                    "sha256",
                    "from",
                    "to",
                    "state",
                    "received",
                    "created_at",
                    "expires_at",
                    "ended_at",
                    "end_reason"
                  ],
                  "title": "Transfer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "507": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Offer a file to another device",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/transfers/api/transfers/{id}": {
      "get": {
        "description": "The transfer as it is now: while it uploads, received is the resume point (the bytes lmgw holds, which the next upload's range starts at). 404 transfer_not_found for no such transfer and for a device that is neither its sender nor its receiver (a receiver lists it and hears of it from ready on, and reads it by id from the offer on).",
        "operationId": "get_transfers_api_transfers_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A transfer, as every route and `transfer.updated` answer it.",
                  "properties": {
                    "app_id": {
                      "description": "The app id the offer names; the receiver declared it at pairing.",
                      "type": "string"
                    },
                    "created_at": {
                      "description": "RFC 3339 UTC.",
                      "type": "string"
                    },
                    "end_reason": {
                      "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ended_at": {
                      "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "expires_at": {
                      "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                      "type": "string"
                    },
                    "filename": {
                      "description": "The receiver's name for the file.",
                      "type": "string"
                    },
                    "from": {
                      "$ref": "#/components/schemas/TransferParty"
                    },
                    "id": {
                      "description": "Opaque: 32 random lowercase hex digits.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "The app's own word for what the file is.",
                      "type": "string"
                    },
                    "received": {
                      "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "sha256": {
                      "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                      "type": "string"
                    },
                    "size": {
                      "description": "The file's size in bytes.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState"
                    },
                    "title": {
                      "description": "What the card and the receiver show; may be empty.",
                      "type": "string"
                    },
                    "to": {
                      "$ref": "#/components/schemas/TransferParty"
                    }
                  },
                  "required": [
                    "id",
                    "app_id",
                    "kind",
                    "title",
                    "filename",
                    "size",
                    "sha256",
                    "from",
                    "to",
                    "state",
                    "received",
                    "created_at",
                    "expires_at",
                    "ended_at",
                    "end_reason"
                  ],
                  "title": "Transfer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Read a transfer",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      }
    },
    "/transfers/api/transfers/{id}/cancel": {
      "post": {
        "description": "The sender's and the owner's, while the transfer is uploading or ready: it is canceled, an upload in progress stops (answered 409 transfer_state, canceled), a download in progress breaks off, lmgw deletes its bytes, and both devices hear it on the feed. 404 transfer_not_found for any other device; 409 transfer_state with state once it ended.",
        "operationId": "post_transfers_api_transfers_id_cancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A transfer, as every route and `transfer.updated` answer it.",
                  "properties": {
                    "app_id": {
                      "description": "The app id the offer names; the receiver declared it at pairing.",
                      "type": "string"
                    },
                    "created_at": {
                      "description": "RFC 3339 UTC.",
                      "type": "string"
                    },
                    "end_reason": {
                      "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ended_at": {
                      "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "expires_at": {
                      "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                      "type": "string"
                    },
                    "filename": {
                      "description": "The receiver's name for the file.",
                      "type": "string"
                    },
                    "from": {
                      "$ref": "#/components/schemas/TransferParty"
                    },
                    "id": {
                      "description": "Opaque: 32 random lowercase hex digits.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "The app's own word for what the file is.",
                      "type": "string"
                    },
                    "received": {
                      "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "sha256": {
                      "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                      "type": "string"
                    },
                    "size": {
                      "description": "The file's size in bytes.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState"
                    },
                    "title": {
                      "description": "What the card and the receiver show; may be empty.",
                      "type": "string"
                    },
                    "to": {
                      "$ref": "#/components/schemas/TransferParty"
                    }
                  },
                  "required": [
                    "id",
                    "app_id",
                    "kind",
                    "title",
                    "filename",
                    "size",
                    "sha256",
                    "from",
                    "to",
                    "state",
                    "received",
                    "created_at",
                    "expires_at",
                    "ended_at",
                    "end_reason"
                  ],
                  "title": "Transfer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Cancel a transfer",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-confirm-note": "The transfer ends and lmgw deletes its bytes.",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/transfers/api/transfers/{id}/content": {
      "get": {
        "description": "The receiver's, while the transfer is ready: the file, streamed from lmgw's disk, with Accept-Ranges: bytes, ETag \"sha256:<hex>\" and Content-Disposition naming its filename. One Range (bytes=a-b, bytes=a- or bytes=-n) answers 206 with Content-Range; If-Range with the ETag serves the range, with anything else the whole file. A Range lmgw does not read (another unit, several ranges, an invalid one) is ignored: the whole file, 200. 416 range_not_satisfiable, with Content-Range: bytes */size, for a range that names no byte of the file (it starts at or past the end, or asks the last 0 bytes). 404 transfer_not_found but for the receiver; 409 transfer_state with state when it is not ready. A transfer that ends while its bytes stream (a cancel, an expiry, a device's end) breaks the body off short of its length. HEAD answers the same head without the body. After its own hash check the receiver sends …/received.",
        "operationId": "get_transfers_api_transfers_id_content",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "507": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Download a transfer's bytes",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": false
      },
      "put": {
        "description": "The sender's, while the transfer is uploading. Content-Range: bytes a-b/size is required, size the offer's and a the transfer's received; the body is the range's raw bytes (any Content-Type), streamed to lmgw's disk. Chunks are any size; a body that breaks off keeps every byte that arrived, so received (read the transfer) is where to go on. A newer upload of the same transfer stops one still being read. Answers {received, state}; the last byte has the file's sha256 checked: state ready (offered to the receiver), or 422 transfer_hash_mismatch, the transfer failed and its bytes deleted. When lmgw already holds every byte (the last range's answer was lost), any upload of it completes it the same, whatever range it names; Content-Range: bytes */size with no body is the form that asks only that: where the upload stands, and its completion when it is whole. 400 bad_request for a missing or malformed Content-Range, another total, a Content-Length that is not b-a+1, or a body shorter or longer than its range when that was not the last byte (what arrived of the range is kept); 404 transfer_not_found but for the sender; 409 transfer_offset with received when a is not it (or a newer upload stopped this one); 409 transfer_state with state once it is not uploading, also for an upload a cancel, an expiry or a device's end stopped (ready: it is done); 507 transfer_storage_full with free_bytes when the disk filled.",
        "operationId": "put_transfers_api_transfers_id_content",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "`PUT /transfers/api/transfers/{id}/content`'s answer.",
                  "properties": {
                    "received": {
                      "description": "Bytes lmgw holds now: where the next range starts.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`uploading`, or `ready` once the last byte arrived and matched."
                    }
                  },
                  "required": [
                    "received",
                    "state"
                  ],
                  "title": "ContentReceived",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "507": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A `/transfers/api` refusal: the flat `{code, message}` with the extra\nfield its code names (`code`).",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "free_bytes": {
                      "description": "`code::TRANSFER_STORAGE_FULL`'s: the space left for new offers.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "received": {
                      "description": "`code::TRANSFER_OFFSET`'s: the resume point.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState",
                      "description": "`code::TRANSFER_STATE`'s: the state the transfer is in."
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "title": "TransferRefusal",
                  "type": "object"
                }
              }
            },
            "description": "Error, with this body rather than the default one."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Upload a transfer's bytes",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/transfers/api/transfers/{id}/decline": {
      "post": {
        "description": "The receiver's: the transfer is declined and lmgw deletes its bytes; the sender hears it on the feed. 404 transfer_not_found but for the receiver; 409 transfer_state with state when it is not ready.",
        "operationId": "post_transfers_api_transfers_id_decline",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A transfer, as every route and `transfer.updated` answer it.",
                  "properties": {
                    "app_id": {
                      "description": "The app id the offer names; the receiver declared it at pairing.",
                      "type": "string"
                    },
                    "created_at": {
                      "description": "RFC 3339 UTC.",
                      "type": "string"
                    },
                    "end_reason": {
                      "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ended_at": {
                      "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "expires_at": {
                      "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                      "type": "string"
                    },
                    "filename": {
                      "description": "The receiver's name for the file.",
                      "type": "string"
                    },
                    "from": {
                      "$ref": "#/components/schemas/TransferParty"
                    },
                    "id": {
                      "description": "Opaque: 32 random lowercase hex digits.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "The app's own word for what the file is.",
                      "type": "string"
                    },
                    "received": {
                      "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "sha256": {
                      "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                      "type": "string"
                    },
                    "size": {
                      "description": "The file's size in bytes.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState"
                    },
                    "title": {
                      "description": "What the card and the receiver show; may be empty.",
                      "type": "string"
                    },
                    "to": {
                      "$ref": "#/components/schemas/TransferParty"
                    }
                  },
                  "required": [
                    "id",
                    "app_id",
                    "kind",
                    "title",
                    "filename",
                    "size",
                    "sha256",
                    "from",
                    "to",
                    "state",
                    "received",
                    "created_at",
                    "expires_at",
                    "ended_at",
                    "end_reason"
                  ],
                  "title": "Transfer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Decline a transfer",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/transfers/api/transfers/{id}/received": {
      "post": {
        "description": "The receiver's, after its own check of the bytes: the transfer is delivered and lmgw deletes its bytes; the sender hears it on the feed. 404 transfer_not_found but for the receiver; 409 transfer_state with state when it is not ready.",
        "operationId": "post_transfers_api_transfers_id_received",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A transfer, as every route and `transfer.updated` answer it.",
                  "properties": {
                    "app_id": {
                      "description": "The app id the offer names; the receiver declared it at pairing.",
                      "type": "string"
                    },
                    "created_at": {
                      "description": "RFC 3339 UTC.",
                      "type": "string"
                    },
                    "end_reason": {
                      "description": "Why it ended, a sentence for people (\"not delivered within 7 days of\nthe offer\", \"canceled by device 'phone'\"), naming no setting and no\nraw time; `null` while in progress and once delivered. `state` is\nwhat a client acts on.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ended_at": {
                      "description": "When it ended (RFC 3339 UTC); `null` while in progress.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "expires_at": {
                      "description": "When it expires unless delivered first (RFC 3339 UTC):\n`devices.transfer_expiry_days` after the offer.",
                      "type": "string"
                    },
                    "filename": {
                      "description": "The receiver's name for the file.",
                      "type": "string"
                    },
                    "from": {
                      "$ref": "#/components/schemas/TransferParty"
                    },
                    "id": {
                      "description": "Opaque: 32 random lowercase hex digits.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "The app's own word for what the file is.",
                      "type": "string"
                    },
                    "received": {
                      "description": "Bytes lmgw holds: the resume point while `uploading` (the next\nupload's range starts here), `size` from `ready` on, and how far it\ngot for one that ended before.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "sha256": {
                      "description": "The file's sha256, 64 lowercase hex digits; checked when the last\nbyte arrives.",
                      "type": "string"
                    },
                    "size": {
                      "description": "The file's size in bytes.",
                      "format": "uint64",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "state": {
                      "$ref": "#/components/schemas/TransferState"
                    },
                    "title": {
                      "description": "What the card and the receiver show; may be empty.",
                      "type": "string"
                    },
                    "to": {
                      "$ref": "#/components/schemas/TransferParty"
                    }
                  },
                  "required": [
                    "id",
                    "app_id",
                    "kind",
                    "title",
                    "filename",
                    "size",
                    "sha256",
                    "from",
                    "to",
                    "state",
                    "received",
                    "created_at",
                    "expires_at",
                    "ended_at",
                    "end_reason"
                  ],
                  "title": "Transfer",
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          }
        ],
        "summary": "Say a transfer arrived",
        "tags": [
          "transfers"
        ],
        "x-lmgw-capability": "transfer",
        "x-lmgw-dialect": "dashboard",
        "x-lmgw-writes": true
      }
    },
    "/v1/audio/alignments": {
      "post": {
        "description": "Forced alignment against a task: \"align\" row — lmgw's own route, multipart/form-data only. Every family answers the same shape: the words with their seconds, samples where known, and their character span in the submitted text; a model whose answer has no word timings lmgw can read is a 502 naming its family.",
        "operationId": "post_v1_audio_alignments",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AudioAlignmentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "description": "A forced alignment: the submitted transcript and where each of its words\nis spoken in the clip.",
                  "properties": {
                    "language": {
                      "description": "The language as the model reported it (`en`, `de`; the model's own\nspelling). Absent when the model says none.\n\nA model may report the language it assumes rather than the one it was\nasked to align in: CrisperWhisper's aligner answers its default, `en`,\nto any `language` (checked 2026-10-22 with `de`, `german` and none).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sample_rate": {
                      "description": "The rate, in Hz, the `start_sample` and `end_sample` of the words\ncount in: the model's own figure when its answer states one, else\nderived from the words' seconds and samples (they are what the\nsamples count in, even where the engine resampled the clip), else the\nuploaded WAV's header. Absent when none of the three works; the\nseconds are always there.",
                      "format": "uint32",
                      "minimum": 0,
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "text": {
                      "description": "The transcript as the client submitted it (the multipart `text`\nfield), not what the model echoes. `char_start` and `char_end` of the\nwords index into this string.",
                      "type": "string"
                    },
                    "timing": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/AudioTiming"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "How long the engine took, as it reports it (audio.cpp's `timing`\nobject, which both aligners send). Absent when the answer has none."
                    },
                    "words": {
                      "description": "The words in the order the model answered them, which is the\ntranscript's order.",
                      "items": {
                        "$ref": "#/components/schemas/AlignedWord"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "text",
                    "words"
                  ],
                  "title": "AudioAlignment",
                  "type": "object"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Align audio to text",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/audio/speech": {
      "post": {
        "description": "OpenAI's TTS shape plus audio.cpp's own request options, forwarded verbatim (model rewritten); a row's configured voice presets apply on top.",
        "operationId": "post_v1_audio_speech",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AudioSpeechRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "audio/aac": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/flac": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/ogg": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/opus": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/pcm": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              },
              "audio/wav": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-sample-rate": {
                "description": "On a streamed POST /v1/audio/speech (stream_format sse or audio) to a local audio model, the sample rate of its PCM16 in Hz; the stream has no header of its own. lmgw learns it from the model's last WAV answer (it is also capabilities.speech.sample_rate) and omits it until the model has answered one since lmgw started.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-sample-rate": {
                "description": "On a streamed POST /v1/audio/speech (stream_format sse or audio) to a local audio model, the sample rate of its PCM16 in Hz; the stream has no header of its own. lmgw learns it from the model's last WAV answer (it is also capabilities.speech.sample_rate) and omits it until the model has answered one since lmgw started.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Generate speech",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "tts",
        "x-lmgw-writes": false
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "description": "multipart/form-data upload (also accepts application/json); byte-level passthrough to an OpenAI-protocol upstream only.",
        "operationId": "post_v1_audio_transcriptions",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AudioTranscriptionsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioTranscription"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Transcribe audio",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "asr",
        "x-lmgw-writes": false
      }
    },
    "/v1/audio/transcriptions/details": {
      "post": {
        "description": "The same request as /v1/audio/transcriptions, with the transcript detail arrays (words, segments, speaker turns) the plain route leaves out — an lmgw route, not an OpenAI one.",
        "operationId": "post_v1_audio_transcriptions_details",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AudioTranscriptionsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioTranscriptionDetails"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Transcribe audio with detail",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "asr",
        "x-lmgw-writes": false
      }
    },
    "/v1/audio/voices": {
      "get": {
        "description": "Every voice name a TTS model answers to — lmgw's own route. A local audio model is answered from lmgw's catalog (presets, the voices its package ships, its embeddings, the voice library) without starting it; ?probe=engine asks its own server instead, starting it if it is down. A remote model is asked.",
        "operationId": "get_v1_audio_voices",
        "parameters": [
          {
            "in": "query",
            "name": "model",
            "required": false,
            "schema": {
              "default": "",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "probe",
            "required": false,
            "schema": {
              "default": null,
              "description": "Where the list comes from. Absent or `config`: a local audio model is\nanswered from lmgw's own catalog (its presets, the voices its package\nships, its embeddings and the voice library) without starting it.\n`engine`: ask the model's own server — a local model's container is\nstarted if it is down. A remote model is always asked.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioVoices"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-voices-source": {
                "description": "On GET /v1/audio/voices, where the list came from. config: a local audio model answered from lmgw's own catalog (its presets, the voices its package ships, its embeddings and the voice library) without being started. engine: the model's own server answered, either a remote upstream or a local container with ?probe=engine, which starts the container if it is down.",
                "schema": {
                  "enum": [
                    "config",
                    "engine"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-voices-source": {
                "description": "On GET /v1/audio/voices, where the list came from. config: a local audio model answered from lmgw's own catalog (its presets, the voices its package ships, its embeddings and the voice library) without being started. engine: the model's own server answered, either a remote upstream or a local container with ?probe=engine, which starts the container if it is down.",
                "schema": {
                  "enum": [
                    "config",
                    "engine"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "List a model's voices",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "tts",
        "x-lmgw-writes": false
      }
    },
    "/v1/chat/completions": {
      "post": {
        "description": "The chat-completions API, plus lmgw's own reasoning controls and chat_template_kwargs passthrough. `model` may be an alias, a local model id, a candidate alias, or an exposed upstream's `prefix/…` id. An anthropic-beta header is forwarded when the route is an Anthropic upstream.",
        "operationId": "post_v1_chat_completions",
        "parameters": [
          {
            "description": "on|off: per-request thinking switch; it wins over body fields. On a cloud model, off goes out in the form the model takes: no reasoning control where the model has none, its lowest level where it cannot stop (x-lmgw-reasoning-ignored then lists enabled), thinking type between_tools on an Anthropic model whose catalog says it takes that type and not disabled. An off never ends in an error: a refused one is retried with what the refusal names and, failing that, with no reasoning control, so a model that cannot run without reasoning answers with its default reasoning. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "An effort level (see capabilities.reasoning.levels of the model); 'none' turns reasoning off. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-effort",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "Integer thinking-token budget; 0 turns reasoning off. Expressible on llama.cpp, Gemini and budget-style Anthropic models only. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-budget",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest",
                "example": {
                  "messages": [
                    {
                      "content": "Say hello in one short sentence.",
                      "role": "user"
                    }
                  ],
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-images-omitted": {
                "description": "Sent next to x-lmgw-fallback: the number of the request's images that went to the answering fallback as text placeholders because its capabilities say it cannot see ('[image/png image, N base64 bytes — omitted: the answering model cannot see images]'). The model reads the placeholder; the client reads this count. On /v1/responses it counts the images the run opened with. Absent when every image was sent, and on a route the client named itself, which always gets its images.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-clamped": {
                "description": "The max_tokens value lmgw lowered the request's cap to, because the n_predict of a ladder rung, or of a guarded shared-KV-pool model, is a ceiling every request on it must respect. Absent when nothing was lowered: a missing max_tokens is filled, not clamped, and a value already under the ceiling is kept exactly.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-defaulted": {
                "description": "The max_tokens value lmgw chose because the request set none and the route (an Anthropic upstream) requires one: the catalog's published maximum when streaming, 4096 when not streaming (the provider refuses non-streamed requests that could run too long).",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-raised": {
                "description": "The max_tokens value lmgw raised the request's cap to, because the requested thinking budget would not fit underneath it.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-params-ignored": {
                "description": "Comma-separated list of the request's sampling parameters (top_k, min_p, repeat_penalty, presence_penalty, frequency_penalty, seed) the answering model's provider does not take, so lmgw did not send them: the OpenAI platform takes no top_k, min_p or repeat_penalty; Anthropic none of the six but top_k; Gemini no min_p, repeat_penalty or penalties. llama.cpp and OpenAI-compatible providers are sent all of them. Also context_management and compaction, a /v1/messages request's Anthropic context management and on-demand compaction, which only an Anthropic model's route takes (both sent on as written), and thinking.display, which goes only to an Anthropic model, beside a thinking type that takes it (adaptive or enabled). Also content.<type>, a /v1/messages request's content block lmgw does not model (redacted_thinking, a type newer than lmgw), which only an Anthropic model's route is sent, and answer.<type>, such a block in an Anthropic model's whole answer, which a Chat Completions or Responses client is not given (a streamed answer's headers leave before it). On an Anthropic model's route, content.thinking and content.<type> name a thinking or other Anthropic block lmgw recorded from an answer at another provider's address (a stored /v1/responses chain), which this provider cannot read and is not sent. answer.citations and content.citations name an Anthropic text block's citations, which only a /v1/messages client and an Anthropic model's route are given (citations lmgw recorded from an answer only at that provider's address, and a citation with no text not at all). Request fields lmgw does not model are sent as they came and never listed. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "context_management",
                    "compaction",
                    "thinking.display"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-params-refused": {
                "description": "Comma-separated list of the request's sampling parameters the answering model refused, which lmgw left out of the send (stop is not left out; its refusal reaches the client). A 400 whose words refuse exactly one parameter the request carried (Anthropic '`temperature` is deprecated for this model.', OpenAI 'Unsupported parameter: 'temperature' is not supported with this model.' or 'Unsupported value: 'temperature' does not support 0 with this model.') is retried once without exactly that parameter, the refused attempt logged with a note naming it, and when the retry answers the parameter is left out of that model's later requests too, each saying so here. Nothing is left out without a refusal on record. On a streamed /v1/responses run the header names what was on record when the stream opened. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "temperature",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-reasoning-ignored": {
                "description": "Comma-separated list of the reasoning controls (enabled, effort, budget) the route could not express. enabled is also listed when an off went out as no control or as the model's lowest level, either because the model cannot take the off itself or because the provider refused every form of off and the model answered with its default reasoning. An off sent to an Anthropic model as thinking type between_tools (its own lowest setting, when it takes no disabled) is not listed. between_tools: a /v1/messages request's thinking type between_tools went to a model of another provider as that provider's off. Absent when every control was applied.",
                "schema": {
                  "enum": [
                    "enabled",
                    "effort",
                    "budget",
                    "between_tools"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-rung": {
                "description": "On a ladder model, the rung that answered (or refused) the request, as '<k>/<n>; ctx=<per-slot context>; gguf=<weights file>', counted from 1 (the gguf part is left off when the file name cannot be a header value). A request whose prompt plus max output does not fit the running rung makes the model climb to the smallest rung that fits before it answers. On /v1/responses it names the rung running when the run opened; a unary answer one of whose turns the fallback answered carries x-lmgw-fallback instead, and a stream's headers are sent before its turns run. Absent on models without a ladder and on responses a fallback answered.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "x-lmgw-sse-events": {
              "chunk": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/ChatCompletionChunk"
                  },
                  {
                    "$ref": "#/components/schemas/ChatCompletionStreamError"
                  }
                ]
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Create a chat completion",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/completions": {
      "post": {
        "description": "The legacy text-completions shape. Refuses a non-OpenAI-protocol upstream with 400 rather than sending it a request its own API cannot answer. A missing model is a 400 (missing 'model'), as on every other ingress.",
        "operationId": "post_v1_completions",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompletionRequest",
                "example": {
                  "model": "<pick a model>",
                  "prompt": "Once upon a time"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-max-tokens-clamped": {
                "description": "The max_tokens value lmgw lowered the request's cap to, because the n_predict of a ladder rung, or of a guarded shared-KV-pool model, is a ceiling every request on it must respect. Absent when nothing was lowered: a missing max_tokens is filled, not clamped, and a value already under the ceiling is kept exactly.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-rung": {
                "description": "On a ladder model, the rung that answered (or refused) the request, as '<k>/<n>; ctx=<per-slot context>; gguf=<weights file>', counted from 1 (the gguf part is left off when the file name cannot be a header value). A request whose prompt plus max output does not fit the running rung makes the model climb to the smallest rung that fits before it answers. On /v1/responses it names the rung running when the run opened; a unary answer one of whose turns the fallback answered carries x-lmgw-fallback instead, and a stream's headers are sent before its turns run. Absent on models without a ladder and on responses a fallback answered.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "x-lmgw-sse-events": {
              "chunk": {
                "$ref": "#/components/schemas/TextCompletionChunk"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Create a legacy text completion",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/count_tokens": {
      "post": {
        "description": "lmgw's own universal token counter: routed by model exactly like the chat endpoints, so counting on a cold local model starts its container. x-lmgw-count-approximate explains tokenizer_guess (an OpenAI-protocol upstream tiktoken cannot identify) and message_framing (an Anthropic/Gemini upstream counts messages, so the text went as one user turn).",
        "operationId": "post_v1_count_tokens",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CountTokensRequest",
                "example": {
                  "input": "How many tokens is this?",
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountTokensResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Count tokens (universal)",
        "tags": [
          "lmgw-inference"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/embeddings": {
      "post": {
        "description": "dimensions is forwarded in the upstream's own spelling, and a route that ignores it (llama-server) is a 400, not full-length vectors. encoding_format base64 is encoded by the gateway for every upstream.",
        "operationId": "post_v1_embeddings",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingsRequest",
                "example": {
                  "input": "lmgw is a gateway.",
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbeddingsResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Create embeddings",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "embedding",
        "x-lmgw-writes": false
      }
    },
    "/v1/images/edits": {
      "post": {
        "description": "multipart/form-data upload; refused unless the resolved row's edit pipeline flag is set.",
        "operationId": "post_v1_images_edits",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/ImageEditsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationsResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Edit an image",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "image_edit",
        "x-lmgw-writes": false
      }
    },
    "/v1/images/generations": {
      "post": {
        "description": "OpenAI's images shape; sd.cpp CLI arguments may ride along in a trailing <sd_cpp_extra_args>{…}</sd_cpp_extra_args> block on prompt (the dashboard's Image lab builds this block and is the reference for its contents). Answers base64 only (b64_json), never a URL.",
        "operationId": "post_v1_images_generations",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGenerationsRequest",
                "example": {
                  "model": "<pick a model>",
                  "n": 1,
                  "prompt": "A red bicycle in a park."
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationsResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Generate an image",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "image_generation",
        "x-lmgw-writes": false
      }
    },
    "/v1/mcp/servers": {
      "get": {
        "description": "The labels this caller may put into a {\"type\": \"mcp\", \"server_label\"} tool on /v1/realtime or /v1/responses, for a tool picker. Connects nothing: read from the configuration under the caller's tool scope — enabled servers only, and the lmgw self-admin toolset only for an owner credential or a device allowed lmgw's admin tools, while the self-admin tools are on.",
        "operationId": "get_v1_mcp_servers",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpServerList"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "List the MCP labels",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/mcp/servers/{label}": {
      "get": {
        "description": "One label's tools, exactly as a /v1/realtime session's mcp_list_tools item lists them (the server's own tool names, description always a string), under the caller's tool scope and the per-tool switches. Connects that one server if it is not up (up to the lazy-list budget). 404 for a label this caller may not use, naming the available ones; 502 when the server cannot be listed.",
        "operationId": "get_v1_mcp_servers_label",
        "parameters": [
          {
            "in": "path",
            "name": "label",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpServerDetail"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "List one MCP label's tools",
        "tags": [
          "mcp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/messages": {
      "post": {
        "description": "The Anthropic Messages API. A server tool (no input_schema) is refused with 400. A content block lmgw does not model (redacted_thinking, the provider's own tool blocks, a type newer than lmgw) goes between client and an Anthropic upstream as written, whole and streamed, where it stood; any other upstream is sent none of it (x-lmgw-params-ignored: content.<type>), and a Chat Completions or Responses client is given none (a whole answer's x-lmgw-params-ignored: answer.<type>). Thinking blocks keep their signature. A block without a type is refused with 400. A missing max_tokens is filled in rather than refused (x-lmgw-max-tokens-defaulted). anthropic-beta reaches an Anthropic upstream as one header, merged with the upstream row's own; other protocols have no equivalent and are sent none. context_management and the top-level compaction go to an Anthropic upstream as written and its answer's context_management comes back; any other upstream is sent neither, and x-lmgw-params-ignored names them. A compaction block (in the answer, streamed, or sent back in messages) goes between client and an Anthropic upstream as Anthropic wrote it, with stop_reason compaction and usage.iterations; any other upstream is sent the summary as text where the block stood and nothing before it, as Anthropic itself drops that history. thinking: {type: between_tools} and thinking.display go to an Anthropic upstream as written; elsewhere the off is that provider's own (x-lmgw-reasoning-ignored: between_tools) and display is named in x-lmgw-params-ignored. An unknown thinking type is refused with 400.",
        "operationId": "post_v1_messages",
        "parameters": [
          {
            "description": "on|off: per-request thinking switch; it wins over body fields. On a cloud model, off goes out in the form the model takes: no reasoning control where the model has none, its lowest level where it cannot stop (x-lmgw-reasoning-ignored then lists enabled), thinking type between_tools on an Anthropic model whose catalog says it takes that type and not disabled. An off never ends in an error: a refused one is retried with what the refusal names and, failing that, with no reasoning control, so a model that cannot run without reasoning answers with its default reasoning. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "An effort level (see capabilities.reasoning.levels of the model); 'none' turns reasoning off. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-effort",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "Integer thinking-token budget; 0 turns reasoning off. Expressible on llama.cpp, Gemini and budget-style Anthropic models only. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-budget",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          },
          {
            "description": "The Anthropic SDK's protocol version header. lmgw does not validate its value or vary its behaviour on it; egress to a real Anthropic upstream sends its own.",
            "example": "2023-06-01",
            "in": "header",
            "name": "anthropic-version",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-prefill": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessagesRequest",
                "example": {
                  "max_tokens": 256,
                  "messages": [
                    {
                      "content": "Say hello in one short sentence.",
                      "role": "user"
                    }
                  ],
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessage"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-images-omitted": {
                "description": "Sent next to x-lmgw-fallback: the number of the request's images that went to the answering fallback as text placeholders because its capabilities say it cannot see ('[image/png image, N base64 bytes — omitted: the answering model cannot see images]'). The model reads the placeholder; the client reads this count. On /v1/responses it counts the images the run opened with. Absent when every image was sent, and on a route the client named itself, which always gets its images.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-clamped": {
                "description": "The max_tokens value lmgw lowered the request's cap to, because the n_predict of a ladder rung, or of a guarded shared-KV-pool model, is a ceiling every request on it must respect. Absent when nothing was lowered: a missing max_tokens is filled, not clamped, and a value already under the ceiling is kept exactly.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-defaulted": {
                "description": "The max_tokens value lmgw chose because the request set none and the route (an Anthropic upstream) requires one: the catalog's published maximum when streaming, 4096 when not streaming (the provider refuses non-streamed requests that could run too long).",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-raised": {
                "description": "The max_tokens value lmgw raised the request's cap to, because the requested thinking budget would not fit underneath it.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-params-ignored": {
                "description": "Comma-separated list of the request's sampling parameters (top_k, min_p, repeat_penalty, presence_penalty, frequency_penalty, seed) the answering model's provider does not take, so lmgw did not send them: the OpenAI platform takes no top_k, min_p or repeat_penalty; Anthropic none of the six but top_k; Gemini no min_p, repeat_penalty or penalties. llama.cpp and OpenAI-compatible providers are sent all of them. Also context_management and compaction, a /v1/messages request's Anthropic context management and on-demand compaction, which only an Anthropic model's route takes (both sent on as written), and thinking.display, which goes only to an Anthropic model, beside a thinking type that takes it (adaptive or enabled). Also content.<type>, a /v1/messages request's content block lmgw does not model (redacted_thinking, a type newer than lmgw), which only an Anthropic model's route is sent, and answer.<type>, such a block in an Anthropic model's whole answer, which a Chat Completions or Responses client is not given (a streamed answer's headers leave before it). On an Anthropic model's route, content.thinking and content.<type> name a thinking or other Anthropic block lmgw recorded from an answer at another provider's address (a stored /v1/responses chain), which this provider cannot read and is not sent. answer.citations and content.citations name an Anthropic text block's citations, which only a /v1/messages client and an Anthropic model's route are given (citations lmgw recorded from an answer only at that provider's address, and a citation with no text not at all). Request fields lmgw does not model are sent as they came and never listed. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "context_management",
                    "compaction",
                    "thinking.display"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-params-refused": {
                "description": "Comma-separated list of the request's sampling parameters the answering model refused, which lmgw left out of the send (stop is not left out; its refusal reaches the client). A 400 whose words refuse exactly one parameter the request carried (Anthropic '`temperature` is deprecated for this model.', OpenAI 'Unsupported parameter: 'temperature' is not supported with this model.' or 'Unsupported value: 'temperature' does not support 0 with this model.') is retried once without exactly that parameter, the refused attempt logged with a note naming it, and when the retry answers the parameter is left out of that model's later requests too, each saying so here. Nothing is left out without a refusal on record. On a streamed /v1/responses run the header names what was on record when the stream opened. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "temperature",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-reasoning-ignored": {
                "description": "Comma-separated list of the reasoning controls (enabled, effort, budget) the route could not express. enabled is also listed when an off went out as no control or as the model's lowest level, either because the model cannot take the off itself or because the provider refused every form of off and the model answered with its default reasoning. An off sent to an Anthropic model as thinking type between_tools (its own lowest setting, when it takes no disabled) is not listed. between_tools: a /v1/messages request's thinking type between_tools went to a model of another provider as that provider's off. Absent when every control was applied.",
                "schema": {
                  "enum": [
                    "enabled",
                    "effort",
                    "budget",
                    "between_tools"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-rung": {
                "description": "On a ladder model, the rung that answered (or refused) the request, as '<k>/<n>; ctx=<per-slot context>; gguf=<weights file>', counted from 1 (the gguf part is left off when the file name cannot be a header value). A request whose prompt plus max output does not fit the running rung makes the model climb to the smallest rung that fits before it answers. On /v1/responses it names the rung running when the run opened; a unary answer one of whose turns the fallback answered carries x-lmgw-fallback instead, and a stream's headers are sent before its turns run. Absent on models without a ladder and on responses a fallback answered.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "x-lmgw-sse-events": {
              "message": {
                "$ref": "#/components/schemas/AnthropicStreamEvent"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Create a message",
        "tags": [
          "anthropic"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "anthropic",
        "x-lmgw-endpoints": [
          "anthropic"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "description": "The Anthropic SDKs' messages.count_tokens(): on an Anthropic-protocol upstream, the client body is sent through verbatim (only model replaced, and a Gemini thought signature in a tool id dropped), with its anthropic-beta flags, so server tools and new fields count exactly; Anthropic's context_management answer (original_input_tokens) comes back beside input_tokens. x-lmgw-count-approximate explains any other route's approximation. Enforces the key's alias scope like every other counter (a refusal is a logged 403 key_scope, a success is not logged); no budget applies, the key's or the gateway's, since a count costs nothing.",
        "operationId": "post_v1_messages_count_tokens",
        "parameters": [
          {
            "description": "on|off: per-request thinking switch; it wins over body fields. On a cloud model, off goes out in the form the model takes: no reasoning control where the model has none, its lowest level where it cannot stop (x-lmgw-reasoning-ignored then lists enabled), thinking type between_tools on an Anthropic model whose catalog says it takes that type and not disabled. An off never ends in an error: a refused one is retried with what the refusal names and, failing that, with no reasoning control, so a model that cannot run without reasoning answers with its default reasoning. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "An effort level (see capabilities.reasoning.levels of the model); 'none' turns reasoning off. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-effort",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "Integer thinking-token budget; 0 turns reasoning off. Expressible on llama.cpp, Gemini and budget-style Anthropic models only. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-budget",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          },
          {
            "description": "The Anthropic SDK's protocol version header. lmgw does not validate its value or vary its behaviour on it; egress to a real Anthropic upstream sends its own.",
            "example": "2023-06-01",
            "in": "header",
            "name": "anthropic-version",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-prefill": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicCountTokensRequest",
                "example": {
                  "messages": [
                    {
                      "content": "Say hello in one short sentence.",
                      "role": "user"
                    }
                  ],
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicCountTokensResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Count tokens for a message",
        "tags": [
          "anthropic"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "anthropic",
        "x-lmgw-endpoints": [
          "anthropic"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/models": {
      "get": {
        "description": "Aggregates enabled aliases, public local models and expose-all upstream catalogs. Served OpenAI-shaped unless the caller sends anthropic-version, in which case the Anthropic SDK's own shape. This document names the OpenAI error dialect as default; an Anthropic-dialect caller gets an Anthropic-shaped error body in practice.",
        "operationId": "get_v1_models",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "List models",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai",
          "anthropic"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/models/{id}": {
      "get": {
        "description": "The id may contain '/' (a passthrough id carries its upstream prefix and the provider's own slashes), hence the wildcard path parameter. Same dual-dialect note as GET /v1/models.",
        "operationId": "get_v1_models_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-lmgw-wildcard": true
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelById"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Retrieve a model",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai",
          "anthropic"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/openapi.json": {
      "get": {
        "description": "This description, filtered to the inference plane.",
        "operationId": "get_v1_openapi_json",
        "parameters": [
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Get the inference-plane OpenAPI description",
        "tags": [
          "lmgw-inference"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/realtime": {
      "get": {
        "description": "OpenAI's GA Realtime protocol over a WebSocket (ws://<host>/v1/realtime), answered by a cascade of this gateway's own aliases: voice activity and end-of-turn detection inside lmgw (Silero VAD; Smart Turn for semantic_vad), speech to text with realtime.asr_alias, the chat model, and text to speech with realtime.tts_alias — local models first, any of them a cloud alias if so configured (Settings → Realtime, which also shows what the cascade holds on the GPU). `model` is resolved in this order: a realtime.model_map name, an OpenAI Realtime name (gpt-realtime*, never taken as an alias), which realtime.default_model answers, or a chat alias; it may be left out and named in the first session.update instead. What a name resolved to is echoed in session.lmgw.resolved. Implemented: conversation sessions (session.type realtime) with audio or text output, PCM16 at 24 kHz in and out, server_vad, semantic_vad and manual turns, barge-in with a word check, session.update, input_audio_buffer.append/commit/clear, conversation.item.create/retrieve/truncate/delete, response.create and response.cancel, client-side function tools, and MCP tools the gateway runs itself on a session not bound to a Chat thread. An MCP session tool {\"type\": \"mcp\", \"server_label\"} names one of this gateway's own MCP servers (by its tool prefix or name) or a built-in toolset (docs, kb, and lmgw for an owner credential or a device allowed lmgw's admin tools, while the self-admin tools are on), resolved as on /v1/responses under the key's tool scope; GET /v1/mcp/servers lists the labels a caller may use and GET /v1/mcp/servers/{label} one label's tools. server_url, connector_id, headers, authorization and server_description are accepted and never used: lmgw dials no URL a client names, and echoes authorization and header values as [redacted]. allowed_tools takes a name list or {tool_names}; read_only and a require_approval that would gate a tool are refused (approvals are not built here yet: leave it out or send \"never\"); one entry per server_label. The session lists a label's tools as an mcp_list_tools item (mcp_list_tools.in_progress, then .completed or .failed — a failed label also gets an error with code mcp_list_tools_failed saying why, and a later session.update naming it lists it again), and a response waits for the listings in flight. A model's call to one of those tools is an mcp_call item (server_label, name — the server's own tool name — arguments, output, error, always present), streamed as response.mcp_call_arguments.delta and .done, then run by the gateway before response.done (response.mcp_call.in_progress, then .completed with the output or .failed with a tool_execution_error). The call ends the response: the client sends response.create for the answer, as OpenAI's Realtime API has it (@openai/agents does so by itself, once per response). A cancel or barge-in abandons a running call, which then fails saying it may or may not have run. A response's tools may narrow to a label the session has listed, and tool_choice takes {\"type\": \"mcp\", \"server_label\"} with an optional name. A client may replay mcp_call items as history; mcp_list_tools and the approval items are refused. Each call writes a realtime-tool usage row. Refused with an error naming what is missing: transcription sessions, G.711 formats, output_audio_buffer.clear (a WebRTC call's) and an input_audio item without its transcript. Accepted and echoed but not applied: noise_reduction, and truncation (lmgw.resolved.truncation says \"disabled\"; an overflow is an error). WebRTC is served at POST /v1/realtime/calls. Not served at all: the sideband connection to a call (call_id, refused with 400 sideband_unsupported rather than opening an unrelated session), SIP, ephemeral client secrets, live partial transcripts and out-of-band responses. Credentials as on every /v1 route; a browser, which cannot set headers on a WebSocket, may offer its key as the subprotocol `openai-insecure-api-key.<key>` alongside `realtime` — accepted on this route only. A paired device's key is refused before the upgrade with 401 device_key_unknown when it matches no device (pair it again), 401 device_disabled while the device is disabled, and 401 key_expired past its expiry date, as on every Chat route. A beta client (OpenAI-Beta: realtime=v1) is refused with 400 beta_protocol_unsupported, and with Require API key off an anonymous upgrade from another page's Origin is refused with 403. Chat models list this route in their capabilities.endpoints on GET /v1/models once an ASR and a TTS alias are configured, and /v1/realtime/calls beside it while the WebRTC UDP socket of the listener asked is bound. The TTS gets lmgw's speech instructions — session.lmgw.speech_instructions, a response.create's response.lmgw.speech_instructions, else realtime.speech_instructions — as a style, or as the description a voice-design (vdes) model designs its voice from; session.lmgw.resolved.speech says what is in effect, and the transcript leaves out the inline tags ([laughter]) the voice renders. Markdown a voice cannot read is not spoken: fenced code blocks and tables (lines that start with |, from one that ends with | or is followed by a delimiter row) are skipped — the transcript leaves them out, and the model's history keeps them. On a style or passthrough TTS that renders no tags (Qwen3 CustomVoice, Auk, MOSS-TTS; a cloud TTS only when its alias's capabilities.speech override declares instructions 'style'), the tags that open a sentence, or a part of one spoken on its own, are a delivery cue instead ([laughing]): sent after the style as the instructions until that sentence ends, best effort, never read out (resolved.speech.cues). A voice mode binds a session to a Chat thread with chat_thread=<id> (negative for a temporary chat): the chat capability only — the dashboard's cookie, an owner key or a paired device's key; refused before the upgrade, in the OpenAI error shape ({\"error\": {code, message, type, param}}) and checked in this order, with 403 chat_thread_not_allowed, 400 owned_by_thread beside model, 404 chat_thread_not_found (also an Admin Chat thread a device names, and a thread with the self-admin toolset a device not allowed lmgw's admin tools names: for that device they do not exist), 409 chat_thread_admin for an Admin Chat thread the owner names (no voice mode there), and, with takeover=never, 409 chat_thread_bound while another session is bound to the thread (\"voice is in use on device 'phone'\"; nothing is taken over), whose error.held_by names the holder as the Chat feed's voice.bound.by does (\"device 'phone'\", \"the dashboard\") so a client shows it without reading the message; no other refusal carries held_by. A session bound with the same key, or one that is already ending (after its 1001, a revocation or its close, while it writes its last turns), does not count: takeover=never takes it over, so a client's rebind after a restart or a dropped link is not refused in its own name. A device binds as its key: the thread's chat, speech-to-text and text-to-speech aliases pass its scope and budget before the upgrade (refused as an unbound session's aliases are, 403 key_scope or key_budget; the speech aliases' missing price, budget_unpriced, too), while the chat alias's price check comes at the first turn, as an error event, not before the upgrade; every model call of the session is checked and counted against it as an unbound session's, and each refusal writes its request row. session.created then names the thread in session.lmgw.resolved.chat_thread ({id, title, temporary, admin_tools}) and its turn mode in session.lmgw.turn_mode (below), and the connect warm loads the thread's chat, speech-to-text and text-to-speech models as one group, which may evict idle models as the requests it announces would, whatever realtime.warm_on_connect says (that setting is for unbound sessions). chat_folder=<id> binds an ongoing folder's current thread instead, decided by the rules of POST /chat/api/folders/{id}/current and bound in one step under the folder's lock, so no other client moves the folder in between: the current thread, or a new one from the folder's defaults when there is none, when it is out of the caller's reach, when it idled past the folder's idle minutes, or with new=true unless it has no message yet; a new thread is recorded as folder.current on the Chat feed with its reason, and the thread bound is reported in session.lmgw.resolved.chat_thread as for chat_thread. It is refused beside chat_thread (400 invalid_value) and model (400 owned_by_thread), new without chat_folder and takeover with neither parameter are 400 invalid_value, then come 404 chat_folder_not_found (a folder the caller cannot see), 409 not_ongoing and 409 folder_no_model, then the thread's own refusals, checked on the thread the decision picks before a new one is made. takeover=ask is a WebRTC call's and 400 invalid_value here. A bound session carries session.lmgw.turn_mode, automatic or push_to_talk, resolved from the thread's turn detection at the bind (push_to_talk there is push_to_talk, anything else automatic), and lmgw sets audio.input.turn_detection to match: the thread's rule (server_vad or semantic_vad, semantic_vad where it names none) in automatic mode, null in push_to_talk; session.created echoes both. A session.update naming turn_mode switches it and gets the turn detection it implies (the mode in effect named again leaves the detection as it is); one that also names audio.input.turn_detection must agree with it (null with push_to_talk, a rule with automatic), as an echo of the whole session does, else invalid_value; turn detection named alone still works and turn_mode follows it. A change of the thread's turn detection applies at the next bind. An unbound session has no turn_mode, and refuses one with invalid_value. The thread then owns the chat model, prompt, tools, speech models, voice, speech style, language, seed and conversation: a session.update that changes one of them, a response.create that overrides one, and conversation.item.create or .delete are refused with owned_by_thread (an echoed value is accepted). Each response is the thread's own chat turn — its model, prompt with the spoken-style instructions after it, sampling, attachments, knowledge bases and MCP tools, which never become function_call items — written to the thread's history: the user turn with how it was spoken, the reply cut to what was heard (the unheard rest kept beside it, a reply nobody heard deleted unless it ran tools), never over a turn another window started meanwhile. Code blocks and tables are announced rather than skipped silently (\"Code block, rust.\", \"Table.\"; in the thread's language for en, de, fr, es and it), and the dashboard's read-aloud of a reply speaks the same way. No audio is stored: a spoken turn is kept as text. With chat_voice_audio_input on (Settings, or the thread's voice.audio_input), a turn whose answering model takes audio input — the thread's chat model, or the fallback a GPU hold, a benchmark run, an outside-VRAM verdict or a candidate alias hands it to, wherever it runs — goes to it as audio at the commit, while the speech-to-text model transcribes it beside (a model that does not take audio input, one whose capabilities lmgw cannot read, or one lmgw cannot send audio to, such as an Anthropic upstream, is refused it before anything is sent, and the turn goes again as its transcript); the reply is held until the transcript is in, then plays (a thread with no speech-to-text model that resolves always goes as its transcript: only the transcript tells words from noise). A turn that came back without words ends the response quietly as response.done {cancelled, reason no_words}, with no error and nothing written; a failed transcription of a turn the model heard (it answered from the audio) plays the reply and marks the user message (voice.transcript_error) instead of sending transcription.failed, while one no model heard yet, or a turn never transcribed at all (no speech-to-text model, the key's policy, the session's end), is said as with the setting off and ends the response quietly as response.done {cancelled, reason transcription_failed}. A new turn cuts a held reply whatever interrupt_response says, and a held reply's tools run only once its user message is written (a turn that came back without words runs none). A model's server that refuses the audio gets the transcript once, and the session's later turns to that model go as text when the refusal names the audio or the transcript retry answered (a server that went away under the audio is not retried, and its later turns go as text too). One session per thread: a second bind takes the thread over, and the older session gets error chat_thread_taken_over and the close 4000, both naming who bound it (\"voice mode moved to device 'phone'\", \"… to the dashboard\") — unless the second bind gives takeover=never, which a client uses for its own automatic rebinds so it never takes the voice from another device; a user's explicit choice to talk binds without it. A bound session — and no other — also sends lmgw's own events: lmgw.chat.frame ({response_id, event, data}: the chat turn's frames verbatim — turn, retrieval, delta, reasoning, tool, usage, stats, stop, state, error, done; a tool frame's ready and result carry call_id, server_label and ui_resource (the namespaced MCP Apps UI resource the tool links to, for resources/read on /mcp; null when none), ready needs_approval, and result structured_content (the MCP result's structuredContent; null when none) and content (its content blocks as the server sent them), and approval the waiting call's approval_request_id, server_label, name, arguments and call_id (the id its ready frame carried); reasoning is shown, stored with the reply and never spoken, and done's reasoning_note says in a sentence when the model reasoned although the turn asked for reasoning off — a voice turn does unless the thread sets reasoning; no off ends in an error — and its images_note when a fallback that cannot see answered and got the turn's images as placeholders), lmgw.chat.user ({message_id, content, voice (a MessageVoice), response_id}: response_id when that response heard the turn as audio, whose user message is written once the turn is transcribed, after the reply may have started — the page puts it before that reply), lmgw.chat.input ({response_id, input: audio or transcript, why}: how a response's turns reach the chat model and why the transcript, sent at each launch, when an audio attempt was refused, and when a llama-server that went away under the audio sends the session's later turns to it as text; never with chat_voice_audio_input off), lmgw.chat.reply (the ChatReply type: {message_id, content, unheard, voice (a MessageVoice)}, {message_id, removed: true} or {message_id, skipped, voice}: the reply as stored once its response ended, cut to what lmgw knew was heard; a conversation.item.truncate that arrives after that cuts it again at the position the client heard, and sends a second lmgw.chat.reply for the same message_id, which replaces the first), lmgw.model.state ({stage, alias, state, ms, …}: the connect warm's and each turn's model loading), lmgw.chat.thread ({chat_thread: {id, title, temporary, admin_tools}}: the thread as a response re-read it, when that differs from session.lmgw.resolved.chat_thread — a title the first spoken turn named, the admin tools switched on or off) and lmgw.response.timing (a VoiceTiming, flat: {response_id, message_id, end_of_turn_ms, asr_ms, first_token_ms, reasoning_ms, first_clause_ms, first_audio_ms, total_ms, to_first_audio_ms, cold, models: {asr, chat, tts}, input, input_why, transcript_wait_ms}: the timing log line as data, each stage measured from the one before, reasoning_ms the part of first_token_ms the model reasoned (absent when it did not), cold naming the stages that loaded, input whether the chat model heard the turn as audio or read its transcript, input_why why the transcript, transcript_wait_ms how long the first output was held for the transcript (the three absent with chat_voice_audio_input off, transcript_wait_ms on the transcript path), each model with the alias that answered when a fallback did, first_clause: \"announcement\" when the first clause said was one; sent once the reply is written, message_id null when nothing was saved, and stored with the reply), lmgw.approval.decided ({approval_request_id, approve, by}: a call whose mcp_approval_request item the session showed was decided by another client, `by` naming who as the feed names authors; approve false and by null for one whose reply was edited or deleted) and lmgw.task.done ({thread_id, message_id, id, task_id, server_label, tool, status, by}: a late MCP task result entered the thread as message message_id of role tool — the feed's task.done facts; it enters only while no turn of the thread runs, so one that ended during a response is said once that response's turn ended; one said while a response runs entered at that response's start, and that response answers it). Three more lmgw events belong to a WebRTC call bound to a Chat thread and are never sent or read on this WebSocket, whose closes say the same with their codes: lmgw.session.bind_pending ({held_by}: under takeover=ask the thread was held when the call's channel opened; no session runs until the client sends lmgw.session.take_over ({}) to take it, the holder ends and the call binds by itself, or the wait of one realtime.ping_interval_s runs out; a holder that changes brings another), and lmgw.session.closed ({kind, by, message}: the bound call's last event, kind one of taken_over, revoked, out_of_reach, shutting_down, closed and thread_bound, by the new binder, the holder or who hung up and otherwise null, message the sentence a WebSocket close's reason carries, led by the revocation token for revoked). by and held_by name a client as voice.bound.by does. lmgw starts no response for a result: the client's own response.create with no new words and no turn the client committed before it, while the thread holds results no reply answered (said in this session, or there before the bind), is a continuation that answers them, as POST /chat/api/threads/{id}/answer does (turn detection's automatic response to a turn without words stays empty_turn, and so does a push-to-talk commit of silence and its response.create; a continuation a cough cut before any of it was heard runs again after the cough) — it never cancels a turn of the thread (response.done failed with turn_running while one runs), and is empty_turn when a turn of another window answered the results meanwhile. A bound turn's call that waits for an approval (the thread's require_approval) is OpenAI's mcp_approval_request item (conversation.item.added and .done; its id is the approval id; OpenAI's shape, so no call id: the lmgw.chat.frame relaying the turn's approval frame, sent right after the item, carries call_id beside the same approval_request_id) and its response ends; the client answers with conversation.item.create of {type: mcp_approval_response, approval_request_id, approve, reason?} — the one item a bound session takes — then response.create, and that response resumes the thread's turn as POST /chat/api/threads/{id}/approvals does, the session's principal the approver: the approved calls run and the answer comes in that one response. A refusal of the answers fails the response with the route's code (approval_missing, approval_not_found, approval_decided, approval_starter_unavailable, approval_moved_on, approval_out_of_scope, key_rate). A committed turn with words is a new message, which declines what waits: a response that answers one runs as ever. Keep a spoken answer out of the session (transcribe it with POST /chat/api/threads/{id}/transcribe). A refusal mid-session is an error event; its codes: owned_by_thread (a client event changing what the thread owns), empty_turn (a response that would answer no turn and no job result), turn_running (a continuation while a turn of the thread runs), superseded and not_saved (another turn took the thread, or the reply could not be saved; its speech stops), chat_thread_not_found and chat_thread_admin, tts_not_configured, voice_not_configured, voice_not_found, instructions_required, voice_needs_transcript and speech_unavailable (the thread's speech, judged per response after response.created), chat_history_write_failed (the store refused the spoken turn; its words lead the next user message), and chat_thread_taken_over before the takeover's close. A session opened with a key ends when the key is revoked — disabled, rotated or deleted on the Keys page, or past its expires_at — with the close 4003 (any key's session, a device's or not). Its reason starts with a token saying what to do, then a colon and the sentence: device_disabled (a paired device was disabled), key_expired (a paired device's key expired), key_unknown (a paired device's key was replaced or deleted: pair it again), certificate_expired (a paired device's client certificate passed its notAfter: pair it again) or revoked (any other kind of key), e.g. \"device_disabled: device 'desktop' was disabled\"; reconnecting with the same key is refused. A device's session bound to a thread that leaves the device's reach — the self-admin toolset attached to it, or what the device's admin tools may do set to off — closes with 4004 and the neutral reason \"chat thread <id> is out of reach for this key\": the key is still good, and a client asks for its current thread again. Another client binding the thread closes the session with 4000. Every session closes with 1001 (\"lmgw is stopping or restarting\") when the gateway stops or restarts.",
        "operationId": "get_v1_realtime",
        "parameters": [
          {
            "in": "query",
            "name": "call_id",
            "required": false,
            "schema": {
              "default": null,
              "description": "OpenAI's sideband connection: a server-side WebSocket attached to a\nWebRTC call's session. lmgw serves none, so it is refused, 400\nsideband_unsupported, rather than opening an unrelated session.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "chat_folder",
            "required": false,
            "schema": {
              "default": null,
              "description": "A voice mode bound to an ongoing folder's current thread: the bind\ndecides the thread by the rules of `POST\n/chat/api/folders/{id}/current` and binds it in one step, under the\nfolder's lock — the current thread, or a new one from the folder's\ndefaults when there is none, when it is out of the caller's reach,\nwhen it idled past the folder's idle minutes, or with `new=true`\n(unless it has no message yet). A new thread is recorded as\n`folder.current` on the Chat feed with its reason. The thread bound\nis reported in `session.lmgw.resolved.chat_thread`, and is then as\nwith `chat_thread`. Refused beside `chat_thread` (400 invalid_value)\nand beside `model` (400 owned_by_thread); 404 chat_folder_not_found\nfor a folder the caller cannot see, 409 not_ongoing for one that is\nno ongoing conversation, 409 folder_no_model for one whose defaults\nname no model, then the thread's own refusals.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "chat_thread",
            "required": false,
            "schema": {
              "default": null,
              "description": "A voice mode bound to a Chat thread: bind the session to this thread\n(negative for a temporary one). The thread then owns the chat model,\nprompt, tools, speech models, voice and conversation, and the session\nsends lmgw's `lmgw.*` extension events. Needs the chat capability\n(the dashboard's cookie, an owner key or a paired device's key),\nrefused beside `model`, and refused for an Admin Chat thread (a\ndevice is told there is no such thread). A device binds as its key:\nthe thread's aliases pass its scope and budget first.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "model",
            "required": false,
            "schema": {
              "default": null,
              "description": "The chat model: a `realtime.model_map` name, an OpenAI Realtime name\nanswered by `realtime.default_model`, or a chat alias — in that\norder. Optional — a session may name its model in its first\n`session.update` instead.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "new",
            "required": false,
            "schema": {
              "default": null,
              "description": "With `chat_folder`: start a new conversation — a new thread unless\nthe folder's current one has no message yet. Refused without\n`chat_folder` (400 invalid_value).",
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "takeover",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/Takeover"
                },
                {
                  "type": "null"
                }
              ],
              "description": "With `chat_thread` or `chat_folder`: whether this bind may take the\nthread from a session already bound to it. Left out, it does — the\nother session closes (a WebSocket with 4000), naming who took it.\n`never`: it does not — while another session is bound to the thread\nthe request is refused, 409 chat_thread_bound naming who holds it\n(\"voice is in use on device 'phone'\", and as `error.held_by`), and\nnothing is taken over; a WebRTC call whose thread is taken between\nits POST and its channel's open ends with lmgw.session.closed\n{kind: thread_bound}. For a client's own automatic rebinds (after a\nconversation moved to a new thread), so it never takes the voice\nfrom another device that followed the same move; a user's explicit\nchoice to talk binds without it. `ask` is a WebRTC call's own (POST\n/v1/realtime/calls): a thread held when the call's channel opens is\nasked about, lmgw.session.bind_pending; on GET /v1/realtime it is\n400 invalid_value. Without `chat_thread` or `chat_folder`, 400\ninvalid_value."
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "101": {
            "description": "Switching Protocols: the connection is now a WebSocket. Each frame is one JSON text event of OpenAI's GA Realtime protocol: client events in, server events (each with a server-minted event_id) out. session.created arrives first.",
            "headers": {
              "Sec-WebSocket-Protocol": {
                "description": "The subprotocol selected, present when the client offered it.",
                "schema": {
                  "enum": [
                    "realtime"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "426": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Upgrade Required: the request carried no WebSocket upgrade headers."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error, before the upgrade."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Open a realtime voice session",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/realtime/calls": {
      "post": {
        "description": "OpenAI's WebRTC transport for the Realtime API. The client POSTs its SDP offer — audio with Opus, and the data channel oai-events created before createOffer — as application/sdp, or as multipart/form-data with the part sdp and an optional session part: a JSON object, the session as session.update takes it. The answer is 201 Created with the SDP answer (application/sdp: ICE-lite, one UDP host candidate — the local address this POST arrived on, on the WebRTC UDP port: realtime.webrtc_port, by default the HTTP port's number, or on the device listener its own port — Opus only, with RED when the offer carries it) and Location: /v1/realtime/calls/{call_id}, the call's id rtc_ and 24 hex digits. Behind it runs the session GET /v1/realtime runs — the same cascade, binding and policy — its events as JSON text on oai-events and its audio on RTP. lmgw's audio is one Opus stream for the call's whole life, a frame every 20 ms (realtime.webrtc_output_kbps, capped by the offer's maxaveragebitrate; DTX only when the offer's Opus format says usedtx=1; in-band FEC following the client's receiver reports), silence between answers; the client's audio is heard from its first frame after DTLS connects, what it sent before oai-events opened included, and an input_audio_buffer.commit takes the frames captured up to realtime.webrtc_commit_window_ms after it arrived. oai-events carries no audio: no response.output_audio.delta, input_audio_buffer.append is answered invalid_event, and session.lmgw.output_lead_ms is 0. Every call hears OpenAI's output_audio_buffer.started ({response_id}) with an answer's first frame, and .stopped right after the response.done of one that played out, or .cleared after the response.done of one that was cut (a barge-in, a cancel, a clear, a stop); output_audio_buffer.clear cancels the answer whose audio plays and is silent with none. An event over the client's max-message-size (or realtime.max_message_mb below it) arrives on an unbound call with its largest fields emptied, each followed by an error event_too_large naming the field's path. A call bound to a Chat thread also hears lmgw.output_audio.starved ({response_id, starved}) when an answer's audio runs dry and when it comes again, and may report its playout with lmgw.output_audio.playout ({playout_ntp_ms?, jitter_buffer_ms?}), which the answer's end follows; it stops with lmgw.response.stop ({playout_ntp_ms?}: the open response, the one owed and a held response.create cancelled, heard cut at the client's playout position when it sends one and what was sent otherwise, as on an audio-only call, where libwebrtc does not fill estimatedPlayoutTimestamp (calls design Q5); nothing with nothing open); an event over the limit travels both ways as lmgw.event.part ({id, index, count, data}, back to back, id the event's event_id), joined by the receiver, a client's up to realtime.max_message_mb. An unbound call answers these lmgw events invalid_event. The session starts when oai-events opens: session.created, then the session part applied as the session's first update (session.updated, or an error as for any update; on a call bound to a Chat thread it may change only what a bound session's client owns). Credentials, model resolution and the key's scope, budget and concurrency slot are /v1/realtime's — the slot held from this POST until the call ends — the subprotocol key aside; with Require API key off, an anonymous call from another page's Origin is refused with 403 cross_origin_refused. The query is /v1/realtime's: model, chat_thread or chat_folder with new, and takeover. A call bound to a Chat thread or folder only checks at this POST — nothing is bound and no thread is made — and binds when oai-events opens, checking again: takeover left out takes the thread over (its holder closes as taken over); never ends the call with lmgw.session.closed {kind: thread_bound, by} when the thread is held then, and is the 409 chat_thread_bound, the holder in error.held_by, when it is held at this POST; ask, this route's own, makes the call wait with lmgw.session.bind_pending ({held_by}): the client's lmgw.session.take_over ({}) takes the thread, a holder that ends lets the call bind by itself, a third client taking the thread brings another bind_pending, every other event meanwhile is answered with error bind_pending and the audio is discarded, and one realtime.ping_interval_s after the latest bind_pending the call ends with thread_bound (no bound at 0). A take_over that crosses the bind is ignored. A bound call's last event before lmgw ends it is lmgw.session.closed ({kind, by, message}: kind taken_over, revoked, out_of_reach, shutting_down, closed or thread_bound; by the new binder, the holder or who hung up, else null; message the sentence a WebSocket close's reason carries, led by the revocation token for revoked). A refusal when oai-events opens is that event — out_of_reach for a thread or folder out of the caller's reach, revoked for a key revoked since this POST, closed after an error carrying the refusal's code otherwise. by and held_by name a client as the Chat feed's voice.bound.by does. An unbound call sends no lmgw event and closes with nothing in band, as OpenAI's do. A call whose ICE, DTLS or data channel never comes up ends one realtime.ping_interval_s after its answer, binding nothing. Refused before the answer: 400 invalid_value (the query, a parameter rule, or a session part that is no JSON object or is over realtime.max_message_mb, which bounds a session event on either transport), 400 bad_request (a multipart body that does not parse), 400 sideband_unsupported (call_id), 400 owned_by_thread, 400 missing_sdp (a multipart body without sdp), 400 invalid_sdp (the offer does not parse; the reason quoted), 400 unsupported_offer (no Opus audio, or no data channel), 400 beta_protocol_unsupported, 403 cross_origin_refused, the bind's refusals (403 chat_thread_not_allowed, 404 chat_thread_not_found and chat_folder_not_found, 409 not_ongoing, folder_no_model, chat_thread_admin and chat_thread_bound), the key's 401, 403 and 429, 413 over max_body_mb, 415 unsupported_media_type, and 503 webrtc_unavailable when realtime.webrtc_enabled was off at lmgw's start, or the listener's UDP sockets failed to bind or are not bound (the message names the setting or the error), and, with a Retry-After header, while the device listener's group moves with it or when the POST's connection belongs to an earlier start of it. The device listener's UDP sockets follow its addresses and port: a change of the device listener ends its calls, a bound call's last event lmgw.session.closed {kind: shutting_down}, and leaves the plain listener's running. Not served: the sideband WebSocket, SIP's accept, reject and refer, and ephemeral client secrets.",
        "operationId": "post_v1_realtime_calls",
        "parameters": [
          {
            "in": "query",
            "name": "call_id",
            "required": false,
            "schema": {
              "default": null,
              "description": "OpenAI's sideband connection: a server-side WebSocket attached to a\nWebRTC call's session. lmgw serves none, so it is refused, 400\nsideband_unsupported, rather than opening an unrelated session.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "chat_folder",
            "required": false,
            "schema": {
              "default": null,
              "description": "A voice mode bound to an ongoing folder's current thread: the bind\ndecides the thread by the rules of `POST\n/chat/api/folders/{id}/current` and binds it in one step, under the\nfolder's lock — the current thread, or a new one from the folder's\ndefaults when there is none, when it is out of the caller's reach,\nwhen it idled past the folder's idle minutes, or with `new=true`\n(unless it has no message yet). A new thread is recorded as\n`folder.current` on the Chat feed with its reason. The thread bound\nis reported in `session.lmgw.resolved.chat_thread`, and is then as\nwith `chat_thread`. Refused beside `chat_thread` (400 invalid_value)\nand beside `model` (400 owned_by_thread); 404 chat_folder_not_found\nfor a folder the caller cannot see, 409 not_ongoing for one that is\nno ongoing conversation, 409 folder_no_model for one whose defaults\nname no model, then the thread's own refusals.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "chat_thread",
            "required": false,
            "schema": {
              "default": null,
              "description": "A voice mode bound to a Chat thread: bind the session to this thread\n(negative for a temporary one). The thread then owns the chat model,\nprompt, tools, speech models, voice and conversation, and the session\nsends lmgw's `lmgw.*` extension events. Needs the chat capability\n(the dashboard's cookie, an owner key or a paired device's key),\nrefused beside `model`, and refused for an Admin Chat thread (a\ndevice is told there is no such thread). A device binds as its key:\nthe thread's aliases pass its scope and budget first.",
              "format": "int64",
              "type": [
                "integer",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "model",
            "required": false,
            "schema": {
              "default": null,
              "description": "The chat model: a `realtime.model_map` name, an OpenAI Realtime name\nanswered by `realtime.default_model`, or a chat alias — in that\norder. Optional — a session may name its model in its first\n`session.update` instead.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "new",
            "required": false,
            "schema": {
              "default": null,
              "description": "With `chat_folder`: start a new conversation — a new thread unless\nthe folder's current one has no message yet. Refused without\n`chat_folder` (400 invalid_value).",
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          {
            "in": "query",
            "name": "takeover",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/Takeover"
                },
                {
                  "type": "null"
                }
              ],
              "description": "With `chat_thread` or `chat_folder`: whether this bind may take the\nthread from a session already bound to it. Left out, it does — the\nother session closes (a WebSocket with 4000), naming who took it.\n`never`: it does not — while another session is bound to the thread\nthe request is refused, 409 chat_thread_bound naming who holds it\n(\"voice is in use on device 'phone'\", and as `error.held_by`), and\nnothing is taken over; a WebRTC call whose thread is taken between\nits POST and its channel's open ends with lmgw.session.closed\n{kind: thread_bound}. For a client's own automatic rebinds (after a\nconversation moved to a new thread), so it never takes the voice\nfrom another device that followed the same move; a user's explicit\nchoice to talk binds without it. `ask` is a WebRTC call's own (POST\n/v1/realtime/calls): a thread held when the call's channel opens is\nasked about, lmgw.session.bind_pending; on GET /v1/realtime it is\n400 invalid_value. Without `chat_thread` or `chat_folder`, 400\ninvalid_value."
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/sdp": {
              "schema": {
                "type": "string"
              }
            },
            "multipart/form-data": {
              "schema": {
                "description": "`POST /v1/realtime/calls` as `multipart/form-data` (calls design §2.1),\nOpenAI's shape: the parts. The offer may come alone instead, as an\n`application/sdp` body.",
                "properties": {
                  "sdp": {
                    "description": "The SDP offer (`application/sdp`): audio with Opus, and the data\nchannel `oai-events`, created before `createOffer`.",
                    "type": "string"
                  },
                  "session": {
                    "additionalProperties": true,
                    "description": "The session (`application/json`): a JSON object, the session as\n`session.update` takes it — OpenAI's GA session object. Not checked\nbefore the answer: the session applies it as its first update, right\nafter `session.created` and before any event of the client's, and\nanswers it as any update, `session.updated` or an `error`. On a call\nbound to a Chat thread only what the client owns applies (turn\ndetection or `lmgw.turn_mode`, `lmgw.half_duplex`, `lmgw.echo_tail_ms`).",
                    "type": "object"
                  }
                },
                "required": [
                  "sdp"
                ],
                "title": "CallRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/sdp": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Created.",
            "headers": {
              "Location": {
                "description": "The call's path, /v1/realtime/calls/{call_id}: its last segment is the call id the hangup takes.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Start a realtime call (WebRTC)",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-writes": true
      }
    },
    "/v1/realtime/calls/{call_id}/hangup": {
      "post": {
        "description": "Ends a call: its session ends as if the client had closed it, a bound call's last event being lmgw.session.closed {kind: closed, by} naming who hung up. Answered 200 with an empty body once the call has let go — its Chat thread's binding marked as ending and its concurrency slot back — so a call posted right after it is neither refused (takeover=never) nor left pending (takeover=ask) by the call it ended. A call whose session or bind has not let go 10 s after the hangup (the bound a stopping server gives its sessions) is closed by force and answered 200 then; its binding is marked as ending only once its session notices, so a takeover=never call right after such a 200 may still be refused by it for that moment. A call that has let go but still waits for its last events' delivery (closing) is closed at once, without them, and answered 200. Takes no concurrency slot and counts no request, so a key at its limit can still hang up. Allowed for the key that made the call and for the owner; anyone else, and a call that has ended, gets 404 call_not_found.",
        "operationId": "post_v1_realtime_calls_call_id_hangup",
        "parameters": [
          {
            "in": "path",
            "name": "call_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Hang up a realtime call",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-writes": true
      }
    },
    "/v1/rerank": {
      "post": {
        "description": "Jina and TEI request shapes both work (documents or texts); an embedding-only row is refused. Answers Jina's results shape either way.",
        "operationId": "post_v1_rerank",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RerankRequest",
                "example": {
                  "documents": [
                    "An LLM gateway.",
                    "A city in France."
                  ],
                  "model": "<pick a model>",
                  "query": "What is lmgw?"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RerankResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Rerank documents",
        "tags": [
          "lmgw-inference"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-model-task": "rerank",
        "x-lmgw-writes": false
      }
    },
    "/v1/responses": {
      "post": {
        "description": "lmgw's own Responses API implementation; llama-server has none. MCP tools run server-side on lmgw's registered MCP servers. An upstream that implements the Responses API itself (the OpenAI platform, a compatible row flagged for it) gets the body as sent, hosted tools, item references and truncation:\"auto\" included, unless only lmgw's loop can serve the request; the loop refuses those rather than approximating them. background:true is refused on every path. An anthropic-beta header is forwarded when the route is an Anthropic upstream.",
        "operationId": "post_v1_responses",
        "parameters": [
          {
            "description": "on|off: per-request thinking switch; it wins over body fields. On a cloud model, off goes out in the form the model takes: no reasoning control where the model has none, its lowest level where it cannot stop (x-lmgw-reasoning-ignored then lists enabled), thinking type between_tools on an Anthropic model whose catalog says it takes that type and not disabled. An off never ends in an error: a refused one is retried with what the refusal names and, failing that, with no reasoning control, so a model that cannot run without reasoning answers with its default reasoning. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "An effort level (see capabilities.reasoning.levels of the model); 'none' turns reasoning off. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-effort",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "Integer thinking-token budget; 0 turns reasoning off. Expressible on llama.cpp, Gemini and budget-style Anthropic models only. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-budget",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest",
                "example": {
                  "input": "Say hello in one short sentence.",
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Response"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-images-omitted": {
                "description": "Sent next to x-lmgw-fallback: the number of the request's images that went to the answering fallback as text placeholders because its capabilities say it cannot see ('[image/png image, N base64 bytes — omitted: the answering model cannot see images]'). The model reads the placeholder; the client reads this count. On /v1/responses it counts the images the run opened with. Absent when every image was sent, and on a route the client named itself, which always gets its images.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-clamped": {
                "description": "The max_tokens value lmgw lowered the request's cap to, because the n_predict of a ladder rung, or of a guarded shared-KV-pool model, is a ceiling every request on it must respect. Absent when nothing was lowered: a missing max_tokens is filled, not clamped, and a value already under the ceiling is kept exactly.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-defaulted": {
                "description": "The max_tokens value lmgw chose because the request set none and the route (an Anthropic upstream) requires one: the catalog's published maximum when streaming, 4096 when not streaming (the provider refuses non-streamed requests that could run too long).",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-max-tokens-raised": {
                "description": "The max_tokens value lmgw raised the request's cap to, because the requested thinking budget would not fit underneath it.",
                "schema": {
                  "type": "integer"
                }
              },
              "x-lmgw-params-ignored": {
                "description": "Comma-separated list of the request's sampling parameters (top_k, min_p, repeat_penalty, presence_penalty, frequency_penalty, seed) the answering model's provider does not take, so lmgw did not send them: the OpenAI platform takes no top_k, min_p or repeat_penalty; Anthropic none of the six but top_k; Gemini no min_p, repeat_penalty or penalties. llama.cpp and OpenAI-compatible providers are sent all of them. Also context_management and compaction, a /v1/messages request's Anthropic context management and on-demand compaction, which only an Anthropic model's route takes (both sent on as written), and thinking.display, which goes only to an Anthropic model, beside a thinking type that takes it (adaptive or enabled). Also content.<type>, a /v1/messages request's content block lmgw does not model (redacted_thinking, a type newer than lmgw), which only an Anthropic model's route is sent, and answer.<type>, such a block in an Anthropic model's whole answer, which a Chat Completions or Responses client is not given (a streamed answer's headers leave before it). On an Anthropic model's route, content.thinking and content.<type> name a thinking or other Anthropic block lmgw recorded from an answer at another provider's address (a stored /v1/responses chain), which this provider cannot read and is not sent. answer.citations and content.citations name an Anthropic text block's citations, which only a /v1/messages client and an Anthropic model's route are given (citations lmgw recorded from an answer only at that provider's address, and a citation with no text not at all). Request fields lmgw does not model are sent as they came and never listed. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed",
                    "context_management",
                    "compaction",
                    "thinking.display"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-params-refused": {
                "description": "Comma-separated list of the request's sampling parameters the answering model refused, which lmgw left out of the send (stop is not left out; its refusal reaches the client). A 400 whose words refuse exactly one parameter the request carried (Anthropic '`temperature` is deprecated for this model.', OpenAI 'Unsupported parameter: 'temperature' is not supported with this model.' or 'Unsupported value: 'temperature' does not support 0 with this model.') is retried once without exactly that parameter, the refused attempt logged with a note naming it, and when the retry answers the parameter is left out of that model's later requests too, each saying so here. Nothing is left out without a refusal on record. On a streamed /v1/responses run the header names what was on record when the stream opened. Absent when every parameter was sent.",
                "schema": {
                  "enum": [
                    "temperature",
                    "top_p",
                    "top_k",
                    "min_p",
                    "repeat_penalty",
                    "presence_penalty",
                    "frequency_penalty",
                    "seed"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-reasoning-ignored": {
                "description": "Comma-separated list of the reasoning controls (enabled, effort, budget) the route could not express. enabled is also listed when an off went out as no control or as the model's lowest level, either because the model cannot take the off itself or because the provider refused every form of off and the model answered with its default reasoning. An off sent to an Anthropic model as thinking type between_tools (its own lowest setting, when it takes no disabled) is not listed. between_tools: a /v1/messages request's thinking type between_tools went to a model of another provider as that provider's off. Absent when every control was applied.",
                "schema": {
                  "enum": [
                    "enabled",
                    "effort",
                    "budget",
                    "between_tools"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-rung": {
                "description": "On a ladder model, the rung that answered (or refused) the request, as '<k>/<n>; ctx=<per-slot context>; gguf=<weights file>', counted from 1 (the gguf part is left off when the file name cannot be a header value). A request whose prompt plus max output does not fit the running rung makes the model climb to the smallest rung that fits before it answers. On /v1/responses it names the rung running when the run opened; a unary answer one of whose turns the fallback answered carries x-lmgw-fallback instead, and a stream's headers are sent before its turns run. Absent on models without a ladder and on responses a fallback answered.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "x-lmgw-sse-events": {
              "response": {
                "$ref": "#/components/schemas/ResponseStreamEvent"
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Create a response",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": true
      }
    },
    "/v1/responses/input_tokens": {
      "post": {
        "description": "The OpenAI SDKs' responses.input_tokens.count(): the body a Responses create would send (input, instructions, function tools, a previous_response_id's stored conversation in front), counted on the route the model resolves to as the other counters count — exact on an Anthropic upstream (the Messages body the send would render, on Anthropic's own counter), a Gemini upstream and a local llama.cpp chat row; otherwise flattened, which x-lmgw-count-approximate says. mcp tools' definitions are not counted yet (tools_omitted), and what only an upstream's own Responses API serves is refused by name. Enforces the key's alias scope like every other counter; no budget applies.",
        "operationId": "post_v1_responses_input_tokens",
        "parameters": [
          {
            "description": "on|off: per-request thinking switch; it wins over body fields. On a cloud model, off goes out in the form the model takes: no reasoning control where the model has none, its lowest level where it cannot stop (x-lmgw-reasoning-ignored then lists enabled), thinking type between_tools on an Anthropic model whose catalog says it takes that type and not disabled. An off never ends in an error: a refused one is retried with what the refusal names and, failing that, with no reasoning control, so a model that cannot run without reasoning answers with its default reasoning. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "An effort level (see capabilities.reasoning.levels of the model); 'none' turns reasoning off. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-effort",
            "required": false,
            "schema": {
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "Integer thinking-token budget; 0 turns reasoning off. Expressible on llama.cpp, Gemini and budget-style Anthropic models only. Accepted on /v1/chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/input_tokens.",
            "in": "header",
            "name": "x-lmgw-reasoning-budget",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest",
                "example": {
                  "input": "Say hello in one short sentence.",
                  "model": "<pick a model>"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseInputTokens"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-count-approximate": {
                "description": "On the token counters, why the number is not exactly what the backend would count for this request; a comma-separated list. flattened: the request's structure was counted as plain text, so chat template, tool-definition and per-message overhead are not included and the real prompt is larger. tokenizer_guess: the backend's tokenizer is unknown, so the count uses tiktoken o200k_base. media_bound: images are counted at the model's per-image upper bound. media_omitted: image or audio parts are not in the number. message_framing: on /v1/count_tokens, the backend counts messages, so the text was counted as one user message, framing included. tools_omitted: on /v1/responses/input_tokens, the mcp tools' definitions (listed from their servers when a run starts) are not in the number. pending_calls_omitted: on /v1/responses/input_tokens, the stored response being continued is waiting on calls, whose results are not in the number. Absent when the count is exact.",
                "schema": {
                  "enum": [
                    "flattened",
                    "tokenizer_guess",
                    "media_bound",
                    "media_omitted",
                    "message_framing",
                    "tools_omitted",
                    "pending_calls_omitted"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Count a response's input tokens",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "openai"
        ],
        "x-lmgw-model-task": "chat",
        "x-lmgw-writes": false
      }
    },
    "/v1/responses/{id}": {
      "delete": {
        "description": "Deletes a stored response, or has the upstream that made a native one delete it. Read as GET is: another key's response is a 404.",
        "operationId": "delete_v1_responses_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseDeleted"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Delete a response",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": true
      },
      "get": {
        "description": "A stored response, exactly as it was served. It is present only when lmgw stored it — the creating call left store on (the default) while the gateway's response store was on — and only until retention evicts its conversation as a whole: by default 168 hours after the conversation's last activity, or once it falls outside the 500 most recently active conversations. A response an upstream that implements the Responses API made itself (created with store left on) is fetched from that upstream, query string included, and relayed as it answers, for as long as the same retention keeps lmgw's record of it. A client key reads only the responses it made, an owner key every one; another key's response is a 404 like an unknown id. 404 otherwise.",
        "operationId": "get_v1_responses_id",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Response"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Retrieve a response",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/responses/{id}/input_items": {
      "get": {
        "description": "This turn's `input` array as it was sent, for a stored response; for a native one, the upstream's answer with the query string forwarded. Read as GET is.",
        "operationId": "get_v1_responses_id_input_items",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseInputItems"
                }
              }
            },
            "description": "OK."
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error."
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "List a response's input items",
        "tags": [
          "openai"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/systemone": {
      "post": {
        "description": "TypeSafe's System One API as llama.cpp serves it: a state and a map of typed questions (choice, score, noul), answered with calibrated probabilities and no generated text. The client object is forwarded with only model rewritten, members in the order sent (a choice question's criteria order is its option order), and the answer comes back verbatim, its model included: the id that answered upstream, not the name asked for (x-lmgw-fallback names a fallback alias). The body is read as JSON whatever its Content-Type. Routes to a local decision model (an aux row of kind decision) or to an openai_compatible or llama_cpp upstream whose catalog does not rule the model out; any other model is 501 not_supported_error before a container starts. A local row whose image predates the route is a 501 too, once its container is up and answers the route 404. The upstream's own errors are relayed as sent (llama.cpp's 500 for a prompt over the ubatch included), except a 401/403, which is lmgw's credential and a 502. The key's alias scope and budgets apply; the row is priced from lmgw's own price rows, input tokens and, where the price row charges them, output tokens (Jev's does not). Errors lmgw answers itself are llama.cpp-shaped, except the shared /v1 layers' own: the gate's 401, 403 and 429, and the 413 for a declared Content-Length over max_body_mb, which are OpenAI-shaped.",
        "operationId": "post_v1_systemone",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "`POST /v1/systemone`'s body: a state and the questions to answer about it.\n\nlmgw reads only `model` from a client's body and forwards the rest as it\ncame; the upstream validates its own wire (TypeSafe answers a malformed\nquestion with 422, llama.cpp with 400).",
                "example": {
                  "model": "<pick a model>",
                  "questions": {
                    "department": {
                      "criteria": {
                        "billing": "payments, invoices, refunds, plan charges",
                        "sales": "new purchases, upgrades, quotes",
                        "technical": "bugs, outages, errors in the product",
                        "unsure": null
                      },
                      "instructions": "Which team should handle this ticket?",
                      "type": "choice"
                    },
                    "mood": {
                      "instructions": "The customer is upset.",
                      "type": "noul"
                    },
                    "urgency": {
                      "criteria": [
                        "not urgent",
                        "normal",
                        "urgent",
                        "critical"
                      ],
                      "instructions": "How urgent is this ticket?",
                      "type": "score"
                    }
                  },
                  "state": "Hi, my invoice from last month charged me twice for the Pro plan. Can you refund one of the charges?"
                },
                "properties": {
                  "files": {
                    "description": "llama.cpp's extension: files as data URLs (`images` is its alias).",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "images": {
                    "description": "llama.cpp's extension: images as data URLs, for a model started with a\nprojector and a type that reads images (501 otherwise). An alias of\n`files`. TypeSafe takes text only.",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "model": {
                    "description": "Required: lmgw routes by it, as TypeSafe requires it and llama-server's\nrouter mode needs it. Rewritten to the route's upstream model on the\nway out; nothing else is.",
                    "type": "string"
                  },
                  "questions": {
                    "additionalProperties": {
                      "$ref": "#/components/schemas/SystemOneQuestion"
                    },
                    "description": "The questions, keyed by ids the caller picks; the answers come back\nunder the same keys.",
                    "type": "object"
                  },
                  "state": {
                    "description": "What the questions are about: a string, or an object or array (a chat\nlog, a record), which llama.cpp gives the model as JSON text. `null`\nonly for the types that take none (LiquidAI's d1 models); llama.cpp\nrefuses it on the others."
                  }
                },
                "required": [
                  "model",
                  "state",
                  "questions"
                ],
                "title": "SystemOneRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SystemOneResponse"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlamaCppError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Ask a decision model",
        "tags": [
          "llamacpp"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "llamacpp",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-model-task": "decision",
        "x-lmgw-writes": false
      }
    },
    "/v1/tasks/run": {
      "post": {
        "description": "audio.cpp's own generic task route; request is relayed to the backend untouched, but for its text on a local model whose engine refuses a character its package lacks (Supertonic): that is fitted as speech's input is (x-lmgw-speech says how), and a text left with nothing to say is 400 empty_input.",
        "operationId": "post_v1_tasks_run",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "x-lmgw-untyped": "audio.cpp's own per-task JSON, relayed verbatim"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Run a generic task",
        "tags": [
          "lmgw-inference"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    },
    "/v1/tasks/stream": {
      "post": {
        "description": "The streaming-mode sibling of /v1/tasks/run.",
        "operationId": "post_v1_tasks_stream",
        "parameters": [
          {
            "description": "on|off: run this one request as background work, for speculative or prefetching clients. On a local model it uses the model only when that disturbs nobody: it joins the model if it is loaded and no foreground request is waiting for room, or starts it into free GPU memory (evicting only idle background-started models), and never evicts, waits for or climbs a model foreground work uses. Otherwise the model's configured fallback answers (x-lmgw-fallback, x-lmgw-fallback-reason: background), or the request is refused with 503 gpu_deferred: retry later. Foreground work never interrupts a background request that has started; close the request to cancel it. On a candidate alias it makes the alias walk as a background alias. A cloud model and a model running on the CPU are unaffected. Absent or off: an ordinary request. Any other value is a 400.",
            "in": "header",
            "name": "x-lmgw-background",
            "required": false,
            "schema": {
              "enum": [
                "on",
                "off"
              ],
              "type": "string"
            },
            "x-lmgw-audience": "client"
          },
          {
            "description": "The job id of the live agent run to attribute this request's cost, tokens and call count to. Only an agent token may attribute, and only to its own runs. An id that names no live run, a run that belongs to another agent, or a caller without an agent token is ignored with a log line and never refused.",
            "in": "header",
            "name": "x-lmgw-run",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "x-lmgw-audience": "agent"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "x-lmgw-untyped": "audio.cpp's own per-task stream, relayed verbatim"
                }
              }
            },
            "description": "OK.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAiError"
                }
              }
            },
            "description": "Error.",
            "headers": {
              "x-lmgw-candidate": {
                "description": "On a candidate alias, the id of the local model that answered (or refused) the request. Never sent next to x-lmgw-fallback. The body's model field still names the requested alias.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback": {
                "description": "The model or alias that answered instead of the one requested: the last hop of its chain of fallbacks (each model and alias has its own, and a fallback can have one in turn); the answer still names the requested model. On the chat routes, a fallback whose capabilities say it cannot see receives the request's images as text placeholders, and x-lmgw-images-omitted gives the count.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-chain": {
                "description": "Every hop a fallback-served answer was handed to, in order, each with the reason it was handed on, as an RFC 8941 list: \"m2\";reason=hold, \"cloud\";reason=hold. Sent on every answer a fallback served, next to x-lmgw-fallback (the last name) and x-lmgw-fallback-reason (the last reason), so a client reads one header whatever the chain's length. A name that cannot be an sf-string (a byte outside 0x20–0x7E) is left empty, the reason kept. A streamed /v1/responses run names the hops of its first turn only: its headers left with the first event.",
                "schema": {
                  "type": "string"
                }
              },
              "x-lmgw-fallback-reason": {
                "description": "Why x-lmgw-fallback answered (the last hop's reason; x-lmgw-fallback-chain has every hop's); always sent next to it. hold: the GPU hold pauses local models. benchmark: a benchmark run has the GPU to itself until it ends. external_vram: GPU memory used outside lmgw by another program left too little room to load the model, so the fallback answered at once instead of waiting. background: a background job's model could not load without disturbing foreground work (any request that is not background traffic: a background candidate alias's, or one sent with x-lmgw-background: on). unavailable: a candidate alias's primary cannot be used at all (missing, disabled, or lacking a capability the alias enables) and none of its other models is loaded. quota: the upstream answered that its account's quota is exhausted (insufficient_quota), or lmgw remembers it so until its next check; nothing was charged for the refused attempt. unreachable: the upstream could not be connected to, so nothing reached it. disabled: the model or alias asked for is disabled, or its upstream is. gpu_setup: the local model could not start on the graphics card, and lmgw's machine check names why (the card, its driver, or the piece that lets models use it, not ready on the computer lmgw runs on); while that check still describes the machine, the fallback answers without a start being tried. engine_download: the engine the local model runs in is not on the computer yet, and downloading it failed or cannot be done.",
                "schema": {
                  "enum": [
                    "hold",
                    "external_vram",
                    "background",
                    "unavailable",
                    "benchmark",
                    "quota",
                    "unreachable",
                    "disabled",
                    "gpu_setup",
                    "engine_download"
                  ],
                  "type": "string"
                }
              },
              "x-lmgw-speech": {
                "description": "On POST /v1/audio/speech (and on /v1/tasks/run and /v1/tasks/stream, for their chars part), what lmgw changed in the request so the model understands it; a '; '-separated list. voice=options.voice_id: a voice the model ships, which this family (MagpieTTS) reads from options.voice_id. voice=preset->options.voice_id: the same for a preset's voice id. voice=<name>: a shipped voice sent in the model's own spelling. language=<asked>-><sent>: the language in the model's own vocabulary, e.g. de->german for Qwen3-TTS, en->en-us for Kokoro. instructions=options.instruct: instructions moved to where the family reads them. instructions=also:options.instruct or instructions=also:options.instruction: the model's default request options describe the voice under that other key, which the engine would merge in beside the request's and refuse as conflicting, so the request's text went there too and replaces the default. instructions=dropped: the model reads none (capabilities.speech.instructions is none). tags=mapped:<n>,stripped:<n>: inline tags in input were rewritten into the model's spelling, or removed so they are never read out. chars=replaced:<U+XXXX/...>,dropped:<U+XXXX/...>: characters of input the model's engine has no entry for in its package's vocabulary (Supertonic refuses the whole request over one), replaced by an equivalent it has (a typographic quote by a plain one, a dash by -) or removed (an emoji). Each list names at most 64 codepoints and then ends in +<n> more; lmgw's log has the full list. An input left with nothing to say is 400 empty_input, which carries the header too. The voice, language and chars parts apply to local audio models only. Absent when the request went as it came; input changes only for its inline tags and those characters.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "apiKeyHeader": []
          },
          {
            "session": []
          },
          {}
        ],
        "summary": "Run a generic task (streaming)",
        "tags": [
          "lmgw-inference"
        ],
        "x-lmgw-capability": "inference",
        "x-lmgw-dialect": "openai",
        "x-lmgw-endpoints": [
          "other"
        ],
        "x-lmgw-writes": false
      }
    }
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "tags": [
    {
      "description": "OpenAI-compatible",
      "name": "openai",
      "x-displayName": "OpenAI-compatible",
      "x-lmgw-group": "Inference"
    },
    {
      "description": "Anthropic-compatible",
      "name": "anthropic",
      "x-displayName": "Anthropic-compatible",
      "x-lmgw-group": "Inference"
    },
    {
      "description": "llama.cpp-compatible",
      "name": "llamacpp",
      "x-displayName": "llama.cpp-compatible",
      "x-lmgw-group": "Inference"
    },
    {
      "description": "lmgw extensions",
      "name": "lmgw-inference",
      "x-displayName": "lmgw extensions",
      "x-lmgw-group": "Inference"
    },
    {
      "description": "MCP",
      "name": "mcp",
      "x-displayName": "MCP",
      "x-lmgw-group": "Inference"
    },
    {
      "description": "API description",
      "name": "meta",
      "x-displayName": "API description",
      "x-lmgw-group": "Gateway"
    },
    {
      "description": "The Chat API a client app uses as a paired device (the `chat` capability), with its client certificate on the device listener: the threads and folders it follows, an ongoing conversation's current thread, and the change feed that keeps them current. Every route here refuses a device with 401 device_key_unknown once its key opens no device (it was replaced or deleted: pair the device again), 403 device_unconfirmed until the owner confirms its enrolment, 401 device_disabled while the device is disabled, 401 device_certificate_expired past its certificate's notAfter, and 401 key_expired past its expiry date. What is open when that happens ends: the feed with `revoked`, a turn's stream with an `error` event whose code is revoked. Both carry `kind`, what to do: device_disabled and key_expired wait for the gateway's side, key_unknown and certificate_expired mean pair the device again, and revoked is any other kind of key's revocation.",
      "name": "chat",
      "x-displayName": "Chat",
      "x-lmgw-group": "Device API"
    },
    {
      "description": "Files between paired devices of one app (device transfers design): a device offers a file to another device that declared the same app id at pairing, uploads it to lmgw in ranges it can resume, and the other device is offered it once every byte matched its sha256, downloads it with ranges and says it arrived; lmgw then deletes the bytes. The transfer capability: paired devices (on the device listener) send and receive; the owner lists every transfer and cancels any; a client key or an agent token is refused 403 transfer_device_only. A refusal is the flat {code, message}, with free_bytes, received or state where its code names one. JSON bodies are at most 16 KiB (16384 bytes), refused 413 body_too_large; the only bound on a file is the free space of lmgw's data directory. The Chat feed's transfer.updated says each offer, ready and end to the sender, to the receiver from ready on, and to the owner.",
      "name": "transfers",
      "x-displayName": "Transfers",
      "x-lmgw-group": "Device API"
    },
    {
      "description": "The device listener's own routes (device link design §4.6): served on the device listener only, over TLS 1.3, and the 404 an unknown path is on the plain listener. Their bodies are at most 16 KiB (16384 bytes), refused 413 body_too_large naming it, not max_body_mb. Every answer carries Connection: close.",
      "name": "devices",
      "x-displayName": "Devices",
      "x-lmgw-group": "Device API"
    },
    {
      "description": "The routes an agent container calls with its own token: reading its own definition and runs, and opening and driving a run.",
      "name": "agent-runtime",
      "x-displayName": "Agent runtime",
      "x-lmgw-group": "Agent runtime"
    }
  ],
  "x-lmgw-principals": {
    "agent": [
      "public",
      "inference",
      "ledger",
      "agent-self"
    ],
    "anonymous": [
      "public"
    ],
    "anonymous_auth_off": [
      "public",
      "inference"
    ],
    "device": [
      "public",
      "inference",
      "chat",
      "transfer"
    ],
    "key": [
      "public",
      "inference"
    ],
    "owner": [
      "public",
      "inference",
      "chat",
      "transfer",
      "agent-self"
    ]
  }
}
