# Qwen Image 图像生成

> 图像生成

发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。

## 请求地址

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

## 请求体

## 响应

- **200** — 图像生成响应。
- **400** — 
- **default** — 

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "Qwen-Qwen-Image接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `Qwen-Qwen-Image` 的图片接口文档，说明如何发起图片生成或编辑请求、填写参数、读取结果以及处理错误。\n接口路径包括 `POST /v1/images/generations`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "该模型文档中使用的 ModelVerse API 端点。"
    }
  ],
  "tags": [
    {
      "name": "Qwen/Qwen-Image",
      "description": "OpenAI-compatible image generation with Qwen/Qwen-Image."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/images/generations": {
      "post": {
        "tags": [
          "Qwen/Qwen-Image"
        ],
        "operationId": "createQwenQwenImageGeneration",
        "summary": "Qwen Image 图像生成",
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QwenQwenImageGenerationRequest"
              },
              "examples": {
                "quickPencilSketch": {
                  "summary": "源文档 document 图像生成 请求",
                  "value": {
                    "model": "Qwen/Qwen-Image",
                    "prompt": "Convert to quick pencil sketch",
                    "size": "1664x928"
                  }
                },
                "deterministicSquare": {
                  "summary": "带 a 固定 seed and 文档中的默认尺寸族 的请求",
                  "value": {
                    "model": "Qwen/Qwen-Image",
                    "prompt": "A quiet bookstore storefront at night, watercolor style",
                    "seed": 12345,
                    "size": "1328x1328"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "图像生成响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QwenQwenImageGenerationResponse"
                },
                "examples": {
                  "documentedResponse": {
                    "summary": "源文档响应带URL and Base64 data",
                    "value": {
                      "created": 1750667997,
                      "data": [
                        {
                          "url": "https://xxxxx/xxxx.png",
                          "b64_json": "data:image/png;base64,{image_base64_string}"
                        }
                      ],
                      "usage": {
                        "input_tokens_details": {}
                      }
                    }
                  },
                  "urlOnly": {
                    "summary": "返回 URL 的生成图像",
                    "value": {
                      "created": 1750667997,
                      "data": [
                        {
                          "url": "https://xxxxx/xxxx.png"
                        }
                      ],
                      "usage": {
                        "input_tokens_details": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/QwenQwenImageBadRequest"
          },
          "default": {
            "$ref": "#/components/responses/QwenQwenImageError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n"
      }
    },
    "responses": {
      "QwenQwenImageBadRequest": {
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/QwenQwenImageErrorResponse"
            },
            "examples": {
              "documentedError": {
                "$ref": "#/components/examples/QwenQwenImageError"
              }
            }
          }
        }
      },
      "QwenQwenImageError": {
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/QwenQwenImageErrorResponse"
            },
            "examples": {
              "documentedError": {
                "$ref": "#/components/examples/QwenQwenImageError"
              }
            }
          }
        }
      }
    },
    "schemas": {
      "QwenQwenImageModel": {
        "type": "string",
        "const": "Qwen/Qwen-Image",
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n"
      },
      "QwenQwenImagePrompt": {
        "type": "string",
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n"
      },
      "QwenQwenImageSeed": {
        "type": "integer",
        "default": -1,
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n"
      },
      "QwenQwenImageSize": {
        "type": "string",
        "default": "1664x928",
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "enum": [
          "1664x928",
          "1472x1104",
          "1328x1328",
          "1104x1472",
          "928x1664"
        ]
      },
      "QwenQwenImageGenerationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt",
          "model"
        ],
        "properties": {
          "prompt": {
            "$ref": "#/components/schemas/QwenQwenImagePrompt"
          },
          "model": {
            "$ref": "#/components/schemas/QwenQwenImageModel"
          },
          "seed": {
            "$ref": "#/components/schemas/QwenQwenImageSeed"
          },
          "size": {
            "$ref": "#/components/schemas/QwenQwenImageSize"
          }
        }
      },
      "QwenQwenImageGenerationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "created",
          "data"
        ],
        "properties": {
          "created": {
            "type": "integer",
            "format": "int64",
            "description": "Unix timestamp, in seconds, for when this request was created."
          },
          "data": {
            "type": "array",
            "description": "Generated image output information.",
            "items": {
              "$ref": "#/components/schemas/QwenQwenImageData"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/QwenQwenImageUsage"
          }
        }
      },
      "QwenQwenImageData": {
        "type": "object",
        "additionalProperties": false,
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "anyOf": [
          {
            "required": [
              "url"
            ]
          },
          {
            "required": [
              "b64_json"
            ]
          }
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Download URL for the generated image. The source document notes that\nlinks expire within 7 days after generation.\n"
          },
          "b64_json": {
            "type": "string",
            "description": "Base64-encoded generated image data."
          }
        }
      },
      "QwenQwenImageUsage": {
        "type": "object",
        "additionalProperties": false,
        "description": "发起图片生成请求。请求体包含模型、提示词和可选生成参数，响应返回图片 URL 或 Base64 图像数据。\n",
        "properties": {
          "input_tokens_details": {
            "type": "object",
            "additionalProperties": true,
            "description": "Input token detail object shown in the source response example."
          }
        }
      },
      "QwenQwenImageErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/QwenQwenImageErrorObject"
          }
        }
      },
      "QwenQwenImageErrorObject": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "message",
          "type",
          "param",
          "code"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误信息。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。"
          },
          "param": {
            "type": "string",
            "description": "Request identifier, documented as `request_id`."
          },
          "code": {
            "type": "string",
            "description": "错误码。"
          }
        }
      }
    },
    "examples": {
      "QwenQwenImageError": {
        "summary": "源文档错误响应",
        "value": {
          "error": {
            "message": "error_message",
            "type": "error_type",
            "param": "request_id",
            "code": "error_code"
          }
        }
      }
    }
  }
}
```
