Docs ChatGPT Chat /v1/images/edits
API reference

edit image

Given a hint, the model will return one or more predicted completions and can also return the probability of the surrogate marker for each position. Complete creation for the provided prompts and parameters Official…

POST/v1/images/edits

Body Parametersmultipart/form-data

image* string

The picture to be edited. Must be a supported image file or image array. For gpt-image-1, each image should be a png, webp, or jpg file smaller than 25MB. For dall-e-2, you can only provide one image, and it should be a square png file smaller than 4MB.

prompt* string

A text description of the desired image. The maximum length for dall-e-2 is 1000 characters and for gpt-image-1 is 32000 characters.

mask* string

An additional image whose fully transparent areas (for example, with an alpha value of zero) indicate where the image should be edited. If multiple images are provided, the mask will be applied to the first image. Must be a valid PNG file, smaller than 4MB, and the same size as image.

model* string

The model to use for image generation. Only dall-e-2 and gpt-image-1 are supported. Defaults to dall-e-2 unless gpt-image-1-specific parameters are used.

n* integer

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

quality* string

The quality of the image that will be generated. Only gpt-image-1 supports high, medium, and low. dall-e-2 only supports standard. Defaults to auto.

response_format* string

The format in which the generated images are returned. Must be one of url or b64_json. URLs are valid for 60 minutes after generation. This parameter is only supported for dall-e-2; gpt-image-1 always returns base64-encoded images.

size* string

The size of the generated image. Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default) for gpt-image-1; must be one of 256x256, 512x512, or 1024x1024 for dall-e-2.

Responses

200 application/json
response-200 object
properties
choices* array

List of candidate results

created* integer

Creation time (Unix timestamp)

id* string

Resource or task ID

object* string

Object type identifier, e.g. chat.completion

usage* object

Token usage statistics

400 Bad request or validation failed application/json
response-400 object
properties
error* object
Request Body Example edit image
1{
2"size": "1024x1024",
3"prompt": "一直可爱的小猪",
4"model": "gpt-image-1",
5"n": 1
6}
Code Sample cURL
1curl -X POST "https://api.digislash.com/v1/images/edits" \
2-F "image=" \
3-F "prompt=一直可爱的小猪" \
4-F "mask=" \
5-F "model=gpt-image-1" \
6-F "n=1" \
7-F "quality=" \
8-F "response_format=" \
9-F "size=1024x1024"
Response
1▼{
2"id": "chatcmpl-123",
3"object": "chat.completion",
4"created": 1677652288,
5▼"choices": [
6▶{ 3 keys }
7],
8▼"usage": {
9"prompt_tokens": 9,
10"completion_tokens": 12,
11"total_tokens": 21
12}
13}