⌘K

Google Nano Banana 2

nano_banana_2

Google Nano Banana 2 image generation via Gemini API. Supports text-to-image, image editing, and multi-image composition with advanced AI capabilities.

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Parameters

model string required

Model ID to use for the request.

Value: nano_banana_2


prompt string required

Image generation prompt, length must be between 1-2500 characters

Prompt guidelines:

  • Realistic scenes: Use photography terminology. Mention shooting angles, lens types, lighting, and details to guide the model to generate realistic effects
  • Stylized illustrations and stickers: To create stickers, icons, or assets, clearly state the style and request a transparent background
  • Accurate text in images: Gemini excels at rendering text. Clearly specify the text, font style (descriptive), and overall design
  • Product mockups and commercial photography: Ideal for creating clear professional product photos for e-commerce, advertising, or branding
  • Minimalist style and negative space design: Great for creating backgrounds for websites, presentations, or marketing materials to overlay text

image_urls array

Maximum 3 images can be accepted as input


aspect_ratio string

Image aspect ratio

Options: 1:8, 1:4, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 8:1, 4:1, 9:16, 16:9, 21:9


resolution string

Image resolution

Options: 0.5K, 1K, 2K, 4K

Default: 1K


response_modalities string

By default, the model returns both text and image responses (i.e., response_modalities=[‘Text’, ‘Image’]). You can configure the response to return only images without text using response_modalities=[‘Image’]


Polling

Since result generation takes time, you need to poll the task status after creating the task.

The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.

See the examples on the right for polling requests and responses.

Response Format

error object

Error information. Only present when status is failed.

code integer

Error code.

error_message string

Detailed error message.


output array

Generation results. Only present when status is completed.

content array

List of generated content

type string

Resource type

Options: image, text

url string

Content URL


usage object

Usage statistics. Only present when status is completed

prompt_tokens integer

Prompt tokens

completion_tokens integer

Completion tokens

total_tokens integer

Total tokens


metadata object

Metadata information


Error Codes

Error CodeDescription
005001095Internal generation error
005001096Result parsing error
005001097HTTP error response
005001098Synchronous generation error