Nano Banana Image Edit API Documentation
Edit Image Request - Request Code
POST https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"prompt": "Edit the image to have a red hat",
"image_urls": [
"https://example.com/image1.jpg"
],
"output_format": "jpeg"
} import requests
import json
url = "https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"prompt": "Edit the image to have a red hat",
"image_urls": [
"https://example.com/image1.jpg"
],
"output_format": "jpeg"
}
response = requests.post(url, headers=headers, json=data)
print(response.json()) const url = 'https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest';
const data = {
prompt: 'Edit the image to have a red hat',
image_urls: [
'https://example.com/image1.jpg'
],
output_format: 'jpeg'
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error)); curl -v -X POST "https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" --data-raw '{
"prompt": "Edit the image to have a red hat",
"image_urls": [
"https://example.com/image1.jpg"
],
"output_format": "jpeg"
}' import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ApiExample {
public static void main(String[] args) throws Exception {
String json = "{" +
"\n \"prompt\": \"Edit the image to have a red hat\"," +
"\n \"image_urls\": [" +
"\n \"https://example.com/image1.jpg\"" +
"\n ]," +
"\n \"output_format\": \"jpeg\"" +
"\n}";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest"))
.header("Content-Type", "application/json")
.header("Cache-Control", "no-cache")
.header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} <?php
$url = 'https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest';
$data = [
'prompt' => 'Edit the image to have a red hat',
'image_urls' => [
'https://example.com/image1.jpg'
],
'output_format' => 'jpeg'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cache-Control: no-cache',
'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?> Output
Successful API response:
{
"request_id": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
} Request Body - Edit Image Request
Parameters for https://gateway.pixazo.ai/nano-banana/v1/nano-banana/generateEditImageRequest:
| Parameter | Required | Type | Description |
|---|---|---|---|
| prompt | Yes | string | Default: null, The prompt for image editing. Google's state-of-the-art image editing model that modifies existing images based on text descriptions |
| image_urls | Yes | array<string> | Default: null, List of URLs of input images for editing. The images will be edited according to the provided prompt |
| num_images | No | integer | Default: 1, The number of edited images to generate |
| output_format | No | string | Default: "jpeg", The format of the generated images. Values: "jpeg", "png" |
| sync_mode | No | boolean | Default: false, When true, edited images will be returned as data URIs instead of URLs |
Example Request - Edit Image Request
JSON
{
"prompt": "Edit the image to have a red hat",
"image_urls": [
"https://example.com/image1.jpg"
],
"output_format": "jpeg"
} Response - Edit Image Request
JSON
{
"request_id": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
} Request Headers
| Header | Description |
|---|---|
| Content-Type | application/json |
| Cache-Control | no-cache |
| Ocp-Apim-Subscription-Key | Your subscription key for authentication |
Response Handling
The Nano Banana returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement error handling in their applications to manage these responses effectively.
Common Status Codes and Responses
| Status Code | Description | Response Body |
|---|---|---|
| 200 | Success - The request was successfully processed. | { "success": true, ... } |
| 400 | Bad Request - The request contains invalid parameters or missing fields. | { "error": "Invalid request parameters" } |
| 401 | Unauthorized - The provided subscription key is missing or invalid. | { "error": "Invalid or missing authentication" } |
| 403 | Forbidden - The subscription does not have access to this API or action. | { "error": "Access denied for this operation" } |
| 404 | Not Found - The requested resource or endpoint could not be found. | { "error": "Endpoint not found" } |
| 429 | Too Many Requests - The request rate limit has been exceeded. | { "error": "Rate limit exceeded, please retry later" } |
| 500 | Internal Server Error - An unexpected error occurred on the server. | { "error": "An unexpected error occurred, please try again later" } |
Example Error Response
{
"error": "Invalid parameters"
} Retrieving Image Result and URL
After submitting your request, use this endpoint to check status and retrieve results.
Endpoint
POST https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus
Request Body
{
"requestId": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
} POST https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"requestId": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
} import requests
import json
url = "https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"requestId": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
}
response = requests.post(url, headers=headers, json=data)
print(response.json()) const url = 'https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus';
const data = {
requestId: '43c9e643-0693-4f99-9e92-ff15ef6d1c55'
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error)); curl -v -X POST "https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" --data-raw '{
"requestId": "43c9e643-0693-4f99-9e92-ff15ef6d1c55"
}' import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class PollingExample {
public static void main(String[] args) throws Exception {
String json = "{" +
"\n \"requestId\": \"43c9e643-0693-4f99-9e92-ff15ef6d1c55\"" +
"\n}";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus"))
.header("Content-Type", "application/json")
.header("Cache-Control", "no-cache")
.header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} <?php
$url = 'https://gateway.pixazo.ai/nano-banana-polling/nano-banana/getStatus';
$data = [
'requestId' => '43c9e643-0693-4f99-9e92-ff15ef6d1c55'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cache-Control: no-cache',
'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?> Nano Banana Image Edit API Pricing
| Ratio | Width | Height | Pixels | ScaleFactor | Price (USD) |
|---|---|---|---|---|---|
| 1:1 | 1024 | 1024 | 1048576 | 1 | $0.06 |
| 16:9 | 1920 | 1080 | 2073600 | 1.98 | $0.1188 |
| 21:9 | 2560 | 1096 | 2807360 | 2.68 | $0.1608 |
| 3:2 | 1800 | 1200 | 2160000 | 2.06 | $0.1236 |
| 2:3 | 1200 | 1800 | 2160000 | 2.06 | $0.1236 |
| 4:5 | 1080 | 1350 | 1458000 | 1.39 | $0.0834 |
| 5:4 | 1250 | 1000 | 1250000 | 1.19 | $0.0714 |
| 3:4 | 1080 | 1440 | 1555200 | 1.48 | $0.0888 |
| 4:3 | 1440 | 1080 | 1555200 | 1.48 | $0.0888 |
| 9:16 | 1080 | 1920 | 2073600 | 1.98 | $0.1188 |
Ready to generate Nano Banana Image Edit API assets?
Start with an API key, then automate your pipeline.