# GPT Image 1 Mini Image Generation

> Image Generation

Generate one or more images from a text prompt. The documented
`gpt-image-1-mini` response returns base64 image data in
`data[].b64_json`.

## Endpoint

`POST https://api.modelverse.cn/v1/images/generations`

## Request Body

## Responses

- **200** — Image generation response.
- **400** — Invalid request parameters or generation error.
- **default** — Error response.

## OpenAPI Definition

```json
{
  "openapi": "3.1.0",
  "x-language": "en-US",
  "info": {
    "title": "ModelVerse gpt-image-1-mini Image API",
    "version": "1.0.0",
    "description": "Self-contained OpenAPI 3.1 schema for the ModelVerse OpenAI-compatible\n`gpt-image-1-mini` image generation and image editing APIs.\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint documented for this model."
    }
  ],
  "tags": [
    {
      "name": "gpt-image-1-mini",
      "description": "Image generation and image editing with gpt-image-1-mini."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/images/generations": {
      "post": {
        "tags": [
          "gpt-image-1-mini"
        ],
        "operationId": "createGptImage1MiniImageGeneration",
        "summary": "GPT Image 1 Mini Image Generation",
        "description": "Generate one or more images from a text prompt. The documented\n`gpt-image-1-mini` response returns base64 image data in\n`data[].b64_json`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GptImage1MiniGenerationRequest"
              },
              "examples": {
                "flower": {
                  "summary": "Generate a PNG image",
                  "value": {
                    "model": "gpt-image-1-mini",
                    "prompt": "a beautiful flower",
                    "size": "1024x1024",
                    "quality": "high",
                    "output_format": "png",
                    "output_compression": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Image generation response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniImagesResponse"
                },
                "examples": {
                  "generatedImage": {
                    "summary": "Generated image with token usage",
                    "value": {
                      "created": 1748484857,
                      "background": "opaque",
                      "output_format": "png",
                      "quality": "low",
                      "size": "1024x1024",
                      "data": [
                        {
                          "b64_json": "{image_base64_string}"
                        }
                      ],
                      "usage": {
                        "total_tokens": 280,
                        "input_tokens": 8,
                        "output_tokens": 272,
                        "input_tokens_details": {
                          "image_tokens": 0,
                          "text_tokens": 8
                        },
                        "output_tokens_details": {
                          "image_tokens": 272,
                          "text_tokens": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or generation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniErrorResponse"
                },
                "examples": {
                  "documentedError": {
                    "$ref": "#/components/examples/GptImage1MiniError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniErrorResponse"
                },
                "examples": {
                  "documentedError": {
                    "$ref": "#/components/examples/GptImage1MiniError"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "tags": [
          "gpt-image-1-mini"
        ],
        "operationId": "createGptImage1MiniImageEdit",
        "summary": "GPT Image 1 Mini Image Editing",
        "description": "Edit an uploaded image using multipart/form-data. The request must\ninclude `image`, `model`, and `prompt`. A `mask` can optionally limit\nthe edited region; transparent mask pixels are edited and opaque mask\npixels are preserved. The documented mask requirements are PNG format,\nan alpha channel, and exactly the same dimensions as `image`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/GptImage1MiniEditRequest"
              },
              "encoding": {
                "image": {
                  "contentType": "image/png"
                },
                "mask": {
                  "contentType": "image/png"
                }
              },
              "examples": {
                "editWithMask": {
                  "summary": "Edit an image with an optional mask",
                  "value": {
                    "image": "/path/to/your/image.png",
                    "mask": "/path/to/your/mask.png",
                    "model": "gpt-image-1-mini",
                    "prompt": "Add a beach ball in the center",
                    "size": "1024x1024",
                    "n": 1,
                    "quality": "high",
                    "output_format": "png",
                    "output_compression": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Image edit response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniImagesResponse"
                },
                "examples": {
                  "editedImage": {
                    "summary": "Edited image with token usage",
                    "value": {
                      "created": 1748484857,
                      "background": "opaque",
                      "output_format": "png",
                      "quality": "low",
                      "size": "1024x1024",
                      "data": [
                        {
                          "b64_json": "{image_base64_string}"
                        }
                      ],
                      "usage": {
                        "total_tokens": 280,
                        "input_tokens": 8,
                        "output_tokens": 272,
                        "input_tokens_details": {
                          "image_tokens": 0,
                          "text_tokens": 8
                        },
                        "output_tokens_details": {
                          "image_tokens": 272,
                          "text_tokens": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or edit error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniErrorResponse"
                },
                "examples": {
                  "documentedError": {
                    "$ref": "#/components/examples/GptImage1MiniError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GptImage1MiniErrorResponse"
                },
                "examples": {
                  "documentedError": {
                    "$ref": "#/components/examples/GptImage1MiniError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "ModelVerse API key sent in the `Authorization: Bearer <API_KEY>` header."
      }
    },
    "schemas": {
      "GptImage1MiniModel": {
        "type": "string",
        "const": "gpt-image-1-mini",
        "description": "The image model ID documented for these operations."
      },
      "GptImage1MiniPrompt": {
        "type": "string",
        "minLength": 1,
        "description": "Text prompt describing the image to generate or the edit to apply."
      },
      "GptImage1MiniImageCount": {
        "type": "integer",
        "minimum": 1,
        "maximum": 10,
        "default": 1,
        "description": "Number of images to generate. The documented range is 1 to 10."
      },
      "GptImage1MiniSize": {
        "type": "string",
        "enum": [
          "1024x1024",
          "1024x1536",
          "1536x1024"
        ],
        "default": "1024x1536",
        "description": "Image resolution supported by gpt-image-1-mini."
      },
      "GptImage1MiniQuality": {
        "type": "string",
        "enum": [
          "low",
          "medium",
          "high"
        ],
        "description": "Image quality. Higher quality can take longer."
      },
      "GptImage1MiniBackground": {
        "type": "string",
        "enum": [
          "transparent",
          "opaque",
          "auto"
        ],
        "default": "auto",
        "description": "Background transparency setting. Use `transparent` with\n`output_format=png`.\n"
      },
      "GptImage1MiniModeration": {
        "type": "string",
        "enum": [
          "auto",
          "low"
        ],
        "default": "auto",
        "description": "Content moderation level. `low` is the documented less strict mode."
      },
      "GptImage1MiniOutputFormat": {
        "type": "string",
        "enum": [
          "png",
          "jpeg"
        ],
        "default": "png",
        "description": "Output image format."
      },
      "GptImage1MiniOutputCompression": {
        "type": "integer",
        "minimum": 0,
        "maximum": 100,
        "description": "Image compression strength. `0` disables compression and `100` applies\nmaximum compression. Documented as effective only for `jpeg` output.\n"
      },
      "GptImage1MiniUser": {
        "type": "string",
        "description": "End-user identifier passed upstream for abuse detection."
      },
      "GptImage1MiniGenerationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "prompt"
        ],
        "allOf": [
          {
            "$ref": "#/components/schemas/GptImage1MiniTransparentBackgroundConstraint"
          }
        ],
        "properties": {
          "model": {
            "$ref": "#/components/schemas/GptImage1MiniModel"
          },
          "prompt": {
            "$ref": "#/components/schemas/GptImage1MiniPrompt"
          },
          "n": {
            "$ref": "#/components/schemas/GptImage1MiniImageCount"
          },
          "size": {
            "$ref": "#/components/schemas/GptImage1MiniSize"
          },
          "quality": {
            "$ref": "#/components/schemas/GptImage1MiniQuality"
          },
          "background": {
            "$ref": "#/components/schemas/GptImage1MiniBackground"
          },
          "moderation": {
            "$ref": "#/components/schemas/GptImage1MiniModeration"
          },
          "output_format": {
            "$ref": "#/components/schemas/GptImage1MiniOutputFormat"
          },
          "output_compression": {
            "$ref": "#/components/schemas/GptImage1MiniOutputCompression"
          },
          "user": {
            "$ref": "#/components/schemas/GptImage1MiniUser"
          }
        }
      },
      "GptImage1MiniEditRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "image",
          "model",
          "prompt"
        ],
        "allOf": [
          {
            "$ref": "#/components/schemas/GptImage1MiniTransparentBackgroundConstraint"
          }
        ],
        "properties": {
          "image": {
            "type": "string",
            "format": "binary",
            "description": "Image file to edit."
          },
          "mask": {
            "type": "string",
            "format": "binary",
            "description": "Optional PNG mask file. Transparent areas are edited and opaque\nareas are preserved. The mask must include an alpha channel and\nexactly match the dimensions of `image`.\n"
          },
          "model": {
            "$ref": "#/components/schemas/GptImage1MiniModel"
          },
          "prompt": {
            "$ref": "#/components/schemas/GptImage1MiniPrompt"
          },
          "n": {
            "$ref": "#/components/schemas/GptImage1MiniImageCount"
          },
          "size": {
            "$ref": "#/components/schemas/GptImage1MiniSize"
          },
          "quality": {
            "$ref": "#/components/schemas/GptImage1MiniQuality"
          },
          "background": {
            "$ref": "#/components/schemas/GptImage1MiniBackground"
          },
          "moderation": {
            "$ref": "#/components/schemas/GptImage1MiniModeration"
          },
          "output_format": {
            "$ref": "#/components/schemas/GptImage1MiniOutputFormat"
          },
          "output_compression": {
            "$ref": "#/components/schemas/GptImage1MiniOutputCompression"
          },
          "user": {
            "$ref": "#/components/schemas/GptImage1MiniUser"
          }
        }
      },
      "GptImage1MiniTransparentBackgroundConstraint": {
        "type": "object",
        "if": {
          "required": [
            "background"
          ],
          "properties": {
            "background": {
              "const": "transparent"
            }
          }
        },
        "then": {
          "properties": {
            "output_format": {
              "const": "png"
            }
          },
          "description": "Requests with `background=transparent` must use `output_format=png`."
        }
      },
      "GptImage1MiniImagesResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "created",
          "data"
        ],
        "properties": {
          "created": {
            "type": "integer",
            "format": "int64",
            "description": "Unix timestamp in seconds for when the request was created."
          },
          "background": {
            "type": "string",
            "description": "Background type used for the generated image.",
            "examples": [
              "opaque",
              "transparent"
            ]
          },
          "output_format": {
            "$ref": "#/components/schemas/GptImage1MiniOutputFormat"
          },
          "quality": {
            "$ref": "#/components/schemas/GptImage1MiniQuality"
          },
          "size": {
            "$ref": "#/components/schemas/GptImage1MiniSize"
          },
          "data": {
            "type": "array",
            "minItems": 1,
            "description": "Generated image data. The documented response returns base64 image data.",
            "items": {
              "$ref": "#/components/schemas/GptImage1MiniImageData"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/GptImage1MiniUsage"
          }
        }
      },
      "GptImage1MiniImageData": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "b64_json"
        ],
        "properties": {
          "b64_json": {
            "type": "string",
            "description": "Base64-encoded image data, optionally prefixed as a data URL."
          }
        }
      },
      "GptImage1MiniUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "total_tokens": {
            "type": "integer",
            "description": "Total tokens consumed by the request."
          },
          "input_tokens": {
            "type": "integer",
            "description": "Total input tokens consumed by the request."
          },
          "output_tokens": {
            "type": "integer",
            "description": "Total output tokens consumed by the request."
          },
          "input_tokens_details": {
            "$ref": "#/components/schemas/GptImage1MiniInputTokensDetails"
          },
          "output_tokens_details": {
            "$ref": "#/components/schemas/GptImage1MiniOutputTokensDetails"
          }
        }
      },
      "GptImage1MiniInputTokensDetails": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text_tokens": {
            "type": "integer",
            "description": "Tokens consumed by the text prompt."
          },
          "image_tokens": {
            "type": "integer",
            "description": "Tokens consumed by input images."
          }
        }
      },
      "GptImage1MiniOutputTokensDetails": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "image_tokens": {
            "type": "integer",
            "description": "Tokens consumed by output images."
          },
          "text_tokens": {
            "type": "integer",
            "description": "Text output token count when present in the response."
          }
        }
      },
      "GptImage1MiniErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/GptImage1MiniError"
          }
        }
      },
      "GptImage1MiniError": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message."
          },
          "type": {
            "type": "string",
            "description": "Error type."
          },
          "param": {
            "type": "string",
            "description": "Request ID or related parameter."
          },
          "code": {
            "type": "string",
            "description": "Error code."
          }
        }
      }
    },
    "examples": {
      "GptImage1MiniError": {
        "summary": "Documented error response",
        "value": {
          "error": {
            "message": "error_message",
            "type": "error_type",
            "param": "request_id",
            "code": "error_code"
          }
        }
      }
    }
  }
}
```
