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

Image Editing

Images must be uploaded via multipart/form-data.

POST/api/v1/image/generation

Header Parameters

Authorization*string

Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

model*string

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

Value in"gpt-image-1.5" | "gpt-image-2"
images?array<object>

Input image URL. Input image reference for editing. For GPT image models, you can provide up to 16 images.

[]?object
prompt?string

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

background?string

Optional parameter: "transparent", "opaque", or "auto". When using 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.

input_fidelity?string

Optional values are "high" or "low", controlling the fidelity to the original input image.

mask?string

Input image URL. An additional image whose fully transparent areas (e.g., where alpha is zero) indicate where the image should be edited. If multiple images are provided, this mask will be applied to the first image. Must be a valid PNG file, less than 4MB in size, and have the same dimensions as the original image.

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". The format of the returned 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 "auto", "low", "medium", or "high".

size?string

size: Optional string, or "auto", "1024x1024", "1536x1024".

user?string

A unique identifier for the end user, which 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 Seconds

input_tokens*integer

Input Tokens

total_tokens*integer

Total Tokens

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"
}