Endpoint
Authentication
Bearer token authentication
Request Headers
Must be
application/jsonRequest Body
Image model identifier:
gemini-3-pro-image- Standard image generationgemini-3.1-flash-image- Fast image generationgemini-3-pro-image-16-9-4k- With aspect ratio and quality suffix
Text description of the image to generate
Be descriptive! Include style, mood, composition, and details for best results.
Image size in
WIDTHxHEIGHT format or aspect ratio:- Exact dimensions:
1920x1080,1024x1024,1280x720 - Aspect ratios:
16:9,9:16,4:3,3:4,21:9,1:1
1024x1024 (1:1 aspect ratio)Image quality level:
hd- 4K resolution (highest quality)medium- 2K resolutionstandard- Default resolution (1K)
standardDirect Gemini native resolution parameter (takes precedence over
quality):4K- 4096px maximum dimension2K- 2048px maximum dimension1K- 1024px maximum dimension
Number of images to generate (1-10)Default:
1Response format:
b64_json- Base64-encoded JSON (recommended)url- Data URI format
urlPerson generation policy:
allow- Allow person generationdeny- Block person generation
allowResponse Format
Unix timestamp of generation
Array of generated images
Example: Basic Generation
Example: Python SDK
Example: Multiple Sizes
Example: Native imageSize Parameter
Alternative: Chat API Format
You can also generate images via the Chat Completions endpoint:Alternative: Claude Messages API Format
Model Suffix Format
You can specify aspect ratio and quality directly in the model name:- Aspect ratio:
-16-9,-9-16,-4-3,-3-4,-21-9,-1-1 - Quality:
-4k,-2k(no suffix = standard)
gemini-3-pro-image-16-9-4k→ 16:9 + 4Kgemini-3-pro-image-1-1-2k→ Square + 2Kgemini-3-pro-image-21-9→ Ultrawide + Standard
Supported Sizes
Exact Dimensions
| Size | Aspect Ratio | Use Case |
|---|---|---|
1024x1024 | 1:1 | Square, social media |
1920x1080 | 16:9 | Widescreen, desktop |
1080x1920 | 9:16 | Mobile, stories |
1280x720 | 16:9 | HD video thumbnail |
2560x1440 | 16:9 | 2K desktop wallpaper |
3840x2160 | 16:9 | 4K wallpaper |
Aspect Ratios
| Ratio | Description | Common Use |
|---|---|---|
1:1 | Square | Instagram posts |
16:9 | Widescreen | YouTube thumbnails |
9:16 | Portrait | TikTok, Reels |
4:3 | Classic | Presentations |
3:4 | Portrait | |
21:9 | Ultrawide | Cinema, banners |
Quality Levels
| Quality | Native Size | Max Dimension | Token Cost |
|---|---|---|---|
standard | 1K | 1024px | Low |
medium | 2K | 2048px | Medium |
hd | 4K | 4096px | High |
Parameter Priority
When multiple size/quality parameters are provided:- Highest priority:
imageSizeparameter (4K,2K,1K) - Medium priority:
qualityparameter (hd,medium,standard) - Lowest priority: Model suffix (
-4k,-2k)
Prompt Engineering Tips
Be Specific
❌ Bad: “A city” ✅ Good: “A futuristic cyberpunk city at night with neon signs, rain-slicked streets, and flying vehicles”Include Style
- Art style: “digital art”, “oil painting”, “watercolor”, “3D render”
- Artist reference: “in the style of Studio Ghibli”, “Greg Rutkowski style”
- Mood: “moody”, “vibrant”, “minimalist”, “dramatic lighting”
Structure
Good prompt structure:- Subject: What to generate
- Style: Artistic style/medium
- Details: Colors, composition, lighting
- Quality: “highly detailed”, “8k”, “photorealistic”
Error Handling
Quota Management
Image generation consumes quota from the configured account. Antigravity Manager:- Automatically refreshes quota after successful generation
- Rotates accounts when quota is exhausted
- Displays real-time quota in the dashboard
Features
- Flexible Sizing: Supports both exact dimensions and aspect ratios
- Quality Control: Three quality levels (1K/2K/4K)
- Multi-format: Base64 JSON or Data URI output
- Batch Generation: Generate up to 10 images per request
- Auto Quota Refresh: Real-time quota updates
- Multiple Protocols: Works with OpenAI, Claude, and Chat APIs
- Smart Defaults: Sensible defaults for quick testing
Limitations
- Maximum 10 images per request (
nparameter) - Custom sizes auto-mapped to supported aspect ratios
- Person generation controlled by safety settings
- Quota varies by account tier (Pro/Ultra/Free)