# Nano Banana Pro API Complete API reference for Nano Banana Pro models powered by Google Gemini. ## Model Variants This API supports two model variants: | Model | ID | Description | |-------|-----|-------------| | **Nano Banana Pro** | `nano-banana-pro` | Text-to-image generation with up to 4K output | | **Nano Banana Pro Edit** | `nano-banana-pro-edit` | Image editing and multi-image composition | ## Quick Comparison | Feature | Nano Banana Pro | Nano Banana Pro Edit | |---------|-----------------|----------------------| | Input | Text prompt | Image(s) + Text prompt | | Max Resolution | 4K | 4K | | Resolution Options | 1K, 2K, 4K | 1K, 2K, 4K | | Aspect Ratios | 11 options | 11 options | | Image Input | ❌ No | ✅ Yes (1-14 images) | | Multi-Image Support | ❌ No | ✅ Yes | ### Supported Aspect Ratios Both models support 11 aspect ratios: - `16:9` (default), `9:16`, `1:1`, `3:2`, `2:3`, `4:3`, `3:4`, `4:5`, `5:4`, `21:9`, `9:21` ## Nano Banana Pro (Text-to-Image) ### Endpoint ``` POST /api/v1/image/task ``` ### Authentication ``` Authorization: Bearer YOUR_API_KEY ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"nano-banana-pro"` | | `prompt` | string | Image generation prompt | | `width` | number | Width ratio value (e.g., 16 for 16:9) | | `height` | number | Height ratio value (e.g., 9 for 16:9) | | `resolution` | string | Output resolution: `"1k"`, `"2k"`, `"4k"` | **Note:** The width:height ratio must be one of: "21:9", "9:21", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "1:1" ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/image/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'nano-banana-pro', prompt: 'A serene mountain landscape at sunset', width: 16, height: 9, resolution: '2k' }) }); const { data } = await response.json(); const taskId = data.task_id; // Poll for results const pollResponse = await fetch( `https://api.flaq.ai/api/v1/image/${taskId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const result = await pollResponse.json(); console.log(result.data.task_result.images[0].url); ``` ## Nano Banana Pro Edit (Image Editing) ### Endpoint ``` POST /api/v1/image/task ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"nano-banana-pro-edit"` | | `prompt` | string | Description of desired edits | | `width` | number | Width ratio value (e.g., 16 for 16:9) | | `height` | number | Height ratio value (e.g., 9 for 16:9) | | `resolution` | string | Output resolution: `"1k"`, `"2k"`, `"4k"` | | `image_url_list` | string[] | Input image URL array (1-14 items) | **Note:** The width:height ratio must be one of: "21:9", "9:21", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "1:1" ### Single Image Edit Example ```javascript { model_name: 'nano-banana-pro-edit', prompt: 'Change the sky to sunset colors', width: 16, height: 9, resolution: '2k', image_url_list: ['https://example.com/image.jpg'] } ``` ### Multi-Image Composition Example ```javascript { model_name: 'nano-banana-pro-edit', prompt: 'Combine these images into a cohesive landscape', width: 16, height: 9, resolution: '2k', image_url_list: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg', 'https://example.com/image3.jpg'] } ``` ## Response Format ### Initial Response Both models return a `task_id` for polling: ```json { "code": 0, "data": { "task_id": "{task_id}", "task_status": "submitted", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}" }, "message": "success" } ``` ### Polling Response Poll `/api/v1/image/{taskId}` to check status: ```json { "code": 0, "data": { "task_id": "{task_id}", "task_status": "succeed", "task_status_msg": null, "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_result": { "credit": 0.0997, "images": [ { "url": "https://example.com/generated-image.jpeg" } ] } }, "message": "success" } ``` ### Status Values - `submitted`: Task accepted - `processing`: Generation in progress - `succeed`: Generation completed successfully - `failed`: Generation failed ## Error Handling ### Common Errors **Invalid Resolution** ```json { "code": 400, "message": "Resolution must be one of: 1k, 2k, 4k" } ``` **Invalid Aspect Ratio** ```json { "code": 400, "message": "Ratio must be one of: 16:9, 9:16, 1:1, 3:2, 2:3, 4:3, 3:4, 4:5, 5:4, 21:9, 9:21" } ``` **Missing Image URL (Edit Mode)** ```json { "code": 400, "message": "image_url_list is required for nano-banana-pro-edit" } ``` ## Best Practices ### Text-to-Image Tips 1. **Be Specific**: Include subject, style, lighting, composition details 2. **Choose Resolution Wisely**: 2K is default and cost-effective, use 4K for highest quality 3. **Aspect Ratio Selection**: Choose ratio based on your use case (16:9 for web, 9:16 for mobile) 4. **Prompt Quality**: More detailed prompts generally produce better results ### Image Editing Tips 1. **Clear Instructions**: Be specific about what to change 2. **Multi-Image Composition**: Can combine up to 14 images in a single request 3. **Resolution Matching**: Output resolution can differ from input 4. **Prompt Guidance**: Describe the desired outcome, not just the changes ## Example Use Cases ### Product Photography ```javascript { model_name: 'nano-banana-pro', prompt: 'Professional product shot of luxury watch on marble surface', width: 4, height: 3, resolution: '4k' } ``` ### Multi-Image Collage ```javascript { model_name: 'nano-banana-pro-edit', image_url_list: [ 'photo1.jpg', 'photo2.jpg', 'photo3.jpg' ], prompt: 'Create a seamless collage with these vacation photos', width: 16, height: 9, resolution: '2k' } ``` ### Image Enhancement ```javascript { model_name: 'nano-banana-pro-edit', image_url_list: ['photo.jpg'], prompt: 'Enhance colors and add dramatic lighting', width: 1, height: 1, resolution: '2k' } ```