Skip to main content
POST
/
v1
/
images
/
edits
Edit image
curl --request POST \
  --url https://api.dgrid.ai/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form image='@example-file' \
  --form 'prompt=<string>' \
  --form mask='@example-file' \
  --form 'model=<string>' \
  --form n=123 \
  --form 'size=<string>' \
  --form 'response_format=<string>' \
  --form 'user=<string>'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>",
      "revised_prompt": "<string>"
    }
  ],
  "usage": {
    "total_tokens": 123,
    "input_tokens": 123,
    "output_tokens": 123,
    "input_tokens_details": {
      "text_tokens": 123,
      "image_tokens": 123
    }
  }
}
This page uses the same images/edits operation as Edit image, with the playground above pre-filled for the generic OpenAI-style edit schema (image, mask, prompt, etc.). The notes below describe the Qwen-specific request shape for wanx-v1 style models.
Qwen image editing models accept an alternate JSON request shape that wraps your editing instructions and source image references inside input.messages, rather than uploading image/mask files via multipart form data. Provide model and input together in the playground’s request body to use this shape.

Qwen-specific request fields

FieldTypeRequiredDescription
modelstringYesModel identifier, such as wanx-v1.
inputobjectYesInput wrapper object sent in the request body, used instead of multipart image/mask fields.
input.messagesarrayYesMessages array nested under input.
input.messages[].rolestringYesMessage role, e.g. user.
input.messages[].contentstringYesEditing instructions and any referenced source image(s).
Source images can be referenced inline within input.messages[].content (for example as URLs or embedded references) rather than as separate multipart file uploads.

Example: editing an image

{
  "model": "wanx-v1",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": "Remove the background and replace it with a solid white backdrop."
      }
    ]
  }
}

Response fields

The response follows the standard image edit shape:
created
integer
Creation timestamp.
data
array
Generated image entries.

Example response

200
{
  "created": 1719859200,
  "data": [
    {
      "url": "https://cdn.dgrid.ai/generated/edited-abc123.png",
      "b64_json": "",
      "revised_prompt": "The subject with background removed and replaced with a solid white backdrop."
    }
  ]
}

Authorizations

Authorization
string
header
required

Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.

Body

image
file
required

Source image in PNG format, under 4 MB.

prompt
string
required

Editing instruction.

mask
file

Optional mask image.

model
string

Target image model.

n
integer

Number of outputs.

size
string

Output size.

response_format
string

Response format.

user
string

End-user identifier.

Response

Edited images in the image generation response format.

created
integer

Creation timestamp.

data
object[]

Generated image entries.

usage
object