Skip to main content
POST
/
images
/
edits
Create image edit
curl --request POST \
  --url https://dimilinks.com/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=<string>' \
  --form model=gpt-image-2 \
  --form 'size=<string>' \
  --form 'resolution=<string>' \
  --form image='@example-file' \
  --form 'image[]=<string>' \
  --form mask='@example-file' \
  --form image[].items='@example-file'
import requests

url = "https://dimilinks.com/v1/images/edits"

files = {
"image": ("example-file", open("example-file", "rb")),
"mask": ("example-file", open("example-file", "rb")),
"image[].items": ("example-file", open("example-file", "rb"))
}
payload = {
"prompt": "<string>",
"model": "gpt-image-2",
"size": "<string>",
"resolution": "<string>",
"image[]": "<string>"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('prompt', '<string>');
form.append('model', 'gpt-image-2');
form.append('size', '<string>');
form.append('resolution', '<string>');
form.append('image', '<string>');
form.append('image[]', '<string>');
form.append('mask', '<string>');
form.append('image[].items', '{
"fileName": "example-file"
}');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

fetch('https://dimilinks.com/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://dimilinks.com/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n<string>\r\n-----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=\"image%5B%5D\"\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=\"image[].items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://dimilinks.com/v1/images/edits"

payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n<string>\r\n-----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=\"image%5B%5D\"\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=\"image[].items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\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://dimilinks.com/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n<string>\r\n-----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=\"image%5B%5D\"\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=\"image[].items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();
require 'uri'
require 'net/http'

url = URI("https://dimilinks.com/v1/images/edits")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n<string>\r\n-----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=\"image%5B%5D\"\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=\"image[].items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "created": 1777080000,
  "task_id": "img_xxx",
  "data": [
    {
      "url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
      "file_id": "file_xxx"
    }
  ]
}
{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}
/v1/images/edits accepts multipart/form-data and uploads reference images as files. If your references are already URLs or Data URLs, we recommend using Create image generation with image_urls for a more reliable asynchronous workflow.

Request URL

POST https://dimilinks.com/v1/images/edits
Content-Type: multipart/form-data
Authorization: Bearer <DIMILINKS_API_KEY>
Upload at least one image file.

Single-image example

curl "https://dimilinks.com/v1/images/edits" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=Restyle the image as vintage film while preserving the main subject" \
  -F "size=16:9" \
  -F "resolution=2k" \
  -F "image=@/path/to/reference.png"

Multiple-image example

Upload up to nine reference images.
curl "https://dimilinks.com/v1/images/edits" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=Blend the styles of both reference images to create a primary ecommerce product image" \
  -F "size=1:1" \
  -F "resolution=4k" \
  -F "image[]=@/path/to/ref-1.png" \
  -F "image[]=@/path/to/ref-2.png"

File fields

FieldDescription
imageSingle file; recommended.
image[]Multiple files, up to nine.
imagesCompatibility field for multiple files.
images[]Compatibility field for multiple files.
image_1, image_2Compatibility fields with numbered names.
maskOptional. Currently processed as another reference image.

Response

On success, the endpoint returns the same structure as the generation endpoint:
{
  "created": 1777080000,
  "task_id": "img_xxx",
  "data": [
    {
      "url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
      "file_id": "file_xxx"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
prompt
string
required
model
string
default:gpt-image-2
size
string
resolution
string
image
file
image[]
file[]
Maximum array length: 9
mask
file

Response

Image edit result

created
integer
Example:

1777080000

task_id
string
Example:

"img_xxx"

data
object[]