{
  "openapi": "3.1.0",
  "info": {
    "title": "Makoda local gateway",
    "version": "0.1.0",
    "description": "Development preview. Trusted-local Codex agent mode; not a tool-free model API. Fixture mode never invokes Codex. All operational routes require a gateway bearer token and exact loopback Host; browser Origins are rejected."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:43127"
    }
  ],
  "security": [
    {
      "integrationToken": []
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "operationId": "health",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "service": {
                      "const": "makoda"
                    },
                    "status": {
                      "const": "running"
                    }
                  },
                  "required": [
                    "service",
                    "status"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/capabilities": {
      "get": {
        "operationId": "capabilities",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Model"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/jobs": {
      "post": {
        "operationId": "createJob",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[!-~]+$"
            },
            "description": "Stable for the same logical attempt. Retained 7 days. Changing key can buy new inference."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted or prior job for the same key and request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/v1/jobs/{id}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/v1/jobs/{id}/events": {
      "get": {
        "operationId": "jobEvents",
        "parameters": [
          {
            "name": "Last-Event-ID",
            "in": "header",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lifecycle events with monotonic IDs. No text deltas. Terminal result is retrieved through GET job. Replay retained with job metadata.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/v1/usage": {
      "get": {
        "operationId": "integrationUsage",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationUsage"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/openapi.json": {
      "get": {
        "operationId": "openApi",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/providers": {
      "get": {
        "operationId": "listProviders",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PublicProviderStatus"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "integrationToken": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Input": {
        "type": "object",
        "properties": {
          "role": {
            "const": "user"
          },
          "content": {
            "type": "string",
            "minLength": 1,
            "description": "UTF-8 byte length limited to 200 KiB."
          }
        },
        "required": [
          "role",
          "content"
        ],
        "additionalProperties": false
      },
      "JobRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "description": "Exact model for this request: upstream_id with explicit provider, or namespaced id. Checked against discovery for each new request; an existing idempotency binding replays without revalidating the current catalog."
          },
          "reasoning_effort": {
            "type": "string"
          },
          "input": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Input"
            },
            "minItems": 1,
            "maxItems": 1
          },
          "response_format": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "const": "text"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "const": "json_schema"
                  },
                  "schema": {
                    "type": [
                      "object",
                      "boolean"
                    ],
                    "description": "Bounded JSON Schema subset. No references, regex, formats, dynamic schema or unevaluated keywords. See capabilities and quickstart."
                  }
                },
                "required": [
                  "type",
                  "schema"
                ],
                "additionalProperties": false
              }
            ]
          },
          "timeout_ms": {
            "type": "integer",
            "minimum": 1000,
            "maximum": 900000,
            "default": 180000
          },
          "provider": {
            "type": "string",
            "enum": [
              "codex",
              "claude"
            ],
            "description": "Optional explicit provider. Supply an exact upstream_id from discovery, or its matching provider-prefixed id. Without provider a namespaced model is required. Provider/model spelling remains part of the original client-request idempotency fingerprint. No default or fallback provider/model/effort."
          },
          "attachments": {
            "type": "array",
            "maxItems": 4,
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "default": [],
            "description": "Optional inline caller-supplied images and UTF-8 documents. No filesystem paths or URLs. Decoded content is retained only while the job is nonterminal, then removed with the request. Maximum 4 MiB each, 5 MiB total; prompt plus text-document content and framing at most 200 KiB. Supported media types depend on the selected model."
          }
        },
        "required": [
          "model",
          "reasoning_effort",
          "input"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "job_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "details": {
                "type": "object"
              }
            },
            "required": [
              "code",
              "message",
              "retryable",
              "job_id",
              "details"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "Result": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "json": {},
          "usage": {
            "type": [
              "object",
              "null"
            ]
          },
          "provider": {
            "enum": [
              "codex",
              "claude"
            ]
          },
          "cli_version": {
            "type": "string"
          }
        },
        "required": [
          "text",
          "usage",
          "provider",
          "cli_version"
        ],
        "additionalProperties": false
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "integration_id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "reasoning_effort": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "cancelling",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "result_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "idempotency_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "result_availability": {
            "enum": [
              "pending",
              "available",
              "none",
              "expired"
            ]
          },
          "result": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Result"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string",
                    "description": "Optional human-readable guidance. Present for newly recorded timed_out jobs; older stored jobs may contain only code. A timeout can consume provider allowance and does not establish whether output exists upstream."
                  }
                },
                "required": [
                  "code"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "execution_mode": {
            "enum": [
              "fixture",
              "trusted_local_agent"
            ]
          },
          "adapter_version": {
            "type": "string"
          },
          "metrics": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/JobMetrics"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "integration_id",
          "model",
          "reasoning_effort",
          "status",
          "created_at",
          "updated_at",
          "result_expires_at",
          "idempotency_expires_at",
          "result_availability",
          "result",
          "error",
          "execution_mode",
          "adapter_version",
          "metrics"
        ],
        "additionalProperties": false
      },
      "Model": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "upstream_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "reasoning_efforts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "verification": {
            "enum": [
              "fixture",
              "catalogued",
              "documented_alias"
            ],
            "description": "catalogued comes from installed Codex cache. documented_alias is documented Claude CLI syntax, not proof of account entitlement or resolved model."
          },
          "output_streaming": {
            "const": "final_only"
          },
          "structured_output": {
            "type": "boolean"
          },
          "provider": {
            "enum": [
              "codex",
              "claude"
            ]
          },
          "input_modalities": {
            "type": "array",
            "items": {
              "enum": [
                "text",
                "image"
              ]
            }
          },
          "attachment_media_types": {
            "type": "array",
            "items": {
              "enum": [
                "image/png",
                "image/jpeg",
                "text/plain",
                "text/markdown",
                "application/json",
                "text/csv"
              ]
            }
          }
        },
        "required": [
          "id",
          "upstream_id",
          "display_name",
          "reasoning_efforts",
          "verification",
          "output_streaming",
          "structured_output",
          "provider",
          "input_modalities",
          "attachment_media_types"
        ],
        "additionalProperties": false
      },
      "IntegrationUsage": {
        "type": "object",
        "properties": {
          "integration_usage": {
            "type": "object",
            "properties": {
              "retained_jobs": {
                "type": "integer"
              },
              "succeeded": {
                "type": "integer"
              },
              "failed": {
                "type": "integer"
              }
            },
            "required": [
              "retained_jobs",
              "succeeded",
              "failed"
            ],
            "additionalProperties": false
          },
          "window": {
            "const": "retained_7_days"
          },
          "stats": {
            "$ref": "#/components/schemas/UsageStats"
          }
        },
        "required": [
          "integration_usage",
          "window",
          "stats"
        ],
        "additionalProperties": false
      },
      "Capabilities": {
        "type": "object",
        "properties": {
          "contract_version": {
            "type": "string"
          },
          "execution_mode": {
            "enum": [
              "fixture",
              "trusted_local_agent"
            ]
          },
          "remote_access": {
            "const": false
          },
          "output_streaming": {
            "const": "final_only"
          },
          "job_events": {
            "const": true
          },
          "provider_limits": {
            "const": false
          },
          "input_roles": {
            "type": "array",
            "items": {
              "const": "user"
            }
          },
          "max_input_messages": {
            "const": 1
          },
          "limits": {
            "type": "object",
            "properties": {
              "request_bytes": {
                "type": "integer"
              },
              "queued_jobs": {
                "type": "integer"
              },
              "concurrent_jobs": {
                "type": "integer"
              },
              "max_timeout_ms": {
                "type": "integer"
              },
              "queue_timeout_ms": {
                "type": "integer"
              },
              "result_ttl_seconds": {
                "type": "integer"
              },
              "idempotency_ttl_seconds": {
                "type": "integer"
              },
              "attachments": {
                "type": "integer",
                "minimum": 0
              },
              "attachment_bytes": {
                "type": "integer",
                "minimum": 0
              },
              "total_attachment_bytes": {
                "type": "integer",
                "minimum": 0
              },
              "text_context_bytes": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "request_bytes",
              "queued_jobs",
              "concurrent_jobs",
              "max_timeout_ms",
              "queue_timeout_ms",
              "result_ttl_seconds",
              "idempotency_ttl_seconds",
              "attachments",
              "attachment_bytes",
              "total_attachment_bytes",
              "text_context_bytes"
            ],
            "additionalProperties": false
          },
          "schema_dialect": {
            "const": "bounded_subset"
          },
          "docs": {
            "type": "string"
          }
        },
        "required": [
          "contract_version",
          "execution_mode",
          "remote_access",
          "output_streaming",
          "job_events",
          "provider_limits",
          "input_roles",
          "max_input_messages",
          "limits",
          "schema_dialect",
          "docs"
        ],
        "additionalProperties": false
      },
      "TokenUsage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "cached_input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "reasoning_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "total_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "cache_read_input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "cache_creation_input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          }
        },
        "required": [
          "input_tokens",
          "cached_input_tokens",
          "output_tokens",
          "reasoning_output_tokens",
          "total_tokens",
          "cache_read_input_tokens",
          "cache_creation_input_tokens"
        ],
        "additionalProperties": false,
        "description": "Actual provider-reported counters only. Null means unreported, never zero. Fields can have different aggregate coverage. Codex cached_input_tokens is part of its input count; Claude cache_read_input_tokens and cache_creation_input_tokens have separate provider semantics. Counters are never combined into synthesized totals."
      },
      "JobMetrics": {
        "type": "object",
        "properties": {
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Milliseconds from job admission to terminal state, including queue time. Measured for new requests; null for older or unfinished jobs or a backwards wall-clock change."
          },
          "usage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TokenUsage"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "latency_ms",
          "usage"
        ],
        "additionalProperties": false,
        "description": "Small per-request counters retained with job metadata for seven days, after result content expires. Does not include prompts, output content or credentials."
      },
      "UsageGroup": {
        "type": "object",
        "properties": {
          "integration_id": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "requested_model": {
            "type": "string"
          },
          "resolved_model": {
            "type": [
              "string",
              "null"
            ],
            "description": "Authoritatively reported resolved model, otherwise null. The current Codex adapter does not report this."
          },
          "reasoning_effort": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "cancelling",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "jobs": {
            "type": "integer",
            "minimum": 0
          },
          "latency_ms_total": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "latency_samples": {
            "type": "integer",
            "minimum": 0
          },
          "usage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TokenUsage"
              },
              {
                "type": "null"
              }
            ]
          },
          "usage_samples": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of jobs with at least one reported usage counter; individual counters may have lower coverage."
          }
        },
        "required": [
          "integration_id",
          "provider",
          "requested_model",
          "resolved_model",
          "reasoning_effort",
          "status",
          "jobs",
          "latency_ms_total",
          "latency_samples",
          "usage",
          "usage_samples"
        ],
        "additionalProperties": false
      },
      "UsageStats": {
        "type": "object",
        "properties": {
          "window": {
            "const": "retained_7_days"
          },
          "retained_jobs": {
            "type": "integer",
            "minimum": 0
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UsageGroup"
            }
          }
        },
        "required": [
          "window",
          "retained_jobs",
          "groups"
        ],
        "additionalProperties": false,
        "description": "All retained jobs, without the activity-list row cap, grouped by integration, provider, requested/resolved model, reasoning effort and status. No subscription allowance or cost estimates. HTTP usage is scoped to the authenticated integration; desktop owner stats include all integrations."
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Display label only. No slash, backslash or control characters. Never used as a filesystem path."
          },
          "media_type": {
            "enum": [
              "image/png",
              "image/jpeg",
              "text/plain",
              "text/markdown",
              "application/json",
              "text/csv"
            ]
          },
          "data_base64": {
            "type": "string",
            "contentEncoding": "base64",
            "maxLength": 5592408
          }
        },
        "required": [
          "name",
          "media_type",
          "data_base64"
        ],
        "additionalProperties": false,
        "description": "Strict standard base64. PNG/JPEG decoded with image dimension/allocation limits. UTF-8 text cannot contain NUL. PDF, DOCX, URLs, paths and other binary formats are unsupported."
      },
      "AllowanceWindow": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "used_percent": {
            "type": "number",
            "minimum": 0
          },
          "window_duration_minutes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "resets_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "reset_label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Localized reset text reported by the CLI, used when no ISO reset timestamp is supplied. Never infer a date from this label."
          }
        },
        "required": [
          "label",
          "used_percent",
          "window_duration_minutes",
          "resets_at"
        ],
        "additionalProperties": false
      },
      "ProviderAllowance": {
        "type": "object",
        "properties": {
          "windows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AllowanceWindow"
            }
          },
          "source": {
            "type": "string"
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "is_stale": {
            "type": "boolean",
            "default": false,
            "description": "True when the source identifies its allowance as last-known or a previous observation is retained after a failed refresh. checked_at is an observation time, not a guarantee the upstream data is fresh."
          }
        },
        "required": [
          "windows",
          "source",
          "checked_at"
        ],
        "additionalProperties": false,
        "description": "Owner-only allowance from an official non-inference source. Null allowance means unknown or unavailable; never estimate from local jobs. Remaining percentage is max(0,100-used_percent), not token count."
      },
      "PublicProviderStatus": {
        "type": "object",
        "properties": {
          "id": {
            "enum": [
              "codex",
              "claude"
            ]
          },
          "version": {
            "type": [
              "string",
              "null"
            ]
          },
          "auth_mode": {
            "enum": [
              "chatgpt",
              "claude_subscription",
              "api_key",
              "unknown"
            ]
          },
          "ready": {
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "version",
          "auth_mode",
          "ready",
          "code",
          "checked_at"
        ],
        "additionalProperties": false,
        "description": "Cached non-inference readiness, without account identifiers, allowance or other integrations workload. Model catalog verification and capabilities are supplied separately in /v1/models."
      },
      "ProviderStatus": {
        "type": "object",
        "properties": {
          "id": {
            "enum": [
              "codex",
              "claude"
            ]
          },
          "version": {
            "type": [
              "string",
              "null"
            ]
          },
          "auth_mode": {
            "enum": [
              "chatgpt",
              "claude_subscription",
              "api_key",
              "unknown"
            ]
          },
          "ready": {
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "allowance": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ProviderAllowance"
              },
              {
                "type": "null"
              }
            ]
          },
          "queued_jobs": {
            "type": "integer",
            "minimum": 0
          },
          "active_jobs": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "id",
          "version",
          "auth_mode",
          "ready",
          "code",
          "checked_at",
          "allowance",
          "queued_jobs",
          "active_jobs"
        ],
        "additionalProperties": false,
        "description": "Owner-only desktop IPC snapshot. Reads use cached probes; explicit recheck refreshes bounded non-inference CLI probes. Active/queued counts are live local job counts, not token allowance."
      }
    }
  }
}
