1. 图片
Xmodel
  • 快速开始
  • 新手入门
  • 开发者接入指南
  • 常见问题
  • 平台规则与支持
  • 客户端接入
    • CC Switch(小白用)
    • Claude Code 接入
    • Codex 接入
    • Codex + Image2
    • Qoder 接入
  • 账号与计费
    • 账号、额度与 Token
    • 模型与价格
  • API 接口参考
    • AI 模型接口
      • 对话
        • OpenAi协议对话
        • Anthropic 协议对话
        • Gemini协议对话
        • Codex 协议对话
      • 图片
        • 生成图片
          POST
        • 编辑图片
          POST
      • 模型信息
        • 列出模型
        • 列出 Gemini 模型
  1. 图片

生成图片

POST
/v1/images/generations
文本生成图片。

请求参数

Authorization
Bearer Token
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
or
Header 参数

Body 参数application/json

示例
{
  "model": "gpt-image-2",
  "prompt": "A simple product studio photo of a matte ceramic cup on a plain table, vertical composition. strictly rendered in a mandatory [1088x1920] aspect ratio, native widescreen composition, cinematic framing, no horizontal or vertical cropping, no distortion, no stretched elements, perfect alignment to the designated canvas size, high resolution.",
  "size": "1088x1920",
  "quality": "high",
  "output_format": "png",
  "background": "auto",
  "n": 1
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location '/v1/images/generations' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
  "model": "gpt-image-2",
  "prompt": "A simple product studio photo of a matte ceramic cup on a plain table, vertical composition. strictly rendered in a mandatory [1088x1920] aspect ratio, native widescreen composition, cinematic framing, no horizontal or vertical cropping, no distortion, no stretched elements, perfect alignment to the designated canvas size, high resolution.",
  "size": "1088x1920",
  "quality": "high",
  "output_format": "png",
  "background": "auto",
  "n": 1
}'

返回响应

🟢200
application/json
成功生成图像
Bodyapplication/json

示例
{
  "created": 1783566091,
  "background": "auto",
  "data": [
    {
      "b64_json": "",
      "revised_prompt": "A simple product studio photo of a matte ceramic cup on a plain table, vertical composition. strictly rendered in a mandatory [1088x1920] aspect ratio, native widescreen composition, cinematic framing, no horizontal or vertical cropping, no distortion, no stretched elements, perfect alignment to the designated canvas size, high resolution."
    }
  ],
  "output_format": "png",
  "quality": "high",
  "size": "944x1666",
  "usage": {
    "input_tokens": 65,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 65
    },
    "output_tokens": 6460,
    "total_tokens": 6525,
    "output_tokens_details": {
      "image_tokens": 6460,
      "text_tokens": 0
    }
  },
  "moderation": "auto"
}
上一页
Codex 协议对话
下一页
编辑图片
Built with