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:

ParameterRequiredTypeDescription
promptYesstringDefault: null, The prompt for image editing. Google's state-of-the-art image editing model that modifies existing images based on text descriptions
image_urlsYesarray<string>Default: null, List of URLs of input images for editing. The images will be edited according to the provided prompt
num_imagesNointegerDefault: 1, The number of edited images to generate
output_formatNostringDefault: "jpeg", The format of the generated images. Values: "jpeg", "png"
sync_modeNobooleanDefault: 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

HeaderDescription
Content-Typeapplication/json
Cache-Controlno-cache
Ocp-Apim-Subscription-KeyYour 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 CodeDescriptionResponse Body
200Success - The request was successfully processed.{ "success": true, ... }
Bad Request - The request contains invalid parameters or missing fields.{ "error": "Invalid request parameters" }
401Unauthorized - The provided subscription key is missing or invalid.{ "error": "Invalid or missing authentication" }
403Forbidden - The subscription does not have access to this API or action.{ "error": "Access denied for this operation" }
404Not Found - The requested resource or endpoint could not be found.{ "error": "Endpoint not found" }
Too Many Requests - The request rate limit has been exceeded.{ "error": "Rate limit exceeded, please retry later" }
500Internal 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:11024102410485761$0.06
16:91920108020736001.98$0.1188
21:92560109628073602.68$0.1608
3:21800120021600002.06$0.1236
2:31200180021600002.06$0.1236
4:51080135014580001.39$0.0834
5:41250100012500001.19$0.0714
3:41080144015552001.48$0.0888
4:31440108015552001.48$0.0888
9:161080192020736001.98$0.1188

Ready to generate Nano Banana Image Edit API assets?

Start with an API key, then automate your pipeline.