# Nano Banana 2.1 API Complete API reference for Nano Banana 2.1 text-to-image and image editing models. ## Model Variants This API supports two model variants: | Model | ID | Description | |-------|-----|-------------| | **Nano Banana 2.1** | `nano-banana-2.1` | Text-to-image generation | | **Nano Banana 2.1 Edit** | `nano-banana-2.1-edit` | Image editing with up to 14 reference images | ## Quick Comparison | Feature | Nano Banana 2.1 | Nano Banana 2.1 Edit | |---------|-----------------|----------------------| | Input | Text prompt | Image(s) + Text prompt | | Max Resolution | 4K | 4K | | Resolution Options | 1K, 2K, 4K | 1K, 2K, 4K | | Aspect Ratios | 14 options | 14 options | | Image Input | ❌ No | ✅ Yes (1-14 images) | | Multi-Image Support | ❌ No | ✅ Yes | | Web Search | Optional, defaults to `false` | Optional, defaults to `false` | | Image Search | Optional, defaults to `false` | Optional, defaults to `false` | ### Supported Aspect Ratios Both models support 14 aspect ratios: - `16:9`, `9:16`, `1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `5:4`, `4:5`, `21:9`, `1:4`, `4:1`, `1:8`, `8:1` Provide the ratio as separate numeric `width` and `height` values; for example, `width: 16` and `height: 9` select `16:9`. These values describe a ratio, not output pixel dimensions. ## Nano Banana 2.1 (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-2.1"` | | `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: `16:9`, `9:16`, `1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `5:4`, `4:5`, `21:9`, `1:4`, `4:1`, `1:8`, `8:1`. #### Optional | Parameter | Type | Description | |-----------|------|-------------| | `enable_web_search` | boolean | Enable web search with `true`; defaults to `false` when omitted | | `enable_image_search` | boolean | Enable image search with `true`; defaults to `false` when omitted | ### 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-2.1', prompt: 'A serene mountain landscape at sunset', width: 16, height: 9, resolution: '2k', enable_web_search: true, enable_image_search: false }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Nano Banana 2.1 Edit (Image Editing) ### Endpoint ``` POST /api/v1/image/task ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"nano-banana-2.1-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[] | Array of input image URLs (1-14 items) | **Note:** The `width:height` ratio must be one of the 14 supported ratios listed above. #### Optional | Parameter | Type | Description | |-----------|------|-------------| | `enable_web_search` | boolean | Enable web search with `true`; defaults to `false` when omitted | | `enable_image_search` | boolean | Enable image search with `true`; defaults to `false` when omitted | ### Single Image Edit Example ```javascript { model_name: 'nano-banana-2.1-edit', prompt: 'Change the sky to sunset colors', width: 16, height: 9, resolution: '2k', image_url_list: ['https://example.com/image.jpg'], enable_web_search: false, enable_image_search: true } ``` ### Multi-Image Composition Example ```javascript { model_name: 'nano-banana-2.1-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'], enable_web_search: false, enable_image_search: false } ``` **Billing Note:** Reference images are charged per image from the first. Each enabled search option adds a separate fixed charge per generation, regardless of image count. See current pricing for rates. ## Response Format ### Initial Response ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_status": "submitted" } } ``` ### Polling Response ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_status": "processing", "task_status_msg": null, "task_result": null } } ``` ### Successful Response ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_status": "succeed", "task_status_msg": null, "task_result": { "credit": 0.074, "images": [ { "url": "https://example.com/generated-image.png" } ] } } } ``` ### Status Values - `submitted`: Task accepted - `processing`: Task is running - `succeed`: Task completed successfully - `failed`: Task failed ## Best Practices ### Text-to-Image Tips 1. **Describe the Image:** Include subject, lighting, and composition in the prompt. 2. **Choose a Resolution:** Pass `1k`, `2k`, or `4k` in every request. 3. **Select an Aspect Ratio:** Pass the matching `width` and `height` values for one of the 14 supported ratios. 4. **Choose Search Options:** Omit either search flag for its default `false` value; set it to `true` when needed. ### Image Editing Tips 1. **Provide Reference Images:** Include one to 14 accessible image URLs in `image_url_list`. 2. **Describe the Edit:** State what should change or be preserved in the prompt. 3. **Select Output Settings:** Supply the required `resolution`, `width`, and `height` values. 4. **Choose Search Options:** Web search and image search can be enabled independently.