{
  "openapi": "3.1.0",
  "info": {
    "title": "Kisch Inference API",
    "version": "0.1.0",
    "description": "The documented public inference surface in the Kisch local deployment template. This schema does not assert that a public deployment or model is currently online. The gateway accepts only the listed routes through the bundled public reverse proxy. Model-specific capabilities depend on the active upstream deployment."
  },
  "servers": [
    {
      "url": "http://localhost:4000",
      "description": "Local Compose reverse proxy. Replace with the base URL provided by the deployment operator."
    }
  ],
  "security": [{ "BearerAuth": [] }],
  "paths": {
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List models available to this key",
        "description": "Returns the model aliases visible to the supplied virtual key. An empty list can mean that no model has been configured. This response is deployment-specific.",
        "responses": {
          "200": {
            "description": "Models visible to this key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["object", "data"],
                  "properties": {
                    "object": { "const": "list" },
                    "data": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Model" }
                    }
                  }
                },
                "example": {
                  "object": "list",
                  "data": []
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "5XX": { "$ref": "#/components/responses/GatewayError" }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "createTextResponse",
        "summary": "Create a stateless text response",
        "description": "A narrow text-only Responses API request. Send a complete string input; response storage, previous_response_id, tools, multimodal input, background execution, and other Responses API features are outside this contract. The active upstream runtime must support the Responses endpoint.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextResponseRequest" },
              "example": {
                "model": "model-id-returned-by-v1-models",
                "input": "Say hello in five words.",
                "stream": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A text response or, when stream is true, a Server-Sent Events stream.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/TextResponse" } },
              "text/event-stream": { "schema": { "type": "string", "description": "Responses API SSE events from the upstream runtime." } }
            }
          },
          "400": { "$ref": "#/components/responses/GatewayError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/GatewayError" },
          "429": { "$ref": "#/components/responses/GatewayError" },
          "5XX": { "$ref": "#/components/responses/GatewayError" }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion",
        "description": "The documented request/response shape is OpenAI Chat Completions-style. Only basic text messages, the model field, stream, and the common generation controls shown here are in the public contract. Actual supported values depend on the upstream model. This does not imply full OpenAI API compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" },
              "example": {
                "model": "model-id-returned-by-v1-models",
                "messages": [{ "role": "user", "content": "Say hello in five words." }],
                "stream": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A completion response or, when stream is true, a Server-Sent Events stream.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChatCompletionResponse" }
              },
              "text/event-stream": {
                "schema": { "type": "string", "description": "SSE records containing partial completion chunks, terminated by data: [DONE]." }
              }
            }
          },
          "400": { "$ref": "#/components/responses/GatewayError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/GatewayError" },
          "429": { "$ref": "#/components/responses/GatewayError" },
          "5XX": { "$ref": "#/components/responses/GatewayError" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "LiteLLM virtual key" }
    },
    "schemas": {
      "Model": {
        "type": "object",
        "required": ["id", "object"],
        "properties": {
          "id": { "type": "string", "description": "Model alias accepted in the request's model field." },
          "object": { "const": "model" },
          "created": { "type": "integer" },
          "owned_by": { "type": "string" }
        }
      },
      "Message": {
        "type": "object",
        "required": ["role", "content"],
        "properties": {
          "role": { "type": "string", "enum": ["system", "developer", "user", "assistant"] },
          "content": { "type": "string" }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": { "type": "string", "description": "An alias currently returned by GET /v1/models." },
          "messages": { "type": "array", "items": { "$ref": "#/components/schemas/Message" }, "minItems": 1 },
          "stream": { "type": "boolean", "default": false },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "max_tokens": { "type": "integer", "minimum": 1, "description": "Some deployments may instead expose max_completion_tokens. Confirm the active model's runtime contract." },
          "stop": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] }
        },
        "additionalProperties": false
      },
      "TextResponseRequest": {
        "type": "object",
        "required": ["model", "input"],
        "properties": {
          "model": { "type": "string", "description": "An alias currently returned by GET /v1/models." },
          "input": { "type": "string", "description": "Plain text input; array and multimodal input are outside this contract." },
          "stream": { "type": "boolean", "default": false },
          "max_output_tokens": { "type": "integer", "minimum": 1 },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 }
        },
        "additionalProperties": false
      },
      "TextResponse": {
        "type": "object",
        "required": ["id", "object", "status", "output"],
        "properties": {
          "id": { "type": "string" },
          "object": { "const": "response" },
          "created_at": { "type": "integer" },
          "status": { "type": "string" },
          "model": { "type": "string" },
          "output": { "type": "array", "items": { "type": "object" } },
          "output_text": { "type": "string" }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": ["id", "object", "choices"],
        "properties": {
          "id": { "type": "string" },
          "object": { "const": "chat.completion" },
          "created": { "type": "integer" },
          "model": { "type": "string" },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["index", "message", "finish_reason"],
              "properties": {
                "index": { "type": "integer" },
                "message": {
                  "type": "object",
                  "required": ["role", "content"],
                  "properties": { "role": { "const": "assistant" }, "content": { "type": ["string", "null"] } }
                },
                "finish_reason": { "type": ["string", "null"] }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": { "type": "integer" },
              "completion_tokens": { "type": "integer" },
              "total_tokens": { "type": "integer" }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": { "type": "string" },
              "type": { "type": ["string", "null"] },
              "param": { "type": ["string", "null"] },
              "code": { "type": ["string", "integer", "null"] }
            }
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "The virtual key is missing, invalid, or not accepted.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "GatewayError": {
        "description": "Gateway or upstream error. Error details vary by failure and LiteLLM version.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    }
  }
}
