{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/octen-ai/json-schema/octen-ai-image-generation-stream-event-schema.json",
  "title": "ImageGenerationStreamEvent",
  "description": "A streaming SSE event. Partial preview images arrive first (each with `partial_image_index`), then one `completed` event with `usage`. The event type prefix is `image_generation` for text-to-image and `image_edit` for editing.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/octen-ai-images-api-openapi.yml#/components/schemas/ImageGenerationStreamEvent",
  "type": "object",
  "required": [
    "id",
    "type",
    "b64_json"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Request identifier. Identical across all events of one request."
    },
    "type": {
      "type": "string",
      "enum": [
        "image_generation.partial_image",
        "image_generation.completed",
        "image_edit.partial_image",
        "image_edit.completed"
      ],
      "description": "The event type."
    },
    "b64_json": {
      "type": "string",
      "description": "Base64 image for this event: the current preview for `partial_image`, the final image for `completed`."
    },
    "created_at": {
      "type": "integer",
      "description": "Unix timestamp when the event was generated."
    },
    "size": {
      "type": "string",
      "description": "(GPT only) The output size actually applied; useful when `size` was `auto`."
    },
    "quality": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high",
        "xhigh",
        "max"
      ],
      "description": "(GPT only) The quality tier actually applied."
    },
    "background": {
      "type": "string",
      "enum": [
        "transparent",
        "opaque"
      ],
      "description": "(GPT only) The background setting actually applied."
    },
    "output_format": {
      "type": "string",
      "enum": [
        "png",
        "jpeg",
        "webp"
      ],
      "description": "The output format actually applied; for Gemini, derived from the mimeType."
    },
    "partial_image_index": {
      "type": "integer",
      "description": "Present only in `partial_image` events. Preview index, starting at 0."
    },
    "usage": {
      "allOf": [
        {
          "$ref": "#/$defs/ImageUsage"
        }
      ],
      "description": "Present only in `completed` events. Same structure as the non-streaming `usage`."
    }
  },
  "$defs": {
    "ImageUsage": {
      "type": "object",
      "required": [
        "input_tokens",
        "output_tokens",
        "total_tokens"
      ],
      "description": "Token usage information.",
      "properties": {
        "input_tokens": {
          "type": "integer",
          "description": "Input tokens (text prompt + input image tokens)."
        },
        "input_tokens_details": {
          "type": "object",
          "properties": {
            "text_tokens": {
              "type": "integer",
              "description": "Text tokens of the prompt."
            },
            "image_tokens": {
              "type": "integer",
              "description": "Tokens of the input images."
            }
          }
        },
        "output_tokens": {
          "type": "integer",
          "description": "Output tokens (generated image tokens + reasoning text tokens)."
        },
        "output_tokens_details": {
          "type": "object",
          "properties": {
            "text_tokens": {
              "type": "integer",
              "description": "Output tokens used by reasoning text."
            },
            "image_tokens": {
              "type": "integer",
              "description": "Tokens of the generated images."
            }
          }
        },
        "total_tokens": {
          "type": "integer",
          "description": "Total tokens (input_tokens + output_tokens)."
        }
      }
    }
  }
}