The GPT Image 2 API leverages OpenAI's gpt-image-2 model to generate high-quality images from text prompts with customizable quality levels and sizes. It supports image-to-image editing via reference images, batch generation, and flexible aspect ratios.
taskId.Enum: application/json
Bearer authentication token. Example: Bearer {{APIKey}}.
The text description of the image to generate. Maximum length is 4000 characters.
The width of the generated image in pixels. Must be a multiple of 16 and between 16 and 3840. Default value: 1024.
The height of the generated image in pixels. Must be a multiple of 16 and between 16 and 3840. Default value: 1024.
The quality level of the generated image. Enum: low, medium, high. Lower quality generates faster results with fewer credits. Default value: low.
The number of images to generate in a single request. Must be between 1 and 10. Default value: 1.
A list of publicly accessible reference image URLs (maximum 4 items). When provided, the API performs image-to-image editing based on the reference images. Supported formats include JPG, JPEG, PNG, WEBP, and GIF.
Returns 0 for success, or a specific error code.
Returns "success" or a descriptive error message.
The unique identifier for the task. Use this ID with the Polling API to retrieve the generated images.
Use the Polling API to retrieve the processing results.
Alternatively, you can enable Callback to receive task results automatically upon completion.
{
"code": 0,
"message": "success",
"data": {
"images": [
{
"imageUrl": "https://dreamface-resource-new.oss-cn-hongkong.aliyuncs.com/df-ability-tmp/84064945-12a0-4ced-8b44-88663f5a1ac1-0.jpg",
"imageType": "png"
}
],
"task": {
"taskId": "API-177ecf0d5aac4571b9ce1bec58f26524",
"status": 3,
"errorCode": 0,
"reason": "ok",
"taskType": "gpt_image",
"executionTime": 229393,
"creditsConsumed": 144,
"expire": 1780651903492
}
}
}curl -X POST 'https://api.newportai.com/api/async/gpt_image' \
-H "Authorization: Bearer {{APIKey}}" \
-H 'Content-Type: application/json' \
-d '{
"width":1024,
"height":1024,
"quality":"high",
"prompt":"A wild ginseng plant with intact roots and natural soil, macro photography, 8K",
"n":1
}'{
"code": 0,
"message": "success",
"data": {
"taskId": "API-177ecf0d5aac4571b9ce1bec58f26524"
}
}