Image Generation
/api/v1/image/generationHeader Parameters
Format: Authorization: Bearer sk-xxxxxx
Request Body
application/json
Model name, fixed values: gpt-image-1.5, gpt-image-2
"gpt-image-1.5" | "gpt-image-2"A text description of the desired image. The maximum length for GPT image models is 32,000 characters.
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.
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).
The number of images to generate. Must be between 1 and 10. Minimum: 1 Maximum: 10
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.
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: Optional parameter, one of "auto", "low", "medium", or "high".
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.
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.
Status Code
Data Object
Result Set
Usage Information
Number of Images
Video Duration in Seconds
Input Token Count
Total Token Count
Output Token Count
Validity Period
Task ID
Task Status
Status Information
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"
}