{
  "$id": "https://quickiso.app/standards/model-endpoint-v1.schema.json",
  "title": "QuickISO model endpoint standard, version 1 (quickiso-model-endpoint/1)",
  "description": "JSON Schemas of the requests QuickISO sends to an organization's own model endpoint and of the answers it accepts. The prose standard at /standards/model-endpoint is normative; QuickISO's client is tested against these schemas, so an answer the response schema refuses is one QuickISO refuses too.",
  "version": "1",
  "schemas": {
    "chatCompletionRequest": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "model": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+-]{0,127}$"
        },
        "messages": {
          "type": "array",
          "prefixItems": [
            {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "const": "system"
                },
                "content": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "role",
                "content"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "const": "user"
                },
                "content": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "role",
                "content"
              ],
              "additionalProperties": false
            }
          ],
          "items": false,
          "minItems": 2,
          "maxItems": 2
        },
        "response_format": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "json_schema"
            },
            "json_schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[a-z][a-z_]{0,63}$"
                },
                "strict": {
                  "type": "boolean",
                  "const": true
                },
                "schema": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                }
              },
              "required": [
                "name",
                "strict",
                "schema"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "type",
            "json_schema"
          ],
          "additionalProperties": false
        },
        "max_tokens": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8000
        },
        "temperature": {
          "type": "number",
          "const": 0
        },
        "stream": {
          "type": "boolean",
          "const": false
        }
      },
      "required": [
        "model",
        "messages",
        "response_format",
        "max_tokens",
        "temperature",
        "stream"
      ],
      "additionalProperties": false,
      "title": "QuickISO model endpoint standard 1: chat completion request",
      "description": "The only body QuickISO sends to POST {base}/v1/chat/completions. No other field is ever sent."
    },
    "chatCompletionResponse": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "choices": {
          "minItems": 1,
          "maxItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "message": {
                "type": "object",
                "properties": {
                  "content": {
                    "type": "string",
                    "maxLength": 131072,
                    "pattern": "\\S"
                  },
                  "refusal": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\s*$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tool_calls": {
                    "anyOf": [
                      {
                        "maxItems": 0,
                        "type": "array",
                        "items": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "content"
                ]
              },
              "finish_reason": {
                "type": "string",
                "const": "stop"
              }
            },
            "required": [
              "message",
              "finish_reason"
            ]
          }
        },
        "usage": {
          "type": "object",
          "properties": {
            "prompt_tokens": {
              "type": "integer",
              "minimum": 0,
              "maximum": 262144
            },
            "completion_tokens": {
              "type": "integer",
              "minimum": 0,
              "maximum": 65536
            }
          },
          "required": [
            "prompt_tokens",
            "completion_tokens"
          ]
        }
      },
      "required": [
        "choices",
        "usage"
      ],
      "title": "QuickISO model endpoint standard 1: chat completion response",
      "description": "An answer QuickISO accepts: exactly one choice whose content is one JSON value matching the request's own schema (checked by QuickISO after this envelope), finish_reason stop, no refusal text and no tool calls, and usage with both counts. Other fields are ignored and never stored. The max_tokens step of the connection check alone expects finish_reason length."
    },
    "modelList": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "object": {
          "type": "string",
          "maxLength": 64
        },
        "data": {
          "maxItems": 10000,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "maxLength": 256
              }
            },
            "required": [
              "id"
            ]
          }
        }
      },
      "required": [
        "data"
      ],
      "title": "QuickISO model endpoint standard 1: model list",
      "description": "GET {base}/v1/models. QuickISO reads data[].id only, and the configured model id must appear exactly."
    },
    "error": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "message": {
              "type": "string"
            },
            "type": {
              "type": "string"
            },
            "code": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "message",
            "type",
            "code"
          ]
        }
      },
      "required": [
        "error"
      ],
      "title": "QuickISO model endpoint standard 1: error body (recommended)",
      "description": "Optional. QuickISO reads the status code only and never parses, shows, stores or logs this body."
    }
  }
}
