{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/octen-ai/json-schema/octen-ai-grounded-generation-task-schema.json",
  "title": "GroundedGenerationTask",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/octen-ai-grounded-generation-api-openapi.yml#/components/schemas/GroundedGenerationTask",
  "type": "object",
  "required": [
    "generation_id",
    "modality",
    "status",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "request_id": {
      "type": "string",
      "description": "Unique identifier for the request."
    },
    "generation_id": {
      "type": "string",
      "description": "Unique task id."
    },
    "modality": {
      "type": "string",
      "enum": [
        "image",
        "video"
      ],
      "description": "The type of output this task generates."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed"
      ],
      "description": "Task state."
    },
    "output_url": {
      "type": "string",
      "description": "Signed download URL for the output, present when `status` is `succeeded`. Requires no API key, and is valid for 7 days after the task was created."
    },
    "references": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/GroundedGenerationReference"
      },
      "description": "The reference material used to generate the output."
    },
    "search_results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/GroundedGenerationSearchGroup"
      },
      "description": "The search results the references were selected from, grouped by query."
    },
    "error": {
      "$ref": "#/$defs/GroundedGenerationError"
    },
    "created_at": {
      "type": "integer",
      "description": "Unix timestamp in seconds when the task was created."
    },
    "updated_at": {
      "type": "integer",
      "description": "Unix timestamp in seconds when the task was last updated."
    },
    "usage": {
      "$ref": "#/$defs/GroundedGenerationUsage"
    }
  },
  "$defs": {
    "GroundedGenerationError": {
      "type": "object",
      "description": "Failure reason, present when `status` is `failed`. Failed tasks are not billed.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "MM_GENERATION_CONTENT_POLICY",
            "MM_GENERATION_INPUT_IMAGE_PRIVACY_BLOCKED",
            "MM_GENERATION_CONTENT_NOT_SUPPORTED",
            "MM_GENERATION_NO_REFERENCE_MATERIAL",
            "MM_GENERATION_REJECTED",
            "MM_GENERATION_TIMEOUT",
            "MM_GENERATION_FAILED"
          ],
          "description": "Machine-readable failure code. `MM_GENERATION_CONTENT_POLICY`: the prompt triggered a content policy; `MM_GENERATION_INPUT_IMAGE_PRIVACY_BLOCKED`: the reference material was blocked for privacy; `MM_GENERATION_CONTENT_NOT_SUPPORTED`: the content is not supported; `MM_GENERATION_NO_REFERENCE_MATERIAL`: no usable reference material was found; `MM_GENERATION_REJECTED`: the model rejected the request; `MM_GENERATION_TIMEOUT`: generation timed out, retry; `MM_GENERATION_FAILED`: generation failed for another reason, retry."
        },
        "message": {
          "type": "string",
          "description": "A message describing the failure."
        }
      }
    },
    "GroundedGenerationReference": {
      "type": "object",
      "description": "A single piece of reference material.",
      "properties": {
        "source_id": {
          "type": "string",
          "description": "Identifier of the reference, such as `source1`."
        },
        "url": {
          "type": "string",
          "description": "The media URL."
        },
        "title": {
          "type": "string",
          "description": "The title of the reference."
        },
        "cover_url": {
          "type": "string",
          "description": "Thumbnail URL."
        }
      }
    },
    "GroundedGenerationSearchGroup": {
      "type": "object",
      "description": "The results for one search query.",
      "properties": {
        "query": {
          "type": "string",
          "description": "The query the task searched for."
        },
        "results": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GroundedGenerationSearchResult"
          },
          "description": "Results for this query."
        }
      }
    },
    "GroundedGenerationSearchResult": {
      "type": "object",
      "description": "A single search result.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "image",
            "video"
          ],
          "description": "Media type of the result."
        },
        "title": {
          "type": "string",
          "description": "The title of the result."
        },
        "url": {
          "type": "string",
          "description": "The media URL."
        },
        "source_page": {
          "type": "string",
          "description": "URL of the original page hosting the media."
        },
        "description": {
          "type": "string",
          "description": "Description of the result."
        },
        "cover_url": {
          "type": "string",
          "description": "Thumbnail URL."
        }
      }
    },
    "GroundedGenerationUsage": {
      "type": "object",
      "description": "Metering for the task. Present only when `status` is `succeeded`.",
      "properties": {
        "image_count": {
          "type": "integer",
          "description": "Number of images generated. Returned when `modality` is `image`."
        },
        "video_count": {
          "type": "integer",
          "description": "Number of videos generated. Returned when `modality` is `video`."
        },
        "video_seconds": {
          "type": "integer",
          "description": "Length of the generated video in seconds. Returned when `modality` is `video`."
        }
      }
    }
  }
}