典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIImageOpenAI

Image Generation

POST/api/v1/image/generation

Header Parameters

Authorization*string

Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

model*string

Model name, fixed values: gpt-image-1.5, gpt-image-2

Value in"gpt-image-1.5" | "gpt-image-2"
prompt?string

A text description of the desired image. The maximum length for GPT image models is 32,000 characters.

background?string

Optional parameter: "transparent", "opaque", or "auto". When set to "auto", the model automatically determines the optimal background for the image. If set to "transparent", the output format must support transparency, so it should be set to png (default) or webp.

moderation?string

Optional parameter "low" or "auto". Used to control the content moderation level for images generated by GPT image models. The value must be low (less restrictive filtering) or auto (default).

n?integer

The number of images to generate. Must be between 1 and 10. Minimum: 1 Maximum: 10

output_compression?integer

Compression level for generated images (0-100%). This parameter is only supported by GPT image models and is only valid when the output format is webp or jpeg, with a default value of 100.

output_format?string

Optional parameter "png", "jpeg", or "webp". Returns the format of the generated image. This parameter is only supported by GPT image models. The value must be one of png, jpeg, or webp.

quality?string

quality: Optional parameter, one of "auto", "low", "medium", or "high".

size?string

size: Optional string, or "auto", "1024x1024", "1536x1024", and 5 other options. The size of the generated images. For gpt-image-2 and gpt-image-2-2026-04-21, any resolution is supported, specified as a widthxheight string, such as 1536x864. Both width and height must be divisible by 16. Resolutions above 2560x1440 are experimental, with a maximum supported resolution of 3840x2160. The requested size must also meet the model's current pixel and side length constraints. GPT image models support standard sizes of 1024x1024, 1536x1024, and 1024x1536; for models that allow automatic resizing, auto is supported.

user?string

A unique identifier for the end user that helps OpenAI monitor and detect abuse.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Number of Images

seconds*integer

Video Duration in Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Token Count

output_tokens*integer

Output Token Count

expired*string

Validity Period

task_id*string

Task ID

task_status*string

Task Status

message*string

Status Information

request_id*string

Request ID

curl -X POST "https://api.ygw.ai/api/v1/image/generation" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-image-1.5"  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}