Author's Note: Deep dive into Nano Banana Pro's aspect_ratio and resolution parameter combinations, master 10 aspect ratios and 3 resolution combinations, easily generate 4K HD images
When generating high-quality images, the choice of aspect ratio and resolution directly determines the final output effect. Nano Banana Pro provides flexible combinations of 10 aspect ratios and 3 resolutions, but many developers are unclear about how to correctly configure these two parameters.
This article will help you thoroughly master 4K HD image generation techniques from three dimensions: parameter details, combination strategies, and application scenarios.
Core Value: Through this article, you will learn how to choose the most suitable aspect ratio and resolution combination based on actual needs, master the complete technical stack for 4K image generation, and avoid common configuration errors.

Nano Banana Pro 4K Generation Core Parameters
In Nano Banana Pro (gemini-3-pro-image-preview), the quality and format of image generation are controlled by two core parameters:
- aspect_ratio: Controls the aspect ratio of the image
- resolution: Controls the resolution level of the image
The combined use of these two parameters determines the actual pixel size and display effect of the final output image.
📐 aspect_ratio Parameter Details
Nano Banana Pro supports 10 standard aspect ratios:
| Aspect Ratio | Type | Applicable Scenarios | Typical Applications |
|---|---|---|---|
| 1:1 | Square | Social Media, Avatars | Instagram Posts, Personal Avatars |
| 4:3 | Traditional Landscape | Presentations, Web Pages | PPT Covers, Blog Images |
| 3:4 | Traditional Portrait | Mobile Screens, Posters | Mobile Wallpapers, Vertical Posters |
| 16:9 | Widescreen Landscape | Video Covers, Banners | YouTube Covers, Website Banners |
| 9:16 | Widescreen Portrait | Short Videos, Stories | TikTok Video、Instagram Stories |
| 3:2 | Photography Landscape | Professional Photography, Printing | Photo Printing, Photography Works |
| 2:3 | Photography Portrait | Portrait Photography, Magazines | Portrait Photos, Magazine Covers |
| 5:4 | Near-square Landscape | Design Works, Albums | Art Works, Album Layout |
| 4:5 | Near-square Portrait | Social Media, Cards | Facebook Images, Greeting Cards |
| 21:9 | Ultra-wide | Cinematic Banners, Panoramas | Movie Posters, Panoramic Images |
🎯 Selection Recommendation: Aspect ratio selection should prioritize the final display scenario. If your image needs to be displayed on Instagram, use 1:1 or 4:5; if for YouTube covers, use 16:9; if for mobile wallpapers, use 9:16. Choosing the right aspect ratio can avoid content loss caused by post-cropping.
📊 resolution Parameter Details
Nano Banana Pro supports 3 resolution levels:
| Resolution | Pixel Level | Generation Speed | File Size | Recommended Scenarios |
|---|---|---|---|---|
| 1K | ~1024px Short Side | Fast (~12-15 seconds) | Small | Social Media, Test Preview |
| 2K | ~2048px Short Side | Medium (~15-18 seconds) | Web Display, High-Quality Content | |
| 4K | ~4096px Short Side | Slow (~20-25 seconds) | Large | Print Design, Professional Output |
⚠️ Important Note:
- Resolution parameter must be uppercase (
"1K","2K","4K") - Lowercase parameters (
"1k","2k","4k") will be rejected and return an error - Default resolution is
1K
💡 Performance Tip: Higher resolution means longer generation time, but also higher image quality. It is recommended to use 1K or 2K for quick verification during development and testing, and then use 4K to generate the final product after confirmation. We recommend testing through the APIYI apiyi.com platform, which offers unified pricing for all resolutions, so you don't need to worry about additional costs from high resolution.

Combination Relationship of aspect_ratio and resolution
The combination of aspect_ratio and resolution parameters determines the actual pixel size of the final output image.
🧮 Pixel Calculation Logic
Core Principle:
- Short side pixels = Resolution base
- Long side pixels = Short side × Aspect ratio
Calculation Examples:
Example 1: 16:9 + 4K
Short side = 4096px (4K base)
Long side = 4096 × (16/9) = 7282px
Actual output ≈ 7282 × 4096
Example 2: 1:1 + 2K
Short side = 2048px (2K base)
Long side = 2048 × (1/1) = 2048px
Actual output = 2048 × 2048
Example 3: 9:16 + 4K
Short side = 4096px (4K base)
Long side = 4096 × (16/9) = 7282px
Actual output = 4096 × 7282 (Portrait)
📐 Common Combination Actual Size Table
| Aspect Ratio | 1K Actual Size | 2K Actual Size | 4K Actual Size | Applicable Scenarios |
|---|---|---|---|---|
| 1:1 | 1024×1024 | 2048×2048 | 4096×4096 | Instagram Post |
| 16:9 | 1820×1024 | 3640×2048 | 7282×4096 | YouTube Cover |
| 9:16 | 1024×1820 | 2048×3640 | 4096×7282 | TikTok Video |
| 4:3 | 1365×1024 | 2731×2048 | 5461×4096 | Presentations |
| 3:2 | 1536×1024 | 3072×2048 | 6144×4096 | Photo Printing |
| 21:9 | 2389×1024 | 4779×2048 | 9557×4096 | Movie Posters |
📊 Size Note: The above sizes are theoretical calculated values, actual output may vary slightly. It is recommended to generate test images first in actual projects, confirm the output size meets expectations, and then batch generate.
4K HD Image Generation Practice
After mastering the parameter principles, let's see how to generate 4K HD images in actual code.
💻 Method 1: Google Native API Format
import google.generativeai as genai
from google.generativeai import types
# # Configure API Key
genai.configure(api_key="YOUR_API_KEY")
# # Solution 1: Generate 4K 16:9 landscape image
response = genai.GenerativeModel("gemini-3-pro-image-preview").generate_content(
"Generate a tech-style AI summit poster with text '2025 AI Innovation Summit', blue gradient background",
generation_config=types.GenerationConfig(
response_modalities=['IMAGE'],
image_config=types.ImageConfig(
aspect_ratio="16:9", # YouTube cover aspect ratio
image_size="4K" # # 4K HD
)
)
)
# # Extract image
image = response.candidates[0].content.parts[0].inline_data.data
with open("4k_16_9.png", "wb") as f:
f.write(image)
print("4K 16:9 image generated!")
🚀 Method 2: OpenAI Compatible Format (Recommended)
Using OpenAI compatible format through APIYI platform is more concise:
import openai
# Configure client
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://vip.apiyi.com/v1"
)
# # Generate 4K 9:16 portrait image
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[
{
"role": "user",
"content": """Generate a mobile wallpaper, 9:16 portrait, 4K resolution
Theme: Dreamy starry sky
Style: Deep blue-purple gradient, scattered stars
Requirements: Suitable for OLED screens, clean without text"""
}
],
extra_body={
"aspect_ratio": "9:16", # Portrait mobile
"resolution": "4K" # # 4K HD
}
)
# # Extract image URL
image_url = response.choices[0].message.content
print(f"4K portrait wallpaper: {image_url}")
🎯 Recommendation: For domestic developers, we strongly recommend using OpenAI compatible format through the APIYI apiyi.com platform. This approach not only makes the code more concise, but also eliminates the need to handle complex authentication processes, supports domestic payment methods, and you can start using it in 5 minutes.
🎨 Method 3: Batch Generate Different Sizes
import openai
import time
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://vip.apiyi.com/v1"
)
# # Define size combinations to generate
configs = [
{"ratio": "1:1", "res": "4K", "name": "instagram_post"},
{"ratio": "16:9", "res": "4K", "name": "youtube_cover"},
{"ratio": "9:16", "res": "4K", "name": "tiktok_video"},
{"ratio": "4:5", "res": "2K", "name": "facebook_image"},
]
prompt = "Generate a Spring Festival themed holiday poster with text 'Happy New Year', Chinese red with gold"
for config in configs:
print(f"Generating {config['name']} ({config['ratio']} @ {config['res']})...")
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[{"role": "user", "content": prompt}],
extra_body={
"aspect_ratio": config["ratio"],
"resolution": config["res"]
}
)
image_url = response.choices[0].message.content
print(f"✓ {config['name']}: {image_url}")
time.sleep(1) # Avoid requests too fast
print("Batch generation complete!")

Application Scenario Best Practices
Different application scenarios should choose different parameter combinations. The following are best practices summarized from practical experience:
📱 Social Media Scenarios
| Platform | Recommended Aspect Ratio | Recommended Resolution | Actual Size | Notes |
|---|---|---|---|---|
| Instagram Posts | 1:1 or 4:5 | 2K | 2048×2048 or 2048×2560 | 1:1 is more versatile |
| Instagram Stories | 9:16 | 2K | 2048×3640 | Full-screen portrait |
| YouTube Covers | 16:9 | 4K | 7282×4096 | HD landscape |
| TikTok | 9:16 | 4K | 4096×7282 | Portrait video |
| Twitter Cards | 16:9 | 2K | 3640×2048 | Landscape card |
| Facebook Posts | 4:5 | 2K | 2048×2560 | Portrait preferred |
Code Example:
# Instagram Post
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[{"role": "user", "content": "Generate Instagram food photo"}],
extra_body={"aspect_ratio": "1:1", "resolution": "2K"}
)
🎨 Professional Design Scenarios
| Purpose | Recommended Aspect Ratio | Recommended Resolution | Actual Size | Notes |
|---|---|---|---|---|
| Print Posters | 3:2 or 4:3 | 4K | 6144×4096 | Suitable for printing |
| Website Banners | 21:9 | 4K | 9557×4096 | Ultra-wide |
| PPT Covers | 16:9 | 2K | 3640×2048 | Presentations |
| Product Detail Pages | 1:1 | 4K | 4096×4096 | E-commerce scenarios |
| Mobile Wallpapers | 9:16 | 4K | 4096×7282 | HD portrait |
| Desktop Wallpapers | 16:9 | 4K | 7282×4096 | HD landscape |
Code Example:
# Print Poster
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[{"role": "user", "content": "Generate corporate promotional poster, 4K HD suitable for printing"}],
extra_body={"aspect_ratio": "3:2", "resolution": "4K"}
)
🖼️ Content Creation Scenarios
| Content Type | Recommended Aspect Ratio | Recommended Resolution | Notes |
|---|---|---|---|
| Blog Images | 16:9 or 4:3 | 2K | Landscape reading experience |
| WeChat Official Accounts | 16:9 | 2K | Adapt to mobile screens |
| E-book Covers | 3:4 | 4K | Portrait book cover |
| Infographics | 9:16 or 16:9 | 4K | Contains text content |
| Brand Logos | 1:1 | 4K | Square HD |
🛠️ Scenario Selection Recommendation: If unsure about the final use, it is recommended to prioritize generating 4K resolution 1:1 or 16:9 images. These two combinations are the most versatile and can be easily cropped to other ratios. You can quickly test the effects of different combinations through the APIYI apiyi.com platform to find the parameter configuration most suitable for your project.

Parameter Configuration Best Practices
After mastering the basic usage, here are some advanced tips and best practices:
✅ Correct Practices
1. Parameter Uppercase Specification
# ✅ Correct
extra_body={"aspect_ratio": "16:9", "resolution": "4K"}
# ❌ Error - lowercase k will cause error
extra_body={"aspect_ratio": "16:9", "resolution": "4k"}
2. select resolution Based on Scenario
# Social media - use 2K
extra_body={"aspect_ratio": "1:1", "resolution": "2K"}
# Print design - use 4K
extra_body={"aspect_ratio": "3:2", "resolution": "4K"}
# Quick preview - use 1K
extra_body={"aspect_ratio": "16:9", "resolution": "1K"}
3. Clearly Specify Aspect Ratio Requirements in Prompts
# Also specify aspect ratio in prompts to help model understand better
content = """Generate a 16:9 landscape poster
Theme: AI Technology Summit
Layout: Landscape composition, title on left, visual elements on right
"""
extra_body={"aspect_ratio": "16:9", "resolution": "4K"}
❌ Common Errors
Error 1: Using Lowercase Resolution
# ❌ # This will cause API error
extra_body={"aspect_ratio": "16:9", "resolution": "4k"}
# Error message: Invalid resolution parameter
Error 2: Aspect Ratio Reversed
# ❌ # Want portrait but wrote landscape
extra_body={"aspect_ratio": "16:9", "resolution": "4K"} # # This is landscape!
# ✅ # Should use
extra_body={"aspect_ratio": "9:16", "resolution": "4K"} # # This is portrait
Error 3: Prompt and Parameters Mismatch
# ❌ # Prompt says portrait, but parameters are landscape
content = "Generate a portrait mobile wallpaper"
extra_body={"aspect_ratio": "16:9", "resolution": "4K"} # # Contradiction!
# ✅ # Should match
content = "Generate a portrait mobile wallpaper"
extra_body={"aspect_ratio": "9:16", "resolution": "4K"}
🎯 Performance Optimization Recommendations
1. Use Low Resolution in Development Stage
# Use 1K for quick verification during development and testing
if DEBUG_MODE:
resolution = "1K"
else:
resolution = "4K"
extra_body={"aspect_ratio": "16:9", "resolution": resolution}
2. Control Frequency for Batch Generation
import time
for prompt in prompts:
generate_image(prompt)
time.sleep(2) # Avoid requests too fast, give server buffer time
3. Cache Generated Images
import hashlib
import json
def generate_with_cache(prompt, config):
# # Generate cache key
cache_key = hashlib.md5(
(prompt + json.dumps(config)).encode()
).hexdigest()
# # Check cache
if cache_key in image_cache:
return image_cache[cache_key]
# generated image
image_url = generate_image(prompt, config)
image_cache[cache_key] = image_url
return image_url
💡 Optimization Recommendation: In actual projects, it is recommended to combine caching, batch processing, and dynamic resolution selection to optimize performance and cost. The APIYI apiyi.com platform provides unified pricing, so you don't need to worry about additional costs from 4K resolution, and you can confidently use high resolution for development and production.
Frequently Asked Questions

Q1: Why did I set 4K, but the output image is still small?
This problem usually has the following reasons:
Reason 1: Parameter Used Lowercase
# ❌ Lowercase k is invalid, system will use default 1K
extra_body={"resolution": "4k"}
# ✅ Must use uppercase K
extra_body={"resolution": "4K"}
Reason 2: Parameter Position Error
# ❌ # Parameters placed in wrong position
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[{"role": "user", "content": "generated image"}],
resolution="4K" # Wrong position!
)
# ✅ Should be placed in extra_body
response = client.chat.completions.create(
model="gemini-3-pro-image-preview",
messages=[{"role": "user", "content": "generated image"}],
extra_body={"resolution": "4K"} # Correct position
)
Reason 3: Platform Limitations
Some proxy platforms may limit the maximum resolution.
Solution:
Use the APIYI apiyi.com platform, which fully supports 4K resolution output with no limitations. The platform provides detailed debugging tools to view actual request parameters and returned image sizes, helping to quickly locate issues.
Q2: Which is more important, aspect_ratio or resolution?
Both are equally important, but serve different purposes:
aspect_ratio (Aspect Ratio):
-
- Determines the shape of the image
-
- Affects the layout of content
-
- Determines which platforms it adapts to
resolution (Resolution):
-
- Determines the clarity of the image
- Affects the size of the file
-
- Determines whether it can be used for printing
Priority Recommendation:
- Determine purpose first → Select aspect_ratio
- Then determine quality requirements → Select resolution
Example:
# Scenario: YouTube video cover
# 1. Purpose determines aspect ratio: YouTube = 16:9
# 2. Quality determines resolution: Cover needs clarity = 4K
extra_body={
"aspect_ratio": "16:9", # # Determine shape first
"resolution": "4K" # then determine quality
}
Recommended Strategy: If unsure how to choose, you can quickly generate sample images of different combinations in the APIYI apiyi.com platform's parameter testing tool, compare the effects intuitively, and then make a decision.
Q3: How long does it take to generate a 4K image?
Generation time depends on multiple factors:
Main Influencing Factors:
-
Resolution Level
- 1K: ~12-15 seconds
- 2K: ~15-18 seconds
- 4K: ~20-25 seconds
-
Prompt Complexity
-
- Simple prompts: shorter time
-
- Complex scene descriptions: longer time
-
- Including text rendering: slightly longer
-
-
Server Load
- Peak hours may be slightly slower
- Off-peak hours are usually faster
Actual Test Data (Based on APIYI Platform):
Test conditions: 16:9 landscape, 50-character prompt
1K: Average 13 seconds
2K: Average 16 seconds
4K: Average 22 seconds
Optimization Recommendations:
- Development Stage: Use 1K for quick iteration
- Confirm Effect: Use 2K to verify quality
- Final Output: Use 4K to generate final product
Professional Recommendation: When batch generating, it is recommended to schedule through the APIYI apiyi.com platform's batch task functionality. The platform provides intelligent queue management and concurrency control, which can significantly improve batch generation efficiency and automatically handle failure retries.
Q4: Can I generate multiple images of different sizes simultaneously?
Nano Banana Pro can only generate one size per call, but can be achieved through batch calls:
Solution 1: Serial Generation
sizes = [
{"ratio": "1:1", "res": "4K"},
{"ratio": "16:9", "res": "4K"},
{"ratio": "9:16", "res": "4K"}
]
results = []
for size in sizes:
response = generate_image(prompt, size)
results.append(response)
Solution 2: Parallel Generation (Recommended)
import asyncio
import aiohttp
async def generate_async(prompt, config):
async with aiohttp.ClientSession() as session:
# # Asynchronously call API
response = await call_api(session, prompt, config)
return response
async def batch_generate(prompt, configs):
tasks = [generate_async(prompt, cfg) for cfg in configs]
results = await asyncio.gather(*tasks)
return results
# Use
configs = [
{"aspect_ratio": "1:1", "resolution": "4K"},
{"aspect_ratio": "16:9", "resolution": "4K"},
{"aspect_ratio": "9:16", "resolution": "4K"}
]
results = asyncio.run(batch_generate(prompt, configs))
Cost Comparison:
- Generate 3 different sizes = 3 API calls
- Official cost: $0.24 × 3 = $0.72
- APIYI cost: $0.05 × 3 = $0.15
- Savings: 79%
Batch Recommendation: For scenarios requiring multi-size image generation, it is recommended to use the APIYI apiyi.com platform's batch interface. The platform provides batch task management, progress tracking, and failure retry functionality, which can greatly simplify the complexity of batch generation.
Q5: How to verify if the generated image is really 4K?
Method 1: Use Python to Check Image Size
from PIL import Image
import requests
from io import BytesIO
# # Download image
response = requests.get(image_url)
img = Image.open(BytesIO(response.content))
# # Check size
width, height = img.size
print(f"Image size: {width} × {height}")
# # Verify if it meets expectations
if height >= 4096 or width >= 4096:
print("✓ Confirmed as 4K resolution")
else:
print("⚠ Not reaching 4K resolution")
Method 2: Use Image Metadata Viewer
- macOS: – macOS: Preview App → Tools → Show Inspector
- Windows: – Windows: Right-click → Properties → Details
- Online Tools: image-size-checker and other websites
Method 3: Use APIYI Platform's Image Information Tool
The APIYI platform provides an image size verification tool that can automatically check the actual size of generated images and compare it with the requested parameters to ensure the output meets expectations.
Common Size References:
- 4K + 16:9 ≈ 7282 × 4096
- 4K + 1:1 = 4096 × 4096
- 4K + 9:16 ≈ 4096 × 7282
Professional Recommendation: It is recommended to generate a few sample images in the early stages of the project, verify the size using the above methods, and then proceed with batch generation. This can avoid resource waste caused by parameter configuration errors discovered after batch generation.
📚 Further Reading
🔗 Related Resources
| Resource Type | Recommended Content | Access Method |
|---|---|---|
| Official Documentation | Gemini API Image Generation Parameter Guide | https://ai.google.dev/gemini-api/docs/image-generation |
| Platform Documentation | APIYI Nano Banana Pro Complete Tutorial | https://help.apiyi.com |
| Parameter Quick Reference | Aspect Ratio and Resolution Quick Reference Table | Table section of this article |
| Code Examples | GitHub Open Source Example Library | Search "Gemini image generation" |
📖 Learning Recommendation: To better master 4K image generation techniques, it is recommended to practice with actual projects. You can visit APIYI apiyi.com to get test credits and deepen your understanding through actual generation. The platform provides parameter configuration assistants and real-time preview features to help you quickly find the best parameter combinations.
💡 Advanced Tips
Tip 1: Dynamic Parameter Selection
def choose_params(use_case):
"""Automatically select best parameters based on use case"""
params_map = {
"instagram": {"aspect_ratio": "1:1", "resolution": "2K"},
"youtube": {"aspect_ratio": "16:9", "resolution": "4K"},
"tiktok": {"aspect_ratio": "9:16", "resolution": "4K"},
"print": {"aspect_ratio": "3:2", "resolution": "4K"},
"wallpaper": {"aspect_ratio": "16:9", "resolution": "4K"},
}
return params_map.get(use_case, {"aspect_ratio": "1:1", "resolution": "2K"})
# Use
params = choose_params("youtube")
generate_image(prompt, params)
Tip 2: Prompt Templating
def build_prompt(content, aspect_ratio):
"""Adjust prompts based on aspect ratio"""
layout_map = {
"16:9": "Landscape composition, widescreen layout",
"9:16": "Portrait composition, mobile screen layout",
"1:1": "Square composition, centered symmetrical layout",
"21:9": "Ultra-wide composition, cinematic frame"
}
layout_hint = layout_map.get(aspect_ratio, "")
return f"{content}\nLayout requirements: {layout_hint}"
# Use
prompt = build_prompt("Generate Spring Festival poster", "16:9")
Tip 3: Batch Size Conversion
def generate_multi_sizes(prompt, base_config):
"""One-click generation of multiple social media sizes"""
platforms = {
"instagram_post": {"aspect_ratio": "1:1", "resolution": "2K"},
"instagram_story": {"aspect_ratio": "9:16", "resolution": "2K"},
"youtube_cover": {"aspect_ratio": "16:9", "resolution": "4K"},
"twitter_card": {"aspect_ratio": "16:9", "resolution": "2K"},
"facebook_post": {"aspect_ratio": "4:5", "resolution": "2K"},
}
results = {}
for platform, config in platforms.items():
image_url = generate_image(prompt, config)
results[platform] = image_url
return results
In-depth Learning Recommendation: Continue to pay attention to the latest developments in AI image generation technology. We recommend regularly visiting the APIYI help.apiyi.com technical blog to learn about the latest parameter optimization techniques, application cases, and best practices, maintaining a technological leading advantage.
🎯 Summary
Nano Banana Pro's 4K HD image generation is centered on the correct combination of aspect_ratio and resolution parameters.
Key Review:
- 10 Aspect Ratios: From 1:1 to 21:9, covering all mainstream application scenarios
- 3 Resolution Levels: 1K/2K/4K, must use uppercase K
- Parameter Combination: Short side based on resolution, long side calculated from aspect ratio
- Scenario Priority: Determine purpose first to select aspect ratio, then determine quality to select resolution
- Performance Optimization: Use 1K for development, 2K for testing, 4K for production
In actual applications, it is recommended:
- Select aspect ratio based on final display scenario
- Use lower resolution in development stage for quick verification
- Clearly specify layout requirements in prompts
- Make good use of concurrency and caching when batch generating
- Verify the actual size of output images
Final Recommendation: For projects that need to frequently generate 4K HD images, we strongly recommend developing and producing through the APIYI apiyi.com platform. The platform not only provides unified preferential pricing (all resolutions $0.050/image), but also provides professional tools such as parameter configuration assistants, batch task management, and image size verification, which can significantly improve development efficiency and lower the usage threshold.
📝 Author Bio: Senior AI image generation developer, focused on HD image generation and parameter optimization. Regularly shares image generation technology practical experience. More technical materials and parameter configuration cases can be accessed at APIYI apiyi.com technical community.
🔔 Technical Exchange: Welcome to discuss Nano Banana Pro's parameter configuration and usage experience in the comments section, and continue to share 4K image generation techniques and best practices. For in-depth technical support, you can contact our technical team through APIYI apiyi.com.
