Nano Banana 2.1
Learn how to build and deploy AI applications with iCreat.
Nano Banana 2.1
Nano Banana 2.1 (Gemini Nano Banana 2.1) is a high-fidelity multimodal AI image generation and editing model developed by Google. Featuring robust subject and character consistency preservation, fine-grained instruction following, natural language understanding, and multi-reference image guidance, it enables high-quality visual content creation and local/global editing while maintaining ultra-fast generation speeds.
Base URL
https://api.icreat.ai
Authentication
All API requests require authentication using an API Key. You can obtain your API Key from the console.
export ICREAT_API_KEY="your-api-key-here"
HTTP Request Headers
import os
API_KEY = os.environ.get("ICREAT_API_KEY")
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer " + API_KEY,
}
Keep Your API Key Secure Never expose your API Key in client-side code or public code repositories. Store and use your API Key via environment variables or a backend proxy.
Code Examples
Image generation and editing follow a two-step asynchronous workflow: first submit a task to obtain a task_id, then poll the Task Result Query endpoint to check the task status. The response includes status and result. While the task is processing, result remains []; when the task status becomes SUCCEEDED, result contains the generated assets, and the response includes costUSD.
The examples below use the same task_id across the submission and polling steps.
1. Submit Task
Send an image generation or editing request to the task submission endpoint.
2. Query Task Result (Polling)
Query the task status using the task_id returned by the submission endpoint. Repeat query requests until the task reaches a terminal state.
The response includes status and result. While the task is processing, result remains []; when the status becomes SUCCEEDED, result contains the generated assets, and costUSD is included. A status of FAILED indicates that execution failed.
Input Parameters
Submit Task — Input
Total Parameters: 4, Required: 4, Optional: 0
The text prompt describing the image to be generated or the editing operation to perform, supporting multiline text.
A list of reference image URLs used for image generation or editing, supporting up to 4 reference images per request.
Each item must be a publicly accessible image URL (maximum 20 MB per file).
Resolution tier, currently supporting 1K and 2K,4K.
The aspect ratio of the output image. Supported values: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9.
Defaults to the aspect ratio of the first uploaded image.
Query Task Result — Input
Total Parameters: 1, Required: 1, Optional: 0
The task ID returned by the task submission endpoint.
Output Parameters
Submit Task — Output
Total Parameters: 1
The asynchronous task identifier.
Query Task Result — Output
Total Parameters: Variable
The current task status. Before the task succeeds, result is typically []. When the status is SUCCEEDED, result contains the generated assets and costUSD is included in the response.
The list of generated assets. This field is an empty array while the task is processing or if it fails; upon task success, it contains the generated image assets.
The amount consumed by the task in USD. This field is only returned when status is SUCCEEDED.
LLM Prompt
You can copy the Markdown below into AI assistants such as Cursor or ChatGPT to help them understand the model's API, invocation workflow, and parameters. Use the Copy to AI button or copy directly from the code block below.
# google/gemini-nano-banana-2-1
> Nano Banana 2.1 (Gemini Nano Banana 2.1) is a high-fidelity multimodal AI image generation and editing model developed by Google. Featuring superior subject consistency preservation, fine-grained instruction following, and multi-reference image guidance, it enables the rapid creation and editing of high-quality visual content.
## Overview
Uses the iCreat two-step asynchronous task API: first submit the image generation or editing task, then poll the task result query endpoint. Once the task succeeds, retrieve the generated image assets from `result`. Successful responses also include `costUSD`.
## API Information
- **Base URL**: `https://api.icreat.ai`
- **Submission Endpoint (POST)**: `/v1/task/submit/google/gemini-nano-banana-2-1`
- **Result Query Endpoint (POST)**: `/v1/task/result`
- **Model ID**: `google/gemini-nano-banana-2-1`
- **Authentication**: `Authorization: Bearer ${ICREAT_API_KEY}`
## Invocation Workflow
1. **Submit Task**: Send a POST request to `/v1/task/submit/google/gemini-nano-banana-2-1`. The request body includes `prompt`, `image`, `image_size`, and `aspect_ratio`. The response format is `{ "task_id": "..." }`.
2. **Query Result**: Send a POST request to `/v1/task/result` with the body `{ "task_id": "..." }`.
3. **Poll Status**: While `status` is `SUBMITTED` and `result` is `[]`, continue polling the task result.
4. **Read Result**: When `status` is `SUCCEEDED`, read `url` or `download_url` from the resource of type `Image` inside `result`.
5. **Handle Failure**: `FAILED` is a terminal state indicating task execution failure.
### Input Example
```json
{
"prompt": "Sample multiline\ntext prompt",
"image": [
"[https://example.com/example.png](https://example.com/example.png)"
],
"image_size": "1K",
"aspect_ratio": "1:1"
}
Input Notes
- The request body uses top-level flat fields.
- Required fields:
prompt,image,image_size, andaspect_ratio. prompt: Text prompt describing the image to generate or the edit operation to execute, supporting multiline text.image: An array of publicly accessible reference image URLs, supporting up to 4 images.image_size: Resolution tier, supporting1Kand2K.aspect_ratio: Output image aspect ratio. Supported values include1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9, and21:9. Defaults to the aspect ratio of the first uploaded image.
Output Notes
- While the task is processing,
statusis typicallySUBMITTEDandresultis[]. - Once the task succeeds,
statusbecomesSUCCEEDED. - The success response includes
resultandcostUSD. - The format of
resultis:[{ "type": "Image", "url": "...", "download_url": "..." }]. FAILEDis a terminal state indicating task execution failure.
Important Notes
- Each polling request must use the same
task_id. - Continue polling as long as the task is still processing and
resultis empty. - Access the generated image via
url, or download it usingdownload_url. - If the task returns
FAILED, verify the prompt, image URLs, image format, aspect ratio, and other request parameters. - Keep your API Key secure on the server side; never expose it in client-side code.
