{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-inference-model-instance-schema.json",
  "title": "InferenceModelInstance",
  "description": "One loading or loaded incarnation of a model in this inference server. Backend session and composite-cache implementation details are private.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-models-api-openapi.yml#/components/schemas/InferenceModelInstance",
  "type": "object",
  "required": [
    "id",
    "model",
    "tasks",
    "state",
    "active_handles",
    "startup_managed",
    "unloadable",
    "residency_mode",
    "idle_ms"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Opaque incarnation identifier; changes after eviction and reload."
    },
    "model": {
      "type": "string"
    },
    "tasks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InferenceModelKind"
      }
    },
    "state": {
      "type": "string",
      "enum": [
        "loading",
        "loaded"
      ]
    },
    "active_handles": {
      "type": "integer",
      "format": "int64",
      "description": "Internal owners or loading waiters preventing eviction. This is not a count of HTTP requests."
    },
    "startup_managed": {
      "type": "boolean"
    },
    "unloadable": {
      "type": "boolean",
      "description": "Whether an unload would be permitted at snapshot time; concurrent use can change this."
    },
    "unload_blocked_reason": {
      "type": "string",
      "enum": [
        "loading",
        "in_use",
        "startup_managed"
      ]
    },
    "backend": {
      "type": "string",
      "description": "Selected execution backend, when known."
    },
    "residency_mode": {
      "type": "string",
      "enum": [
        "backend_managed",
        "streamed",
        "resident"
      ],
      "description": "Weight residency policy; loaded does not imply full device residency."
    },
    "idle_ms": {
      "type": "integer",
      "format": "int64",
      "description": "Elapsed milliseconds since last use, not a wall-clock timestamp."
    }
  },
  "$defs": {
    "InferenceModelKind": {
      "type": "string",
      "description": "Model registry kind.",
      "enum": [
        "generator",
        "embedder",
        "reranker",
        "chunker",
        "classifier",
        "rewriter",
        "reader",
        "transcriber",
        "extractor"
      ]
    }
  }
}