Edit an existing image
curl --request POST \
--url https://api.infery.ai/v1/images/edits \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image_base64": "<string>",
"image_mime_type": "image/png",
"mask_base64": "<string>",
"mask_mime_type": "image/png",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}
'import requests
url = "https://api.infery.ai/v1/images/edits"
payload = {
"model": "<string>",
"prompt": "<string>",
"image_base64": "<string>",
"image_mime_type": "image/png",
"mask_base64": "<string>",
"mask_mime_type": "image/png",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image_base64: '<string>',
image_mime_type: 'image/png',
mask_base64: '<string>',
mask_mime_type: 'image/png',
n: 1,
size: '1024x1024',
response_format: 'url'
})
};
fetch('https://api.infery.ai/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://api.infery.ai/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 => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'image_base64' => '<string>',
'image_mime_type' => 'image/png',
'mask_base64' => '<string>',
'mask_mime_type' => 'image/png',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'url'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.infery.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.infery.ai/v1/images/edits")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.infery.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1713204900,
"data": [
{
"url": "/samples/image.png"
}
],
"credits_used": 40
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}Images
Edit an image
POST /v1/images/edits — modify an existing image with a prompt.
POST
/
v1
/
images
/
edits
Edit an existing image
curl --request POST \
--url https://api.infery.ai/v1/images/edits \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image_base64": "<string>",
"image_mime_type": "image/png",
"mask_base64": "<string>",
"mask_mime_type": "image/png",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}
'import requests
url = "https://api.infery.ai/v1/images/edits"
payload = {
"model": "<string>",
"prompt": "<string>",
"image_base64": "<string>",
"image_mime_type": "image/png",
"mask_base64": "<string>",
"mask_mime_type": "image/png",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image_base64: '<string>',
image_mime_type: 'image/png',
mask_base64: '<string>',
mask_mime_type: 'image/png',
n: 1,
size: '1024x1024',
response_format: 'url'
})
};
fetch('https://api.infery.ai/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://api.infery.ai/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 => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'image_base64' => '<string>',
'image_mime_type' => 'image/png',
'mask_base64' => '<string>',
'mask_mime_type' => 'image/png',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'url'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.infery.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.infery.ai/v1/images/edits")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.infery.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_base64\": \"<string>\",\n \"image_mime_type\": \"image/png\",\n \"mask_base64\": \"<string>\",\n \"mask_mime_type\": \"image/png\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1713204900,
"data": [
{
"url": "/samples/image.png"
}
],
"credits_used": 40
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found",
"param": "model"
}
}Models like Nano Banana (Gemini Image) support edits — provide a source image + prompt:


Image-edit output format matches image generation.
curl https://api.infery.ai/v1/images/edits \
-H "Authorization: Bearer $INFERY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2-5-flash-image",
"prompt": "Replace the background with a tropical beach",
"image_base64": "<base64 of source image>"
}'
Sample output

Source image — autumn Japanese garden

Edited: 'Transform this into a snowy winter wonderland — keep the layout intact.' (gemini-2.5-flash-image)
Supported models
Image-edit capability is model-dependent. Checkcapabilities.imageEdit: true via GET /v1/models/{slug} or see Models catalog.Authorizations
API key in format: Bearer inf_***
Body
application/json
Edit instruction
Base64-encoded source image
Base64-encoded mask (transparent area = edit region)
Available options:
256x256, 512x512, 1024x1024, 1792x1024, 1024x1792 Available options:
url, b64_json ⌘I

