Nano Banana Pro API Developer Reference
Complete developer reference guide for Nano Banana Pro API Visual Production Platform powered by advanced machine learning technologies
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.orgoverview.api_version
v1.0.0Nano Banana Pro API Quick Start
- 1. Create a Nano Banana Pro API account and obtain access credentials from our official website
- 2. Include your Nano Banana Pro API authentication token in the Authorization header
- 3. Send a POST request to the Nano Banana Pro API image generation endpoint
- 4. Use the returned Nano Banana Pro API task ID to check processing status
- 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-1234567890abcdefRequest 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/genRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model identifier (e.g., "google/gempix2") |
| prompt | string | Yes | Text prompt describing the image |
| images | array | No | Reference image URLs (max 4) |
| callback_url | string | No | Webhook 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| task_id | string | Yes | Unique 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 processingsubmitted - Nano Banana Pro API task has been queued for productionin_progress - Nano Banana Pro API task is currently being processedsuccess - Nano Banana Pro API task finished successfully and generated images are readyfailed - Nano Banana Pro API task encountered an error and could not completeError 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"
}| Field | Type | Description |
|---|---|---|
| image | string | Image 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
}
}| Field | Type | Description |
|---|---|---|
| result | array | Array of ImageGenResult objects (null if failed) |
| status | string | Final task status (success/failed) |
| task_id | string | Unique task identifier |
| consumed | string | Credits consumed by the task |
| status_reason | object | Status details including error message if failed |
Nano Banana Pro API Supported Models
google/gempix2Nano Banana image generation modelgoogle/gemini-2.5-flash-imageGemini 2.5 Flash image modelError 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
OK
Request was successful
Bad Request
Invalid request parameters or malformed JSON
Unauthorized
Invalid, missing, or expired API key
Not Found
Task not found or endpoint doesn't exist
Internal Server Error
Server-side error occurred
Error Handling Best Practices
- Always check HTTP status codes before processing response data
- Implement exponential backoff strategies for retry mechanisms when encountering 500 errors
- Log error messages with full context for debugging purposes
- Validate input parameters before sending requests to avoid 400 errors
- Resolve authentication issues by having clients refresh their API credentials
- Monitor task progress at reasonable intervals rather than polling status excessively
- 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;
}
}