{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cloudinary/json-schema/cloudinary-generate-image-request-schema.json",
  "title": "GenerateImageRequest",
  "description": "Parameters for an image-generation request. Only `prompt` is required;\nall other fields fall back to documented defaults.\n",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cloudinary-media-generation-openapi.yml#/components/schemas/GenerateImageRequest",
  "type": "object",
  "required": [
    "prompt"
  ],
  "properties": {
    "prompt": {
      "type": "string",
      "minLength": 1,
      "maxLength": 16384,
      "description": "The text description of the image to generate."
    },
    "model": {
      "$ref": "#/$defs/ModelSelection"
    },
    "image_size": {
      "$ref": "#/$defs/ImageSize"
    },
    "format": {
      "$ref": "#/$defs/ImageFormat"
    },
    "target": {
      "$ref": "#/$defs/Target"
    },
    "seed": {
      "$ref": "#/$defs/Seed"
    },
    "async": {
      "$ref": "#/$defs/Async"
    },
    "notification_url": {
      "$ref": "#/$defs/NotificationUrl"
    }
  },
  "$defs": {
    "Async": {
      "type": "boolean",
      "default": false,
      "description": "Whether to perform the generation asynchronously. When true, the API\nreturns immediately with a 202 and completes in the background. Once\ncomplete, a webhook notification is sent to the specified URL and/or to\nthe URLs defined in the product environment's settings.\n"
    },
    "DeclarativeImageSize": {
      "type": "object",
      "title": "DeclarativeImageSize",
      "description": "Declarative output size — an aspect ratio plus an optional resolution\ntier, resolved server-side to the nearest size the model supports.\n",
      "additionalProperties": false,
      "required": [
        "aspect_ratio"
      ],
      "properties": {
        "aspect_ratio": {
          "type": "string",
          "description": "Output aspect ratio, width-to-height. Limited to the core ratios\nevery model supports natively.\n",
          "enum": [
            "1:1",
            "16:9",
            "9:16",
            "4:3",
            "3:4"
          ]
        },
        "resolution": {
          "type": "string",
          "description": "Output resolution tier, measured on the longest edge. Defaults to\n`1K` when omitted.\n* `0.5K`: ~512 px\n* `1K`: ~1024 px\n* `2K`: ~2048 px\n* `4K`: ~4096 px\n",
          "enum": [
            "0.5K",
            "1K",
            "2K",
            "4K"
          ]
        }
      }
    },
    "DimensionsImageSize": {
      "type": "object",
      "title": "DimensionsImageSize",
      "description": "Exact output dimensions in pixels. Both `width` and `height` are required together.",
      "additionalProperties": false,
      "required": [
        "width",
        "height"
      ],
      "properties": {
        "width": {
          "type": "integer",
          "minimum": 64,
          "maximum": 4096,
          "description": "Output width in pixels."
        },
        "height": {
          "type": "integer",
          "minimum": 64,
          "maximum": 4096,
          "description": "Output height in pixels."
        }
      }
    },
    "ImageFormat": {
      "type": "string",
      "enum": [
        "jpeg",
        "png",
        "webp"
      ],
      "description": "Desired output image format. Optional; defaults to `png` when omitted.\nMapped to the closest format the chosen model supports — `webp` falls\nback to `png` on models that don't support it (e.g. FLUX.2 Pro), and the\nrequest is ignored entirely by models that don't expose a format option\n(e.g. Recraft).\n"
    },
    "ImageSize": {
      "description": "Desired output size, given in **one** of two mutually exclusive forms:\n\n  * `DimensionsImageSize`: `width` and `height` in pixels, for precise\n    control.\n  * `DeclarativeImageSize`: `aspect_ratio` (and an optional `resolution`\n    tier), resolved server-side to the closest size the chosen model\n    supports. This is the portable form: most providers natively accept\n    an aspect ratio plus a resolution tier rather than raw pixels.\n\nOmit `image_size` entirely to use the model's default size.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/DimensionsImageSize"
        },
        {
          "$ref": "#/$defs/DeclarativeImageSize"
        }
      ]
    },
    "ManagedAssetTarget": {
      "type": "object",
      "description": "Store the output as a permanent managed asset in your Cloudinary product environment (the default).",
      "additionalProperties": false,
      "required": [
        "target_type"
      ],
      "properties": {
        "target_type": {
          "type": "string",
          "description": "Discriminator identifying this as a managed-asset target.",
          "enum": [
            "managed_asset"
          ]
        },
        "public_id": {
          "type": "string",
          "description": "Public ID to store the asset under. Auto-assigned when omitted."
        },
        "upload_preset": {
          "type": "string",
          "description": "Upload preset to apply. Uses the product environment's default when omitted."
        }
      }
    },
    "ModelAuto": {
      "type": "object",
      "title": "ModelAuto",
      "description": "Let the service choose the model for this request. The response reports\nthe resolved model in `data.assets[].model`, as for the other forms; on\n`image_to_image` it is always an edit model.\n",
      "additionalProperties": false,
      "required": [
        "mode"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "auto"
          ],
          "description": "The only valid value; selects automatic model selection."
        },
        "preference": {
          "type": "string",
          "enum": [
            "balanced",
            "quality",
            "economy",
            "balanced_fast",
            "quality_fast",
            "economy_fast"
          ],
          "default": "balanced",
          "description": "What the choice optimizes for:\n* `balanced` (default): quality and cost weighted equally.\n* `quality`: quality only; cost isn't weighed.\n* `economy`: cost first, quality second.\n* `balanced_fast`, `quality_fast`, `economy_fast`: as above, but\n  also favor faster generation, and never pick a model that\n  typically takes longer than 30 seconds.\n"
        }
      }
    },
    "ModelByFamily": {
      "type": "object",
      "title": "ModelByFamily",
      "description": "Select a model by family and quality tier; a missing `tier` defaults to\n`standard`.\n",
      "additionalProperties": false,
      "required": [
        "family"
      ],
      "properties": {
        "family": {
          "type": "string",
          "enum": [
            "flux",
            "recraft",
            "gpt-image",
            "nano-banana",
            "ideogram"
          ],
          "description": "Model family:\n* `flux`: Photorealistic images (FLUX.2 Klein 9B / FLUX.2 Pro).\n* `recraft`: Vector and illustration (Recraft V3 / Recraft V4).\n* `gpt-image`: Campaign and marketing images (GPT Image 1 Mini / GPT\n  Image 2).\n* `nano-banana`: General purpose generation (Nano Banana 1 / Nano\n  Banana 2).\n* `ideogram`: Realism, text rendering, and artistic generation\n  (Ideogram V4).\n"
        },
        "tier": {
          "type": "string",
          "enum": [
            "standard",
            "premium"
          ],
          "description": "Quality tier within the family. Defaults to `standard` when omitted."
        }
      }
    },
    "ModelById": {
      "type": "object",
      "title": "ModelById",
      "description": "Pin an exact model by ID, bypassing family/tier.",
      "additionalProperties": false,
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "nano-banana-1",
            "nano-banana-2",
            "nano-banana-2-lite",
            "flux-2-klein-9b",
            "flux-2-pro",
            "flux-2-flash",
            "flux-3",
            "recraft-v3",
            "recraft-v4",
            "gpt-image-1-mini",
            "gpt-image-2",
            "gpt-image-2.5-flare",
            "gpt-image-2.5-sunburst",
            "muse-image",
            "mai-image-2.5",
            "mai-image-2.5-pro",
            "seedream-5-pro",
            "grok-imagine-image",
            "recraft-v4.1-utility",
            "recraft-v4.1-utility-pro",
            "seedream-5-lite",
            "grok-imagine-image-2.0-low",
            "qwen-image-3",
            "ideogram-v4-base",
            "ideogram-v4-turbo",
            "nano-banana-1-edit",
            "nano-banana-2-edit",
            "nano-banana-2-lite-edit",
            "flux-2-klein-9b-edit",
            "flux-2-pro-edit",
            "flux-2-flash-edit",
            "flux-3-edit",
            "recraft-v3-edit",
            "gpt-image-1-mini-edit",
            "gpt-image-2-edit",
            "gpt-image-2.5-flare-edit",
            "gpt-image-2.5-sunburst-edit",
            "muse-image-edit",
            "mai-image-2.5-edit",
            "mai-image-2.5-pro-edit",
            "seedream-5-pro-edit",
            "grok-imagine-image-edit",
            "seedream-5-lite-edit",
            "grok-imagine-image-2.0-low-edit",
            "qwen-image-3-edit"
          ],
          "description": "Exact model identifier; overrides family/tier when provided. The\n`-edit` models accept reference images and are selectable only on\n`image_to_image`; the others only on `text_to_image`.\n"
        }
      }
    },
    "ModelSelection": {
      "description": "Selects the model, in one of three mutually exclusive forms (omit to use\nthe default: `nano-banana-2`, or `nano-banana-2-edit` for\nimage-to-image):\n  * `ModelByFamily`: `family` (+ optional `tier`); the stable-over-time\n    selector.\n  * `ModelById`: an explicit `id`, pinning one exact model.\n  * `ModelAuto`: `mode: auto`, letting the service choose the model for\n    the request (+ optional `preference`).\n",
      "oneOf": [
        {
          "$ref": "#/$defs/ModelByFamily"
        },
        {
          "$ref": "#/$defs/ModelById"
        },
        {
          "$ref": "#/$defs/ModelAuto"
        }
      ]
    },
    "NotificationUrl": {
      "type": "string",
      "format": "uri",
      "description": "The webhook URL to notify when the generation is complete. Only relevant when `async` is set to true."
    },
    "Seed": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "description": "Seed for reproducible generation. Supported by the `flux`, `nano-banana`\nand `ideogram` models and by `qwen-image-3`; silently ignored by the\nmodels that don't support it, which report `seed` as null in the\nresponse.\n"
    },
    "Target": {
      "description": "Where the generated image goes, determined by `target_type`. Use\n`temporary` when the user only wants the image: a short-lived URL,\nnothing saved to their account. Omit it, or use `managed_asset`, to\nstore the image permanently in their Media Library. If the caller lacks\nupload permission, the image is returned as `temporary` instead, with a\n`warning` notice.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/ManagedAssetTarget"
        },
        {
          "$ref": "#/$defs/TemporaryTarget"
        }
      ]
    },
    "TemporaryTarget": {
      "type": "object",
      "description": "Return the image at a short-lived URL (valid until `expires_at`) without\nsaving it to the user's Cloudinary account.\n",
      "additionalProperties": false,
      "required": [
        "target_type"
      ],
      "properties": {
        "target_type": {
          "type": "string",
          "description": "Discriminator identifying this as a temporary target.",
          "enum": [
            "temporary"
          ]
        }
      }
    }
  }
}