{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spicyapi/json-schema/spicyapi-model-envelope-schema.json",
  "title": "ModelEnvelope",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spicyapi-models-api-openapi.yml#/components/schemas/ModelEnvelope",
  "allOf": [
    {
      "$ref": "#/$defs/EnvelopeBase"
    },
    {
      "type": "object",
      "required": [
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "const": 200
        },
        "msg": {
          "type": "string",
          "const": "success"
        },
        "data": {
          "$ref": "#/$defs/APIModel"
        }
      }
    }
  ],
  "$defs": {
    "APIModel": {
      "type": "object",
      "required": [
        "model",
        "family",
        "displayName",
        "provider",
        "modality",
        "tasks",
        "async",
        "mature",
        "policyTier",
        "taskTimeoutSeconds",
        "enabled",
        "available",
        "quantityField",
        "pricing",
        "version",
        "availability",
        "badges",
        "relatedModels",
        "updatedAt"
      ],
      "properties": {
        "model": {
          "type": "string",
          "description": "Preferred callable identifier in publisher/model/task form. Image editing uses the edit suffix; previously published identifiers remain accepted."
        },
        "family": {
          "type": "string",
          "description": "Stable product-family identifier; endpoint variants are listed in `tasks` and expressed by `inputSchema`."
        },
        "displayName": {
          "type": "string"
        },
        "provider": {
          "type": "string",
          "description": "Model creator/author identifier, such as the research lab that built the model."
        },
        "modality": {
          "type": "string",
          "enum": [
            "image",
            "video",
            "audio",
            "text"
          ]
        },
        "tasks": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The internal task classification of this one endpoint. Always exactly one element, and it is not always the suffix of `model`: image editing endpoints are published as `.../edit` but classified as `image-to-image`, because renaming the call did not reclassify the work. Use `model` to call, and `tasks[0]` only to group or filter. Other values match their suffix: `text-to-image`, `text-to-video`, `image-to-video`, `reference-to-video`, `video-edit`, `video-extend`, `video-analyze`, `character-animation`, `talking-avatar`, `lip-sync`, `video-to-audio` (returns the same video with a generated sound track), `frame-interpolation` (returns the same video at twice its frame rate, same length and audio), `layer-decomposition` (returns a base image plus transparent layers, see `TaskOutputAsset.layer`), `speech-to-text`, `chat`. New values appear as models are added, so treat the set as open."
        },
        "async": {
          "type": "boolean"
        },
        "mature": {
          "type": "boolean",
          "description": "Informational model-creator capability metadata only. It does not participate in authorization, availability decisions, or request rejection."
        },
        "policyTier": {
          "type": "string",
          "enum": [
            "unrestricted",
            "borderline",
            "softened",
            "filtered",
            "unspecified"
          ],
          "description": "Informational model-creator policy metadata only. It does not participate in authorization, availability decisions, or request rejection. `unrestricted`: the model adds no refusal layer of its own. `borderline`: its own policy lets some requests through and may still decline others. `softened`: it does not refuse and does not fail — it quietly returns a toned-down result, and that task settles and is charged like any other success. `filtered`: it declines requests its own policy restricts, which surfaces as a `content_rejected` failure. `unspecified`: no tier has been recorded for this model. Treat the set as open: a value you do not recognise must not break your client."
        },
        "toolkit": {
          "type": "string",
          "enum": [
            "subject-swap",
            "studio-tools"
          ],
          "description": "Which toolkit family this model belongs to (subject-swap for identity swaps; studio-tools for single-purpose image and video tools such as background removal or upscaling). Informational classification for catalogue grouping only; it does not participate in routing, pricing or authorization. Absent when the model is not part of a toolkit."
        },
        "taskTimeoutSeconds": {
          "type": "integer",
          "minimum": 1,
          "description": "Absolute platform execution deadline before timeout/refund; not media output duration."
        },
        "maxOutputDurationSeconds": {
          "type": "integer",
          "minimum": 1,
          "description": "Maximum output duration the model schema allows, taken from the `maximum` of its `duration_seconds` property; omitted when that property is absent or has no declared maximum. Distinct from `taskTimeoutSeconds`, which is the platform execution deadline."
        },
        "enabled": {
          "type": "boolean"
        },
        "available": {
          "type": "boolean"
        },
        "quantityField": {
          "type": "string"
        },
        "pricing": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/APIModelPrice"
          }
        },
        "startingPrice": {
          "$ref": "#/$defs/APIModelPrice"
        },
        "inputSchema": {
          "type": "object",
          "description": "JSON Schema draft 2020-12 used by `createTask.input` validation and Playground rendering. Standard JSON Schema keywords validate. Presentation hints live only in a per-property `x-ui` object whose keys are snake_case and drawn from a closed set: `widget`, `order`, `label`, `placeholder`, `rows`, `step`, `unit`, `accept`, `max_size_mb`, `advanced`, `primary`, `affects_price`, `visible_when`, `enum_labels`. `x-ui.order` is the only source of field order (descending first). `x-ui.widget` is one of `textarea`, `text`, `upload`, `multi-upload`, `select`, `radio`, `slider`, `number`, `switch`, `json`, `object-list`, `chat-messages`, `hidden`. Root-level composition is limited to `anyOf`, where every branch contains only `required`, and `allOf`, where each branch is `if` (`required` or `properties.*.const`) plus `then` (`required`); `oneOf`, `not` and `dependentSchemas` never appear. Unknown hints must be ignored.",
          "additionalProperties": true
        },
        "version": {
          "type": "string",
          "description": "Public model-catalog version label used to detect schema or metadata changes."
        },
        "availability": {
          "type": "string",
          "enum": [
            "planned",
            "available",
            "preview",
            "maintenance"
          ]
        },
        "badges": {
          "type": "array",
          "description": "Closed capability and licensing vocabulary; clients should ignore unknown future IDs.",
          "items": {
            "type": "string",
            "enum": [
              "commercial_use",
              "no_watermark",
              "commercial_restricted",
              "reference_input",
              "audio_output",
              "streaming",
              "fast_tier",
              "high_resolution",
              "long_context",
              "mature_capable",
              "policy_unrestricted",
              "policy_borderline"
            ]
          }
        },
        "relatedModels": {
          "type": "array",
          "description": "Curated model identifiers suitable for alternatives or workflow steps.",
          "items": {
            "type": "string"
          }
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "APIModelExample": {
      "type": "object",
      "required": [
        "id",
        "input",
        "sortWeight"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "input": {
          "type": "object",
          "additionalProperties": true
        },
        "sortWeight": {
          "type": "integer"
        }
      }
    },
    "APIModelPrice": {
      "type": "object",
      "required": [
        "variant",
        "unit",
        "price",
        "currency"
      ],
      "properties": {
        "variant": {
          "type": "string",
          "description": "Price tier key. Empty when the model has a single price. When one input field sets the price, it is that field's value as is (for example `720p`). When several fields do, it is `field=value` pairs sorted by field name and joined with `;` (for example `duration=5;resolution=720p`), with values URL-encoded; `~` stands for an optional field that was not sent and has no default."
        },
        "unit": {
          "type": "string",
          "enum": [
            "per_image",
            "per_second",
            "per_request",
            "per_1k_tokens",
            "per_1k_characters"
          ]
        },
        "price": {
          "$ref": "#/$defs/USDString"
        },
        "regularPrice": {
          "$ref": "#/$defs/USDString"
        },
        "offerLabel": {
          "type": "string"
        },
        "offerPercent": {
          "type": "string"
        },
        "offerEndsAt": {
          "type": "string",
          "format": "date-time"
        },
        "currency": {
          "type": "string",
          "const": "USD"
        },
        "officialFallbackPrice": {
          "allOf": [
            {
              "$ref": "#/$defs/USDString"
            }
          ],
          "description": "Present only for models with an economy route. `price` is then the economy-route price and this is the same tier's official price: the most a request is charged when `official_fallback` is `true` and the economy route fails."
        }
      }
    },
    "EnvelopeBase": {
      "type": "object",
      "required": [
        "code",
        "msg",
        "request_id"
      ],
      "properties": {
        "code": {
          "type": "integer"
        },
        "msg": {
          "type": "string"
        },
        "request_id": {
          "type": "string",
          "description": "Correlation identifier. Include it in support requests."
        }
      }
    },
    "USDString": {
      "type": "string",
      "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
      "description": "Decimal USD amount encoded as a string to avoid binary floating-point loss."
    }
  }
}