文档提示:本目录为静态文档,接口示例与 OpenAPI 地址已固定为 https://api.xiexus.cn
AI 模型接口 图像(Images) 生成图像

生成图像

在给定提示的情况下创建图像。[了解更多](https://platform.openai.com/docs/guides/images)。

POST
https://api.xiexus.cn/v1/images/generations/
请求体:可选
接口信息
方法
POST
路径
/v1/images/generations/
完整地址
https://api.xiexus.cn/v1/images/generations/
请求体
可选
标签
图像(Images)/原生OpenAI格式
响应码
200
当前接口页内已嵌入 OpenAPI JSON;如果需要查看总文件,可直接打开固定静态文件 relay.json
当前 JSON
../../../openapi/generated/ai-model/图像(Images)/原生OpenAI格式/post-v1-images-generations-post-v1-images-generations-385320132.json
总文件
../../../openapi/relay.json

OpenAPI JSON

已将服务地址固定为 https://api.xiexus.cn,其余结构保持和源文档一致。
{
  "openapi": "3.1.0",
  "info": {
    "title": "生成图像",
    "version": "1.0.0",
    "description": "在给定提示的情况下创建图像。[了解更多](https://platform.openai.com/docs/guides/images)。"
  },
  "tags": [
    {
      "name": "图像(Images)/原生OpenAI格式"
    }
  ],
  "components": {
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/images/generations/": {
      "post": {
        "tags": [
          "图像(Images)/原生OpenAI格式"
        ],
        "summary": "生成图像",
        "description": "在给定提示的情况下创建图像。[了解更多](https://platform.openai.com/docs/guides/images)。",
        "operationId": "post-v1-images-generations",
        "parameters": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "用于图像生成的模型。`dall-e-2`、`dall-e-3` 或 `gpt-image-1` 之一。默认为 `dall-e-2`,除非使用特定于 `gpt-image-1` 的参数。"
                  },
                  "prompt": {
                    "type": "string",
                    "description": "所需图像的文本描述。`gpt-image-1` 的最大长度为 32000 个字符,`dall-e-2` 的最大长度为 1000 个字符,`dall-e-3` 的最大长度为 4000 个字符。"
                  },
                  "n": {
                    "type": "integer",
                    "description": "要生成的图像数量。必须介于 1 到 10 之间。对于 `dall-e-3`,仅支持 `n=1`。"
                  },
                  "size": {
                    "type": "string",
                    "description": "生成的图像的大小。`对于 gpt-image-1`,必须是 `1024x1024`、`1536x1024`(横向)、`1024x1536`(纵向)或`自动`(默认值)之一,`对于 dall-e-2`,必须是 `256x256、``512x512` 或 `1024x1024` 之一,对于 `dall-e-3`,必须是 `1024x1024`、`1792x1024` 或 `1024x1792` 之一。"
                  },
                  "background": {
                    "type": "string",
                    "description": "允许为生成的图像的背景设置透明度。此参数仅支持 `gpt-image-1`。必须是以下之一 `透明`、`不透明`或`自动`(默认值)。使用`自动`时,模型将自动确定图像的最佳背景。\n\n如果`是透明`的,则输出格式需要支持透明度,因此应将其设置为 `png`(默认值)或 `webp`。"
                  },
                  "moderation": {
                    "type": "string",
                    "description": "控制 `gpt-image-1` 生成的图像的内容审核级别。必须为`低,` 以进行限制较少的筛选或`自动`(默认值)。"
                  },
                  "quality": {
                    "type": "string",
                    "description": "将生成的图像的质量。"
                  },
                  "stream": {
                    "type": "string"
                  },
                  "style": {
                    "type": "string"
                  },
                  "user": {
                    "type": "string"
                  }
                },
                "required": [
                  "prompt"
                ],
                "x-apifox-orders": [
                  "model",
                  "prompt",
                  "n",
                  "size",
                  "background",
                  "moderation",
                  "quality",
                  "stream",
                  "style",
                  "user"
                ]
              }
            }
          }
        },
        "security": [
          {
            "Bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "b64_json": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "url"
                        ],
                        "x-apifox-orders": [
                          "b64_json",
                          "url"
                        ]
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "total_tokens": {
                          "type": "integer"
                        },
                        "input_tokens": {
                          "type": "integer"
                        },
                        "output_tokens": {
                          "type": "integer"
                        },
                        "input_tokens_details": {
                          "type": "object",
                          "properties": {
                            "text_tokens": {
                              "type": "integer"
                            },
                            "image_tokens": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "text_tokens",
                            "image_tokens"
                          ],
                          "x-apifox-orders": [
                            "text_tokens",
                            "image_tokens"
                          ]
                        }
                      },
                      "required": [
                        "total_tokens",
                        "input_tokens",
                        "output_tokens",
                        "input_tokens_details"
                      ],
                      "x-apifox-orders": [
                        "total_tokens",
                        "input_tokens",
                        "output_tokens",
                        "input_tokens_details"
                      ]
                    }
                  },
                  "required": [
                    "created",
                    "data",
                    "usage"
                  ],
                  "x-apifox-orders": [
                    "created",
                    "data",
                    "usage"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://api.xiexus.cn",
      "description": "固定生产地址"
    }
  ]
}