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>'import requests
url = "https://api.dgrid.ai/v1/images/edits"
files = {
"image": ("example-file", open("example-file", "rb")),
"mask": ("example-file", open("example-file", "rb"))
}
payload = {
"prompt": "<string>",
"model": "<string>",
"n": "123",
"size": "<string>",
"response_format": "<string>",
"user": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('image', '<string>');
form.append('prompt', '<string>');
form.append('mask', '<string>');
form.append('model', '<string>');
form.append('n', '123');
form.append('size', '<string>');
form.append('response_format', '<string>');
form.append('user', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.dgrid.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dgrid.ai/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dgrid.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();{
"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
}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Images
Qwen Image Edits
Edit an uploaded image with an optional mask using the OpenAI-compatible image editing endpoint. Also accepts Qwen-compatible JSON payloads with an input.messages wrapper.
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>'import requests
url = "https://api.dgrid.ai/v1/images/edits"
files = {
"image": ("example-file", open("example-file", "rb")),
"mask": ("example-file", open("example-file", "rb"))
}
payload = {
"prompt": "<string>",
"model": "<string>",
"n": "123",
"size": "<string>",
"response_format": "<string>",
"user": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('image', '<string>');
form.append('prompt', '<string>');
form.append('mask', '<string>');
form.append('model', '<string>');
form.append('n', '123');
form.append('size', '<string>');
form.append('response_format', '<string>');
form.append('user', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.dgrid.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dgrid.ai/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dgrid.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();{
"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
}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}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
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier, such as wanx-v1. |
input | object | Yes | Input wrapper object sent in the request body, used instead of multipart image/mask fields. |
input.messages | array | Yes | Messages array nested under input. |
input.messages[].role | string | Yes | Message role, e.g. user. |
input.messages[].content | string | Yes | Editing 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:integer
Creation timestamp.
array
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
Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.
Body
multipart/form-dataapplication/json
⌘I

