curl --request POST \
--url https://api.deepshi.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=nano-banana-2 \
--form 'prompt=remove the person on the left' \
--form 'image[]=<string>' \
--form 'image=<string>' \
--form n=1 \
--form response_format=b64_json \
--form stream=false \
--form seed=123 \
--form width=123 \
--form height=123 \
--form aspect_ratio=16:9 \
--form resolution=2K \
--form image_size=auto_2K \
--form 0.image[].items='@example-file' \
--form 0.image.items='@example-file' \
--form 1.image.items='@example-file' \
--form 1.image[].items='@example-file'import requests
url = "https://api.deepshi.ai/v1/images/edits"
files = {
"0.image[].items": ("example-file", open("example-file", "rb")),
"0.image.items": ("example-file", open("example-file", "rb")),
"1.image.items": ("example-file", open("example-file", "rb")),
"1.image[].items": ("example-file", open("example-file", "rb"))
}
payload = {
"model": "nano-banana-2",
"prompt": "remove the person on the left",
"image[]": "<string>",
"image": "<string>",
"n": "1",
"response_format": "b64_json",
"stream": "false",
"seed": "123",
"width": "123",
"height": "123",
"aspect_ratio": "16:9",
"resolution": "2K",
"image_size": "auto_2K"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'nano-banana-2');
form.append('prompt', 'remove the person on the left');
form.append('image[]', '<string>');
form.append('image', '<string>');
form.append('n', '1');
form.append('response_format', 'b64_json');
form.append('stream', 'false');
form.append('seed', '123');
form.append('width', '123');
form.append('height', '123');
form.append('aspect_ratio', '16:9');
form.append('resolution', '2K');
form.append('image_size', 'auto_2K');
form.append('0.image[].items', '{
"fileName": "example-file"
}');
form.append('0.image.items', '{
"fileName": "example-file"
}');
form.append('1.image.items', '{
"fileName": "example-file"
}');
form.append('1.image[].items', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.deepshi.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.deepshi.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 => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/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=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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": 123,
"model": "<string>",
"size": "<string>",
"data": [
{
"index": 123,
"b64_json": "<string>",
"url": "<string>",
"revised_prompt": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"cached_read_tokens": 123,
"image_tokens": 123
},
"completion_tokens": 123,
"completion_tokens_details": {
"reasoning_tokens": 123,
"image_tokens": 123
},
"total_tokens": 123,
"cost": {
"total_cost": 0.000135
}
}
}{
"error": {
"message": "The model does not exist or you do not have access to it.",
"type": "invalid_request_error",
"code": "model_not_found",
"param": null
}
}{
"error": {
"message": "Incorrect API key provided.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have insufficient credits to complete this request.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "The model does not exist or you do not have access to it.",
"type": "invalid_request_error",
"code": "model_not_found",
"param": null
}
}{
"error": {
"message": "Rate limit reached. Please retry after a short delay.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "The server had an error while processing your request. Please retry.",
"type": "api_error",
"code": null,
"param": null
}
}Edit an image
Edit or transform an existing image from a prompt and one or more input images. Sent as multipart/form-data. Supports the same model-specific sizing and quality parameters as image generation; how many reference images a model accepts varies (see the edit block in GET /v1/models).
curl --request POST \
--url https://api.deepshi.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=nano-banana-2 \
--form 'prompt=remove the person on the left' \
--form 'image[]=<string>' \
--form 'image=<string>' \
--form n=1 \
--form response_format=b64_json \
--form stream=false \
--form seed=123 \
--form width=123 \
--form height=123 \
--form aspect_ratio=16:9 \
--form resolution=2K \
--form image_size=auto_2K \
--form 0.image[].items='@example-file' \
--form 0.image.items='@example-file' \
--form 1.image.items='@example-file' \
--form 1.image[].items='@example-file'import requests
url = "https://api.deepshi.ai/v1/images/edits"
files = {
"0.image[].items": ("example-file", open("example-file", "rb")),
"0.image.items": ("example-file", open("example-file", "rb")),
"1.image.items": ("example-file", open("example-file", "rb")),
"1.image[].items": ("example-file", open("example-file", "rb"))
}
payload = {
"model": "nano-banana-2",
"prompt": "remove the person on the left",
"image[]": "<string>",
"image": "<string>",
"n": "1",
"response_format": "b64_json",
"stream": "false",
"seed": "123",
"width": "123",
"height": "123",
"aspect_ratio": "16:9",
"resolution": "2K",
"image_size": "auto_2K"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'nano-banana-2');
form.append('prompt', 'remove the person on the left');
form.append('image[]', '<string>');
form.append('image', '<string>');
form.append('n', '1');
form.append('response_format', 'b64_json');
form.append('stream', 'false');
form.append('seed', '123');
form.append('width', '123');
form.append('height', '123');
form.append('aspect_ratio', '16:9');
form.append('resolution', '2K');
form.append('image_size', 'auto_2K');
form.append('0.image[].items', '{
"fileName": "example-file"
}');
form.append('0.image.items', '{
"fileName": "example-file"
}');
form.append('1.image.items', '{
"fileName": "example-file"
}');
form.append('1.image[].items', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.deepshi.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.deepshi.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 => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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://api.deepshi.ai/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=\"model\"\r\n\r\nnano-banana-2\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nremove the person on the left\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=\"image\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\n\r\nb64_json\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"stream\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n16:9\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image_size\"\r\n\r\nauto_2K\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"0.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\r\nContent-Disposition: form-data; name=\"1.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\r\nContent-Disposition: form-data; name=\"1.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": 123,
"model": "<string>",
"size": "<string>",
"data": [
{
"index": 123,
"b64_json": "<string>",
"url": "<string>",
"revised_prompt": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"cached_read_tokens": 123,
"image_tokens": 123
},
"completion_tokens": 123,
"completion_tokens_details": {
"reasoning_tokens": 123,
"image_tokens": 123
},
"total_tokens": 123,
"cost": {
"total_cost": 0.000135
}
}
}{
"error": {
"message": "The model does not exist or you do not have access to it.",
"type": "invalid_request_error",
"code": "model_not_found",
"param": null
}
}{
"error": {
"message": "Incorrect API key provided.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have insufficient credits to complete this request.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "The model does not exist or you do not have access to it.",
"type": "invalid_request_error",
"code": "model_not_found",
"param": null
}
}{
"error": {
"message": "Rate limit reached. Please retry after a short delay.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "The server had an error while processing your request. Please retry.",
"type": "api_error",
"code": null,
"param": null
}
}Authorizations
Your Deepshi API key, sent as Authorization: Bearer <key>.
Body
- Option 1
- Option 2
Image edit request, sent as multipart/form-data. model, prompt, and at least one input image are required. Send the image files under either image[] or image — both are accepted.
The image model id to use. See GET /v1/models.
"nano-banana-2"
Instruction describing the edit to perform.
"remove the person on the left"
One or more input images to edit, each sent as a separate image[] part. How many reference images a model accepts varies from 1 up to 14. See the edit block in GET /v1/models.
Same as image[], under the field name the OpenAI SDKs use when you pass a single file. Send images under either this or image[].
Number of images to generate (1–4).
1 <= x <= 4How images are returned. url returns an inline base64 data: URI, not a hosted link.
b64_json, url Encoding of the returned image. Not all models honor every format.
png, jpeg, webp Stream the result as Server-Sent Events. Use it for slow, high-resolution generations that would otherwise time out.
Seed for reproducible output. Omit for a random seed.
Model-specific. Output width in pixels, for pixel-dimension models (e.g. flux-2-pro).
Model-specific. Output height in pixels, for pixel-dimension models.
Model-specific. Aspect ratio for aspect-ratio and resolution-tier models.
"16:9"
Model-specific. Resolution tier for resolution-tier models (e.g. nano-banana-2, nano-banana-pro, grok-imagine-quality). Determines the billed price for those models.
"2K"
Model-specific. Quality tier for the GPT Image models (gpt-image-1.5, gpt-image-2). Higher tiers cost more, and the price depends on the image size and quality you pick. Omit to use the model's default tier.
low, medium, high Model-specific. Named output size for preset-size models (e.g. seedream-4.5).
"auto_2K"
Response
The edited image(s). When stream: true, the response is a Server-Sent Events stream (text/event-stream): periodic keepalive comments followed by a terminal image_generation.completed event carrying the final image (see the ImageStreamEvent schema).
Unix timestamp when the request was created.
The image model id you requested.
The actual output dimensions, as WIDTHxHEIGHT.
The generated image(s).
Show child attributes
Show child attributes
Token usage and the billed cost for the request.
Show child attributes
Show child attributes
Was this page helpful?