NodeKeyNodeKey
AI model interfaceImagesGPT Image 2

GPT Image 2 Image Generation

Use the OpenAI image API to generate images. The current project supports gpt-image-2-1k, gpt-image-2-2k, and gpt-image-2-4k model variants; if quality is not provided, it defaults to medium, and if n is not provided or set to 0, it processes as 1.

POST
/v1/images/generations
AuthorizationBearer <token>

In: header

Request Body

application/json

model*string

模型名称。gpt-image-2gpt-image-2-vip 为可选模型;gpt-image-2-1k 默认生成 1024x1024gpt-image-2-2k 默认生成 2048x2048gpt-image-2-4k 默认生成 3840x2160

Value in"gpt-image-2" | "gpt-image-2-vip" | "gpt-image-2-1k" | "gpt-image-2-2k" | "gpt-image-2-4k"
prompt*string

图像生成提示词。

n?integer

生成图片数量。未传或传 0 时按 1 处理。

Range1 <= value
size?string

输出尺寸。gpt-image-2-1k 支持 1024x10241536x10241024x1536gpt-image-2-2k 支持 2048x20482048x1152gpt-image-2-4k 支持 3840x21602160x3840

quality?string

生成质量。项目未传时默认补为 medium

Default"medium"
response_format?string

返回图片格式。

Value in"url" | "b64_json"
background?string

透传给上游的背景设置。

moderation?string

透传给上游的内容审核设置。

output_format?string

透传给上游的输出格式。

output_compression?integer

透传给上游的输出压缩参数。

partial_images?unknown

透传给上游的局部图片参数。

user?string

最终用户标识。

Response Body

application/json

curl -X POST "https://nodekey.xinghanyun.cn/v1/images/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-image-2",    "prompt": "一张红色山地自行车的产品海报,白色背景,清晰棚拍",    "size": "1024x1024",    "quality": "medium",    "n": 1,    "response_format": "url"  }'
{
  "created": 0,
  "data": [
    {
      "url": "string",
      "b64_json": "string",
      "revised_prompt": "string"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0,
    "prompt_tokens_details": {
      "text_tokens": 0,
      "image_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 0
    }
  }
}

Last updated on