Gemini 3.1 Flash with image generation capabilities. High-efficiency image generation model with support for text rendering, reference images, search grounding, and thinking mode. The efficient counterpart to Gemini 3 Pro Image.
gemini-3.1-flash-image API OpenAI-compatible
Connect to Nano Banana 2 via the Lumenfall OpenAI-compatible API to integrate high-speed text-to-image generation and image editing into your workflow. The unified endpoint allows for programmatic creation of visual assets and precise modifications to existing images through a single interface.
https://api.lumenfall.ai/openai/v1
gemini-3.1-flash-image-preview
Code Examples
Text to Image
/v1/images/generationscurl -X POST \
https://api.lumenfall.ai/openai/v1/images/generations \
-H "Authorization: Bearer $LUMENFALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-image-preview",
"prompt": "",
"size": "1024x1024"
}'
# Response:
# { "created": 1234567890, "data": [{ "url": "https://...", "revised_prompt": "..." }] }
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.lumenfall.ai/openai/v1'
});
const response = await client.images.generate({
model: 'gemini-3.1-flash-image-preview',
prompt: '',
size: '1024x1024'
});
// { created: 1234567890, data: [{ url: "https://...", revised_prompt: "..." }] }
console.log(response.data[0].url);
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.lumenfall.ai/openai/v1"
)
response = client.images.generate(
model="gemini-3.1-flash-image-preview",
prompt="",
size="1024x1024"
)
# { created: 1234567890, data: [{ url: "https://...", revised_prompt: "..." }] }
print(response.data[0].url)
Image Edit
/v1/images/editsParameter Reference
Core Parameters
| Parameter | Type | Description | Modes |
|---|---|---|---|
prompt
|
string | Required. Text prompt for image generation |
T2I
Edit
|
seed
|
integer | Random seed for reproducibility |
T2I
Edit
|
Size & Layout
| Parameter | Type | Description | Modes |
|---|---|---|---|
size
|
string |
Image dimensions as WxH pixels (e.g. "1024x1024") or aspect ratio (e.g. "16:9")
WxH determines both shape and scale (aspect_ratio and resolution are ignored when size is provided). W:H format is equivalent to aspect_ratio.
|
T2I
Edit
|
aspect_ratio
|
string |
Aspect ratio of the output image (e.g. "16:9", "1:1")
Controls shape independently of scale. Use with resolution to control both. If size is also provided, size takes precedence. Any ratio is accepted and mapped to the nearest supported value.
|
T2I
Edit
|
resolution
|
string |
Output resolution tier (e.g. "1K", "4K")
auto
0.5K
1K
2K
4K
Controls scale independently of shape. Higher tiers produce larger images and cost more. If size is also provided, size takes precedence for scale. Any tier is accepted and mapped to the nearest supported value.
|
T2I
Edit
|
| Output |
size
|
aspect_ratio
+
resolution
|
|
|---|---|---|---|
| Flexible | |||
| Auto | "auto" |
— | Model chooses optimal dimensions |
0.5K 14 sizes
| Output |
size
|
aspect_ratio
+
resolution
|
|
|---|---|---|---|
| 573 × 458 | "573x458" |
or |
"5:4"
+
"0.5K"
|
| 384 × 683 | "384x683" |
or |
"9:16"
+
"0.5K"
|
| 683 × 384 | "683x384" |
or |
"16:9"
+
"0.5K"
|
| 256 × 1024 | "256x1024" |
or |
"1:4"
+
"0.5K"
|
| 512 × 512 | "512x512" |
or |
"1:1"
+
"0.5K"
|
| 1024 × 256 | "1024x256" |
or |
"4:1"
+
"0.5K"
|
| 181 × 1448 | "181x1448" |
or |
"1:8"
+
"0.5K"
|
| 1448 × 181 | "1448x181" |
or |
"8:1"
+
"0.5K"
|
| 418 × 627 | "418x627" |
or |
"2:3"
+
"0.5K"
|
| 627 × 418 | "627x418" |
or |
"3:2"
+
"0.5K"
|
| 458 × 572 | "458x572" |
or |
"4:5"
+
"0.5K"
|
| 782 × 335 | "782x335" |
or |
"21:9"
+
"0.5K"
|
| 443 × 591 | "443x591" |
or |
"3:4"
+
"0.5K"
|
| 591 × 443 | "591x443" |
or |
"4:3"
+
"0.5K"
|
1K 14 sizes
| Output |
size
|
aspect_ratio
+
resolution
|
|
|---|---|---|---|
| 1183 × 887 | "1183x887" |
or |
"4:3"
+
"1K"
|
| 916 × 1145 | "916x1145" |
or |
"4:5"
+
"1K"
|
| 1145 × 916 | "1145x916" |
or |
"5:4"
+
"1K"
|
| 512 × 2048 | "512x2048" |
or |
"1:4"
+
"1K"
|
| 1024 × 1024 | "1024x1024" |
or |
"1:1"
+
"1K"
|
| 2048 × 512 | "2048x512" |
or |
"4:1"
+
"1K"
|
| 887 × 1182 | "887x1182" |
or |
"3:4"
+
"1K"
|
| 362 × 2896 | "362x2896" |
or |
"1:8"
+
"1K"
|
| 2896 × 362 | "2896x362" |
or |
"8:1"
+
"1K"
|
| 836 × 1254 | "836x1254" |
or |
"2:3"
+
"1K"
|
| 1254 × 836 | "1254x836" |
or |
"3:2"
+
"1K"
|
| 768 × 1365 | "768x1365" |
or |
"9:16"
+
"1K"
|
| 1365 × 768 | "1365x768" |
or |
"16:9"
+
"1K"
|
| 1563 × 670 | "1563x670" |
or |
"21:9"
+
"1K"
|
2K 14 sizes
| Output |
size
|
aspect_ratio
+
resolution
|
|
|---|---|---|---|
| 3129 × 1341 | "3129x1341" |
or |
"21:9"
+
"2K"
|
| 1774 × 2365 | "1774x2365" |
or |
"3:4"
+
"2K"
|
| 2365 × 1774 | "2365x1774" |
or |
"4:3"
+
"2K"
|
| 1832 × 2290 | "1832x2290" |
or |
"4:5"
+
"2K"
|
| 2290 × 1832 | "2290x1832" |
or |
"5:4"
+
"2K"
|
| 1536 × 2731 | "1536x2731" |
or |
"9:16"
+
"2K"
|
| 2731 × 1536 | "2731x1536" |
or |
"16:9"
+
"2K"
|
| 1024 × 4096 | "1024x4096" |
or |
"1:4"
+
"2K"
|
| 2048 × 2048 | "2048x2048" |
or |
"1:1"
+
"2K"
|
| 4096 × 1024 | "4096x1024" |
or |
"4:1"
+
"2K"
|
| 724 × 5793 | "724x5793" |
or |
"1:8"
+
"2K"
|
| 5792 × 724 | "5792x724" |
or |
"8:1"
+
"2K"
|
| 1672 × 2508 | "1672x2508" |
or |
"2:3"
+
"2K"
|
| 2508 × 1672 | "2508x1672" |
or |
"3:2"
+
"2K"
|
4K 14 sizes
| Output |
size
|
aspect_ratio
+
resolution
|
|
|---|---|---|---|
| 3548 × 4730 | "3548x4730" |
or |
"3:4"
+
"4K"
|
| 3345 × 5017 | "3345x5017" |
or |
"2:3"
+
"4K"
|
| 4580 × 3664 | "4580x3664" |
or |
"5:4"
+
"4K"
|
| 2048 × 8192 | "2048x8192" |
or |
"1:4"
+
"4K"
|
| 4096 × 4096 | "4096x4096" |
or |
"1:1"
+
"4K"
|
| 8192 × 2048 | "8192x2048" |
or |
"4:1"
+
"4K"
|
| 3072 × 5461 | "3072x5461" |
or |
"9:16"
+
"4K"
|
| 5461 × 3072 | "5461x3072" |
or |
"16:9"
+
"4K"
|
| 1448 × 11585 | "1448x11585" |
or |
"1:8"
+
"4K"
|
| 4729 × 3547 | "4729x3547" |
or |
"4:3"
+
"4K"
|
| 11584 × 1448 | "11584x1448" |
or |
"8:1"
+
"4K"
|
| 5016 × 3344 | "5016x3344" |
or |
"3:2"
+
"4K"
|
| 3663 × 4579 | "3663x4579" |
or |
"4:5"
+
"4K"
|
| 6256 × 2681 | "6256x2681" |
or |
"21:9"
+
"4K"
|
How these parameters work
size
Exact pixel dimensions
"1920x1080"
aspect_ratio
Shape only, default scale
"16:9"
resolution
Scale tier, preserves shape
"1K"
Priority when combined
size is most specific and always wins. aspect_ratio and resolution control shape and scale independently.
How matching works
7:1 on a model with
4:1 and 8:1,
you get 8:1.
0.5K 1K 2K 4K)
or megapixel tiers (0.25 1).
If the exact tier isn't available, you get the nearest one.
Media Inputs
| Parameter | Type | Description | Modes |
|---|---|---|---|
image
|
file |
Required.
Input image(s) to edit
Supports PNG, JPEG, WebP.
|
T2I
Edit
|
Output & Format
| Parameter | Type | Description | Modes |
|---|---|---|---|
response_format
|
string |
How to return the image
url
b64_json
Default:
"url" |
T2I
Edit
|
output_format
|
string |
Output image format
png
jpeg
gif
webp
avif
Gateway converts to requested format if provider doesn't support it natively.
|
T2I
Edit
|
output_compression
|
integer | Compression level for lossy formats (JPEG, WebP, AVIF) |
T2I
Edit
|
n
|
integer |
Number of images to generate
Default:
1Gateway generates multiple images in parallel even if provider only supports 1.
|
T2I
Edit
|
Additional Parameters
| Parameter | Type | Description | Modes |
|---|---|---|---|
enable_web_search
fal
|
boolean | Enable web search for the image generation task. This will allow the model to use the latest information from the web to generate the image. |
T2I
Edit
|
google_search
replicate
|
boolean | Use Google Web Search grounding to generate images based on real-time information (e.g. weather, sports scores, recent events). |
T2I
Edit
|
image_search
replicate
|
boolean | Use Google Image Search grounding to find web images as visual context for generation. When enabled, web search is also used automatically. |
T2I
Edit
|
limit_generations
fal
|
boolean | Experimental parameter to limit the number of generations from each round of prompting to 1. Set to `True` to to disregard any instructions in the prompt regarding the number of images to generate and ignore any intermediate images generated by the model. This may affect generation quality. |
T2I
Edit
|
safety_tolerance
fal
|
string |
The safety tolerance level for content moderation. 1 is the most strict (blocks most content), 6 is the least strict.
1
2
3
4
5
6
|
T2I
Edit
|
sync_mode
fal
|
boolean | If `True`, the media will be returned as a data URI and the output data won't be available in the request history. |
T2I
Edit
|
thinking_level
fal
|
string |
When set, enables model thinking with the given level ('minimal' or 'high') and includes thoughts in the generation. Omit to disable.
high
minimal
|
T2I
Edit
|
Parameter Normalization
How we handle parameters across different providers
Not every provider speaks the same language. When you send a parameter, we handle it in one of four ways depending on what the model supports:
| Behavior | What happens | Example |
|---|---|---|
passthrough |
Sent as-is to the provider | style, quality |
renamed |
Same value, mapped to the field name the provider expects | prompt |
converted |
Transformed to the provider's native format | size |
emulated |
Works even if the provider has no concept of it | n, response_format |
Parameters we don't recognize pass straight through to the upstream API, so provider-specific options still work.