Skip to content

Image Generation ​

Generate images from text prompts using Nano Banana 2 Lite (Gemini 3.1 Flash Lite, default), Nano Banana 2 (Gemini 3.1 Flash), Go Bananas! Pro (Gemini 3 Pro Image), OpenAI GPT Image 2, or OpenAI GPT Image 2.5 (Flare and Sunburst).

Basic Generation ​

The simplest way to generate an image:

Generate an image of a mountain landscape at sunrise

This creates a single 1024x1024 image with default settings.

Parameters ​

Prompt (Required) ​

The text description of what you want to generate.

Tips for effective prompts:

AspectExample
Subject"a red fox"
Action"running through snow"
Setting"in a winter forest"
Lighting"golden hour sunlight"
Style"oil painting style"
Mood"peaceful, serene"

Good prompt example:

A red fox running through fresh snow in a winter pine forest,
golden hour sunlight filtering through the trees, photorealistic,
detailed fur texture, breath visible in cold air

Negative Prompt (Optional) ​

What to avoid in the image:

Generate a portrait photo of a business professional
Avoid: cartoon, anime, illustration, blurry, low quality

Common negative prompt additions:

  • blurry, low quality, pixelated
  • text, watermark, signature
  • deformed, distorted
  • multiple subjects (for single-subject images)

Aspect Ratio ​

ValueDimensionsBest For
square1:1Social media, profiles
portrait3:4Character art, posters
landscape4:3Scenes, environments
16:9WidescreenDesktop wallpapers, videos
9:16VerticalMobile, stories

Default: with no aspect ratio, the image is square (1:1). The request's own aspect_ratio always wins; if you leave it out, a default saved on a scene, style preset or character you use applies (checked in that order), and only then square. Edits keep the source image's shape unless you pass aspect_ratio or a scene, style preset or character you use supplies one.

Generate a cinematic landscape in 16:9 aspect ratio

Number of Images ​

Generate 1-4 variations in a single request:

Generate 4 variations of a fantasy castle

Model Selection ​

Default Model

Nano Banana 2 Lite (gemini-flash-lite-image) is the current default — fastest, lowest-cost, and optimized for 1K generation/editing. Pass model_id to override per request, subject to your tenant's allowed-models list.

ModelProviderUse Case
gemini-flash-lite-imageGemini 3.1 Flash LiteFastest, lowest cost, 1K output (default)
gemini-flash-imageGemini 3.1 FlashStrong all-around model, 2K/4K tiers, broader ratios
gemini-pro-imageGemini 3 ProBest Gemini quality, Google Search grounding, 1K/2K/4K tiers
openai-gpt-image-2OpenAI GPT Image 2Text rendering, prompt adherence, quality tiers, JPEG/WebP output
openai-gpt-image-2.5-flareOpenAI GPT Image 2.5 FlareFast everyday generation; xhigh/max quality, transparent backgrounds
openai-gpt-image-2.5-sunburstOpenAI GPT Image 2.5 SunburstPrecise generation and editing; same controls as Flare

model_id is validated against your tenant's allowedModels allowlist. Omit it to use the tenant default (Nano Banana 2 Lite); unknown or disallowed values are rejected. See the OpenAI gpt-image-2 deep-dive and the GPT Image 2.5 page for provider-specific parameters.

Generate a detailed architectural rendering

To use the general-purpose Flash model explicitly:

Generate a quick sketch using the Flash model

OpenAI-Specific Parameters ​

When model_id is an OpenAI model (openai-gpt-image-2, openai-gpt-image-2.5-flare or openai-gpt-image-2.5-sunburst), these extra parameters are honored:

ParameterValuesPurpose
output_formatpng, jpeg, webpNative compression formats
output_compression0–100JPEG/WebP only; rejected for PNG
qualitylow, medium, high, auto (+ xhigh, max on GPT Image 2.5)Trade cost vs. detail
sizeauto or WIDTHxHEIGHTCustom GPT Image 2 size under OpenAI constraints
backgroundauto, opaque (+ transparent on GPT Image 2.5, png/webp only)Transparent is not supported by GPT Image 2
moderationauto, lowlow is less restrictive
json
{
  "prompt": "Marketing poster with the headline 'Summer Sale' in a bold serif",
  "model_id": "openai-gpt-image-2",
  "aspect_ratio": "4:5",
  "size": "auto",
  "output_format": "webp",
  "output_compression": 85,
  "quality": "high"
}

System Instruction ​

Guide the model's overall approach:

System instruction: Professional product photography style
Generate a smartwatch on a marble surface

Reference Images ​

Use existing images as style or composition guides:

Generate an image in the style of [reference image URL]

Limits (total reference images per request):

  • Gemini models (Nano Banana 2 Lite, Nano Banana 2, Go Bananas! Pro): Up to 14 reference images
  • OpenAI GPT Image 2 and 2.5: Up to 16 reference images (routed through /v1/images/edits)

Character references are capped separately: when generating with a saved character, up to 4 of its reference images are used on the standard-tier models (Nano Banana 2 Lite and Nano Banana 2) and up to 5 on the pro-tier models (Go Bananas! Pro and the OpenAI models). With several characters, each contributes up to 3, within the same total.

Reference images must be at least 512x512 pixels for reliable character consistency.

Style Presets ​

Apply saved style templates:

Generate a coffee shop scene using the "Vintage Film" style preset

Learn about style presets →

Advanced Options (Pro Model) ​

Resolution Tiers ​

TierQualitySpeed
1024StandardFastest
768MediumMedium
512LowerFast

Google Search Grounding ​

Enable real-world accuracy for specific subjects:

Generate the Eiffel Tower at sunset with Google Search grounding enabled

Thinking Mode ​

Enable step-by-step reasoning for complex compositions:

Generate a detailed steampunk cityscape with thinking mode enabled

Output ​

Each generated image returns:

json
{
  "images": [
    {
      "id": 42,
      "full_url": "https://cdn.example.com/image.png",
      "thumbnail_url": "https://cdn.example.com/image-thumb.jpg",
      "width": 1024,
      "height": 1024,
      "size_bytes": 524288,
      "format": "png"
    }
  ],
  "session_id": "sess_abc123",
  "model": "gemini-flash-image"
}

Generation Workflow ​

Image Generation Workflow

Prompt → Style preset → References → Gemini or OpenAI API → R2 storage → Metadata

Tips for Better Results ​

Be Specific ​

❌ "a cat" ✅ "a fluffy orange tabby cat lounging on a velvet cushion, soft window light"

Use Art Terminology ​

  • Photography: "shallow depth of field", "golden hour", "macro shot"
  • Painting: "impasto technique", "chiaroscuro lighting", "watercolor wash"
  • Digital: "3D render", "vector illustration", "low poly"

Iterate ​

  1. Start with a basic prompt
  2. Review the result
  3. Add details to improve
  4. Use editing for refinements

Combine Techniques ​

Generate a portrait in the style of [reference image],
with dramatic Rembrandt lighting, shallow depth of field,
using the "Cinematic" style preset

Combined Character & Product Generation ​

Generate images with multiple characters AND products in a single request for marketing and branding content.

Multi-Character Scenes ​

Generate scenes with up to 5 saved characters:

Generate an image of characters 19 and 20 having a team meeting in a modern office

The system automatically:

  • Fetches character reference images from your library
  • Builds optimal prompts for character consistency
  • Maintains exact likeness across scenes

Character + Product Placement ​

Combine characters with product references:

Generate characters 19 and 20 at a product photoshoot with product 2

Example API call:

json
{
  "prompt": "at a professional photoshoot",
  "character_ids": [19, 20],
  "product_ids": [2],
  "aspect_ratio": "16:9"
}

Automatic Prompt Construction:

  • Characters only: "The characters from the reference images {scene}"
  • Products only: "Using the products shown, {scene}. Maintain exact design..."
  • Both: "The characters with the products shown, {scene}. Maintain exact product design..."

Limits ​

ResourceMaximum
Characters per scene5
Products per scene6
Total reference images14

WARNING

Cannot mix singular and array parameters (e.g., character_id with character_ids). Use one form consistently.

Common Use Cases ​

Product Shots ​

Professional product photography of a luxury watch on a marble
surface, soft studio lighting, reflection, minimalist background

Character Concept Art ​

Fantasy character concept art, elven ranger with silver hair,
green cloak, bow and arrows, forest background, digital painting style

Marketing Graphics ​

Modern social media banner for a tech startup, abstract geometric
shapes in blue and purple, clean minimalist design, 16:9 aspect ratio

Architectural Visualization ​

Photorealistic architectural render of a modern beach house,
floor-to-ceiling windows, infinity pool, sunset view, 4:3 landscape

Rate Limits & Quotas ​

  • Rate limit: 60 requests/minute (configurable per tenant)
  • Storage quota: Tracked per image stored
  • Tokens: Prompt length counts against model limits

Next Steps ​

Released under the MIT License.