{
  "components": {
    "schemas": {
      "Asset": {
        "properties": {
          "format": {
            "enum": [
              "png",
              "jpeg",
              "webp"
            ],
            "title": "Format",
            "type": "string"
          },
          "height": {
            "title": "Height",
            "type": "integer"
          },
          "id": {
            "pattern": "^[0-9a-f]{32}$",
            "title": "Id",
            "type": "string"
          },
          "width": {
            "title": "Width",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "width",
          "height",
          "format"
        ],
        "title": "Asset",
        "type": "object"
      },
      "Detect": {
        "properties": {
          "confidence": {
            "default": 0.3,
            "exclusiveMaximum": 1.0,
            "exclusiveMinimum": 0.0,
            "title": "Confidence",
            "type": "number"
          },
          "image_ids": {
            "items": {
              "pattern": "^[0-9a-f]{32}$",
              "type": "string"
            },
            "maxItems": 32,
            "minItems": 1,
            "title": "Image Ids",
            "type": "array"
          }
        },
        "required": [
          "image_ids"
        ],
        "title": "Detect",
        "type": "object"
      },
      "EngineState": {
        "properties": {
          "generating": {
            "title": "Generating",
            "type": "boolean"
          },
          "id": {
            "description": "Engine ID used in generation control routes.",
            "examples": [
              "sdcpp"
            ],
            "title": "Id",
            "type": "string"
          },
          "idle_timeout_seconds": {
            "title": "Idle Timeout Seconds",
            "type": "integer"
          },
          "loaded": {
            "title": "Loaded",
            "type": "boolean"
          },
          "loading": {
            "title": "Loading",
            "type": "boolean"
          },
          "models": {
            "items": {
              "type": "string"
            },
            "title": "Models",
            "type": "array"
          },
          "resident_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resident Model"
          }
        },
        "required": [
          "id",
          "loaded",
          "loading",
          "generating",
          "resident_model",
          "models",
          "idle_timeout_seconds"
        ],
        "title": "EngineState",
        "type": "object"
      },
      "GenerationEngine": {
        "properties": {
          "id": {
            "description": "Engine ID used in generation control routes.",
            "examples": [
              "sdcpp"
            ],
            "title": "Id",
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "GenerationEngine",
        "type": "object"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "title": "Detail",
            "type": "array"
          }
        },
        "title": "HTTPValidationError",
        "type": "object"
      },
      "Match": {
        "properties": {
          "image_ids": {
            "items": {
              "pattern": "^[0-9a-f]{32}$",
              "type": "string"
            },
            "maxItems": 32,
            "minItems": 1,
            "title": "Image Ids",
            "type": "array"
          },
          "queries": {
            "items": {
              "maxLength": 160,
              "minLength": 1,
              "type": "string"
            },
            "maxItems": 16,
            "minItems": 1,
            "title": "Queries",
            "type": "array"
          }
        },
        "required": [
          "image_ids",
          "queries"
        ],
        "title": "Match",
        "type": "object"
      },
      "ModelSelection": {
        "additionalProperties": false,
        "properties": {
          "model": {
            "description": "Generation model ID from GET /v1/models.",
            "examples": [
              "imagies-sd-turbo"
            ],
            "maxLength": 160,
            "minLength": 1,
            "pattern": "^\\S+$",
            "title": "Model",
            "type": "string"
          }
        },
        "required": [
          "model"
        ],
        "title": "ModelSelection",
        "type": "object"
      },
      "Montage": {
        "properties": {
          "cell_height": {
            "default": 180,
            "maximum": 4096.0,
            "minimum": 1.0,
            "title": "Cell Height",
            "type": "integer"
          },
          "cell_width": {
            "default": 320,
            "maximum": 4096.0,
            "minimum": 1.0,
            "title": "Cell Width",
            "type": "integer"
          },
          "columns": {
            "default": 3,
            "maximum": 8.0,
            "minimum": 1.0,
            "title": "Columns",
            "type": "integer"
          },
          "image_ids": {
            "items": {
              "pattern": "^[0-9a-f]{32}$",
              "type": "string"
            },
            "maxItems": 32,
            "minItems": 2,
            "title": "Image Ids",
            "type": "array"
          }
        },
        "required": [
          "image_ids"
        ],
        "title": "Montage",
        "type": "object"
      },
      "Transform": {
        "properties": {
          "crop": {
            "anyOf": [
              {
                "maxItems": 4,
                "minItems": 4,
                "prefixItems": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  }
                ],
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "description": "Crop rectangle as x, y, width, height before resize.",
            "title": "Crop"
          },
          "fit": {
            "default": "contain",
            "enum": [
              "contain",
              "cover",
              "pad",
              "stretch"
            ],
            "title": "Fit",
            "type": "string"
          },
          "format": {
            "default": "png",
            "enum": [
              "png",
              "jpeg",
              "webp"
            ],
            "title": "Format",
            "type": "string"
          },
          "height": {
            "anyOf": [
              {
                "maximum": 4096.0,
                "minimum": 1.0,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Height"
          },
          "image_id": {
            "pattern": "^[0-9a-f]{32}$",
            "title": "Image Id",
            "type": "string"
          },
          "width": {
            "anyOf": [
              {
                "maximum": 4096.0,
                "minimum": 1.0,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Width"
          }
        },
        "required": [
          "image_id"
        ],
        "title": "Transform",
        "type": "object"
      },
      "UnloadResult": {
        "properties": {
          "unloaded": {
            "description": "IDs of models and vision engines released.",
            "items": {
              "type": "string"
            },
            "title": "Unloaded",
            "type": "array"
          }
        },
        "required": [
          "unloaded"
        ],
        "title": "UnloadResult",
        "type": "object"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "title": "Location",
            "type": "array"
          },
          "msg": {
            "title": "Message",
            "type": "string"
          },
          "type": {
            "title": "Error Type",
            "type": "string"
          }
        },
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError",
        "type": "object"
      }
    }
  },
  "info": {
    "title": "Imagies",
    "version": "0.2.1"
  },
  "openapi": "3.1.0",
  "paths": {
    "/healthz": {
      "get": {
        "description": "Process health. No authentication required.",
        "operationId": "health_healthz_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "title": "Response Health Healthz Get",
                  "type": "object"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Health",
        "tags": [
          "Service"
        ]
      }
    },
    "/v1/engines": {
      "get": {
        "description": "List vision engines that can use installed weights or a configured download.",
        "operationId": "engines_v1_engines_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "title": "Response Engines V1 Engines Get",
                  "type": "object"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Engines",
        "tags": [
          "Service"
        ]
      }
    },
    "/v1/generation/engines": {
      "get": {
        "description": "List the configured image generation engines.",
        "operationId": "engines_v1_generation_engines_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/GenerationEngine"
                  },
                  "title": "Response Engines V1 Generation Engines Get",
                  "type": "array"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Engines",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/generation/engines/{engine}": {
      "get": {
        "description": "Read the engine state and available model IDs.",
        "operationId": "engine_state_v1_generation_engines__engine__get",
        "parameters": [
          {
            "description": "ID from GET /v1/generation/engines.",
            "in": "path",
            "name": "engine",
            "required": true,
            "schema": {
              "description": "ID from GET /v1/generation/engines.",
              "examples": [
                "sdcpp"
              ],
              "title": "Engine",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngineState"
                }
              }
            },
            "description": "Successful Response"
          },
          "404": {
            "description": "Unknown generation engine."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Engine State",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/generation/engines/{engine}/active": {
      "delete": {
        "description": "Cancel the engine's active generation. Succeeds if it is already idle.",
        "operationId": "cancel_generation_v1_generation_engines__engine__active_delete",
        "parameters": [
          {
            "description": "ID from GET /v1/generation/engines.",
            "in": "path",
            "name": "engine",
            "required": true,
            "schema": {
              "description": "ID from GET /v1/generation/engines.",
              "examples": [
                "sdcpp"
              ],
              "title": "Engine",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "404": {
            "description": "Unknown generation engine."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Cancel Generation",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/generation/engines/{engine}/model": {
      "delete": {
        "description": "Unload the resident model. Returns 409 while the engine is busy.",
        "operationId": "unload_model_v1_generation_engines__engine__model_delete",
        "parameters": [
          {
            "description": "ID from GET /v1/generation/engines.",
            "in": "path",
            "name": "engine",
            "required": true,
            "schema": {
              "description": "ID from GET /v1/generation/engines.",
              "examples": [
                "sdcpp"
              ],
              "title": "Engine",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "404": {
            "description": "Unknown generation engine."
          },
          "409": {
            "description": "The engine is loading or generating."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Unload Model",
        "tags": [
          "Generation"
        ]
      },
      "put": {
        "description": "Load the selected model and wait until the engine is ready.",
        "operationId": "select_model_v1_generation_engines__engine__model_put",
        "parameters": [
          {
            "description": "ID from GET /v1/generation/engines.",
            "in": "path",
            "name": "engine",
            "required": true,
            "schema": {
              "description": "ID from GET /v1/generation/engines.",
              "examples": [
                "sdcpp"
              ],
              "title": "Engine",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModelSelection"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "400": {
            "description": "The engine does not serve the requested model."
          },
          "404": {
            "description": "Unknown generation engine."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          },
          "503": {
            "description": "The engine could not load the model."
          }
        },
        "summary": "Select Model",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/images": {
      "post": {
        "description": "Stage a PNG, JPEG or WebP still image up to 20 MiB as raw request bytes.",
        "operationId": "upload_v1_images_post",
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            },
            "image/jpeg": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            },
            "image/png": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            },
            "image/webp": {
              "schema": {
                "format": "binary",
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Asset"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Upload",
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/images/detect": {
      "post": {
        "description": "Return YOLO object labels, scores and normalized boxes.",
        "operationId": "detect_v1_images_detect_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Detect"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "items": {
                      "additionalProperties": true,
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "title": "Response Detect V1 Images Detect Post",
                  "type": "object"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Detect",
        "tags": [
          "Analysis"
        ]
      }
    },
    "/v1/images/generations": {
      "post": {
        "description": "Generate an image using the OpenAI-compatible image API.",
        "operationId": "generate_image_v1_images_generations_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "description": "Model ID from GET /v1/models.",
                    "maxLength": 160,
                    "minLength": 1,
                    "title": "Model",
                    "type": "string"
                  },
                  "n": {
                    "default": 1,
                    "maximum": 4.0,
                    "minimum": 1.0,
                    "title": "N",
                    "type": "integer"
                  },
                  "prompt": {
                    "maxLength": 16384,
                    "minLength": 1,
                    "title": "Prompt",
                    "type": "string"
                  },
                  "response_format": {
                    "anyOf": [
                      {
                        "enum": [
                          "b64_json",
                          "url"
                        ],
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "Response Format"
                  },
                  "size": {
                    "anyOf": [
                      {
                        "pattern": "^[1-9]\\d{0,3}x[1-9]\\d{0,3}$|^auto$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "Size"
                  }
                },
                "required": [
                  "model",
                  "prompt"
                ],
                "title": "GenerationRequest",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {}
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Generate Image",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/images/match": {
      "post": {
        "description": "Rank text queries against each staged image with CLIP.",
        "operationId": "match_v1_images_match_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Match"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "items": {
                      "additionalProperties": true,
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "title": "Response Match V1 Images Match Post",
                  "type": "object"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Match",
        "tags": [
          "Analysis"
        ]
      }
    },
    "/v1/images/montage": {
      "post": {
        "description": "Lay out staged still images in a single grid.",
        "operationId": "montage_v1_images_montage_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Montage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Asset"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Montage",
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/images/transform": {
      "post": {
        "description": "Crop, resize and encode a staged image.",
        "operationId": "transform_v1_images_transform_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Transform"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Asset"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Transform",
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/images/{image_id}": {
      "delete": {
        "description": "Delete a staged image.",
        "operationId": "delete_v1_images__image_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "image_id",
            "required": true,
            "schema": {
              "pattern": "^[0-9a-f]{32}$",
              "title": "Image Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete",
        "tags": [
          "Images"
        ]
      },
      "get": {
        "description": "Download a staged image by ID.",
        "operationId": "download_v1_images__image_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "image_id",
            "required": true,
            "schema": {
              "pattern": "^[0-9a-f]{32}$",
              "title": "Image Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {}
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Download",
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/models": {
      "get": {
        "description": "List local image generation model IDs.",
        "operationId": "models_v1_models_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {}
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Models",
        "tags": [
          "Generation"
        ]
      }
    },
    "/v1/unload": {
      "post": {
        "description": "Stop resident generation and vision model processes and return their IDs.",
        "operationId": "unload_all_v1_unload_post",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnloadResult"
                }
              }
            },
            "description": "Successful Response"
          },
          "409": {
            "description": "A model is loading or processing a request."
          }
        },
        "summary": "Unload all models",
        "tags": [
          "Service"
        ]
      }
    }
  }
}
