Nano Banana Pro API Developer Reference

Complete developer reference guide for Nano Banana Pro API Visual Production Platform powered by advanced machine learning technologies

View PricingDiscover Nano Banana Pro API subscription plans

Nano Banana Pro API Overview

The Nano Banana Pro API Visual Production service allows developers to connect with advanced machine learning engines to produce high-quality imagery from text prompts and reference photographs. Our Nano Banana Pro API solution provides a straightforward REST interface with comprehensive task management and real-time notification features.

Nano Banana Pro API Key Features

  • Nano Banana Pro API text-to-image conversion using state-of-the-art machine learning engines
  • Nano Banana Pro API reference image support (up to 4 reference images)
  • Nano Banana Pro API asynchronous task processing with real-time progress tracking
  • Nano Banana Pro API webhook notifications for immediate status changes
  • Nano Banana Pro API RESTful interface returning structured JSON data
  • Nano Banana Pro API Bearer token authentication mechanism

overview.base_url

https://api.defapi.org

overview.api_version

v1.0.0

Nano Banana Pro API Quick Start

  1. 1. Create a Nano Banana Pro API account and obtain access credentials from our official website
  2. 2. Include your Nano Banana Pro API authentication token in the Authorization header
  3. 3. Send a POST request to the Nano Banana Pro API image generation endpoint
  4. 4. Use the returned Nano Banana Pro API task ID to check processing status
  5. 5. Retrieve your Nano Banana Pro API generated images when processing completes

Access Authentication

All API requests must include valid authentication using Bearer token credentials. Include your API key in the Authorization header for every request.

Authentication Method

Use HTTP Bearer token authentication by including your API credentials in the Authorization header:

Authorization: Bearer <your-api-key>

Example API Key Format

Authorization: Bearer dk-1234567890abcdef

Request Example

curl -X POST "https://api.defapi.org/api/image/gen" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key-here" \
  -d '{
    "model": "google/gempix2",
    "prompt": "A beautiful landscape"
  }'

Valid Authentication

  • API credentials have not expired
  • Account registration is in good standing
  • Sufficient account balance is available

Common Problems

  • Missing API credentials in request
  • Invalid or incorrectly formatted API key
  • Account is disabled or account access is revoked

Nano Banana Pro API Image Generation

Create images using Nano Banana Pro API with advanced machine learning technologies and flexible text prompts along with reference images.

API Endpoint

POST /api/image/gen

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel identifier (e.g., "google/gempix2")
promptstringYesText prompt describing the image
imagesarrayNoReference image URLs (max 4)
callback_urlstringNoWebhook URL for completion notifications

Usage Examples

Basic Nano Banana Pro API Image Creation

{
  "model": "google/gempix2",
  "prompt": "A beautiful girl dancing in a garden"
}

Nano Banana Pro API Reference-Based Generation with Sample Images

{
  "model": "google/gempix2",
  "prompt": "Put them in a basket",
  "images": [
    "https://cdn.openai.com/API/docs/images/body-lotion.png",
    "https://cdn.openai.com/API/docs/images/soap.png"
  ],
  "callback_url": "https://example.com/webhook/image-callback"
}

Response Format

{
  "code": 0,
  "message": "ok",
  "data": {
    "task_id": "ta12345678-1234-1234-1234-123456789abc"
  }
}

Error Handling

400 - Bad Request

{"code": 1, "message": "failed", "detail": "prompt is required"}

401 - Unauthorized

{"code": 1, "message": "Invalid API key"}

Nano Banana Pro API Task Status

Query the status and results of Nano Banana Pro API image generation tasks using the task ID returned by the Nano Banana Pro API image generation endpoint.

API Endpoint

GET /api/task/query?task_id=<task_id>

Query Parameters

ParameterTypeRequiredDescription
task_idstringYesUnique task identifier returned from generation endpoint

Request Example

curl -X GET "https://api.defapi.org/api/task/query?task_id=ta823dfb-eaac-44fd-aec2-3e2c7ba8e071" \
  -H "Authorization: Bearer your-api-key-here"

Nano Banana Pro API Task Status Types

pending - Nano Banana Pro API task has been created and is waiting to begin processing
submitted - Nano Banana Pro API task has been queued for production
in_progress - Nano Banana Pro API task is currently being processed
success - Nano Banana Pro API task finished successfully and generated images are ready
failed - Nano Banana Pro API task encountered an error and could not complete

Error Responses

404 - Task Not Found

{"code": 1, "message": "task not found"}

401 - Unauthorized

{"code": 401, "message": "Invalid API key"}

Nano Banana Pro API Data Structures

Complete reference for all Nano Banana Pro API data formats and schemas used in API requests and responses.

ImageGenResult

Represents a generated image result.

{
  "image": "https://google.datas.systems/fileSystem/response_images/287/2025/08/29/1756432513771985292_2989.png"
}
FieldTypeDescription
imagestringImage URL or base64 data URI

CallbackPayload

Payload sent to the callback_url when task status changes to final states.

{
  "result": [
    {
      "image": "https://google.datas.systems/fileSystem/response_images/287/2025/08/29/1756432513771985292_2989.png"
    }
  ],
  "status": "success",
  "task_id": "ta5c9705-b8ae-4cb9-aa6f-97c4fee88c8d",
  "consumed": "0.500000",
  "status_reason": {
    "message": null
  }
}
FieldTypeDescription
resultarrayArray of ImageGenResult objects (null if failed)
statusstringFinal task status (success/failed)
task_idstringUnique task identifier
consumedstringCredits consumed by the task
status_reasonobjectStatus details including error message if failed

Nano Banana Pro API Supported Models

google/gempix2Nano Banana image generation model
google/gemini-2.5-flash-imageGemini 2.5 Flash image model

Error Management

Complete guide for handling errors and interpreting API response codes. All error messages follow a consistent format to enable effective troubleshooting procedures.

HTTP Status Codes

200

OK

Request was successful

400

Bad Request

Invalid request parameters or malformed JSON

401

Unauthorized

Invalid, missing, or expired API key

404

Not Found

Task not found or endpoint doesn't exist

500

Internal Server Error

Server-side error occurred

Error Handling Best Practices

  1. Always check HTTP status codes before processing response data
  2. Implement exponential backoff strategies for retry mechanisms when encountering 500 errors
  3. Log error messages with full context for debugging purposes
  4. Validate input parameters before sending requests to avoid 400 errors
  5. Resolve authentication issues by having clients refresh their API credentials
  6. Monitor task progress at reasonable intervals rather than polling status excessively
  7. Use webhook notifications when possible to avoid constant polling for completion status

Example Error Handling (JavaScript)

async function generateImage(prompt, apiKey) {
  try {
    const response = await fetch('https://api.defapi.org/api/image/gen', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        model: 'google/gempix2',
        prompt: prompt
      })
    });

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`API Error ${response.status}: ${errorData.message}`);
    }

    const data = await response.json();
    return data.data.task_id;

  } catch (error) {
    console.error('Image generation failed:', error.message);
    throw error;
  }
}