Skip to main content
POST
/
api
/
v3
/
openai
/
gpt-image-1
/
image-edit
Image to Image
curl --request POST \
  --url https://gptproto.com/api/v3/openai/gpt-image-1/image-edit \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '{
  "image": [
    {}
  ],
  "prompt": "<string>",
  "mask": "<string>",
  "n": 123,
  "quality": "<string>",
  "size": "<string>",
  "background": "<string>",
  "enable_sync_mode": true
}'
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}

Overview

This endpoint allows you to transform existing images based on text descriptions. You can apply transformations, add elements, or modify the image content according to your prompt.

Authentication

This endpoint requires authentication using a Bearer token.
Authorization
string
default:"sk-***********"
required
Your API key in the format: YOUR_API_KEY
Content-Type
string
default:"application/json"
required
Must be set to application/json

Request Body

image
array
required
An array of image URLs to be edited. Currently supports one image at a time.
prompt
string
default:"The cat is running on the grassland"
required
The text prompt describing the desired changes or transformations to the image
mask
string
default:""
Optional mask image URL to specify which parts of the image should be edited
n
integer
default:"2"
The number of edited images to generate. Must be between 1 and 10.
quality
string
default:"medium"
The quality of the generated images. Options: low, medium, high
size
string
default:"1024x1024"
The size of the generated images. Common sizes: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792
background
string
default:""
Optional background setting for the image
enable_sync_mode
boolean
default:"false"
Whether to enable synchronous mode. If true, the response will wait until the image is generated. If false, returns immediately with a task ID.

Request Example

curl --location 'https://gptproto.com/api/v3/openai/gpt-image-1/image-edit' \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "image": [
        "https://heyoo.oss-ap-southeast-1.aliyuncs.com/ai-draw/java/test/d95aeb5f-2081-4db5-9e41-7230f51b49e0.png"
    ],
    "prompt": "The cat is running on the grassland",
    "mask": "",
    "n": 2,
    "quality": "medium",
    "size": "1024x1024",
    "background": "",
    "enable_sync_mode": false
}'

Response

Success (Async Mode)
200
Successful response when enable_sync_mode is false
{
  "task_id": "abc123def456",
  "status": "processing",
  "message": "Image editing task has been submitted"
}
Success (Sync Mode)
200
Successful response when enable_sync_mode is true
{
  "created": 1700000000,
  "data": [
    {
      "url": "https://example.com/edited-image-1.png",
      "b64_json": null
    },
    {
      "url": "https://example.com/edited-image-2.png",
      "b64_json": null
    }
  ]
}

Error Responses

{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}