# Gemini 3.1 Flash Image (Preview)

Gemini 3.1 Flash Image (Preview) costs $0.5 per 1M input tokens and $60 per 1M output tokens on LLM API, with a 131K-token context window.

Model ID: `gemini-3.1-flash-image-preview` · Google · Image generation · Released February 26, 2026
Updated: 2026-10-13
Canonical: https://llmapi.ai/models/google-gemini-3-1-flash-image-preview/

- Input: $0.5 per 1M tokens
- Output: $60 per 1M tokens
- Modes: Generate, Edit
- Input images: Up to 10

## Pricing

Lowest price among 2 providers, after discounts.

| Price | Amount | Per |
| --- | --- | --- |
| Input | $0.5 | per 1M tokens |
| Output | $60 | per 1M tokens |

**Volume pricing.** At higher monthly volume, Gemini 3.1 Flash Image (Preview) may cost less. Book a call and sales will quote a price for your usage. [Book a call with sales](https://meetings.hubspot.com/julia-andriienko/llmapi) or [Create an account first](https://app.llmapi.ai/signup).

## Providers

Prices after each provider’s discount; the lowest in bold.

| Provider | Input / 1M | Output / 1M |
| --- | --- | --- |
| [Google AI Studio](https://llmapi.ai/providers/google-ai-studio/) | $0.5 | $60 |
| [Google Vertex AI](https://llmapi.ai/providers/google-vertex/) | $0.5 | $60 |

## Specifications

- Modes: Generate, Edit
- Output formats: PNG
- Input images: Up to 10, 20 MB each
- Sizes: 14 sizes: 1024×1024, 512×2048, 384×3072, 848×1264, 1264×848, 896×1200, 2048×512, 1200×896, 928×1152, 1152×928, 3072×384, 768×1376, 1376×768, 1584×672

## Call Gemini 3.1 Flash Image (Preview)

### Generate (`POST /v1/images/generations`)

Set LLMAPI_KEY to your LLM API key.

```python
import base64
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.llmapi.ai/v1",
    api_key=os.environ["LLMAPI_KEY"],
)

result = client.images.generate(
    model="gemini-3.1-flash-image-preview",
    prompt="A lighthouse at dawn, watercolor",
)
with open(f"image.{result.output_format}", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))
```

Docs: [Generate docs](https://docs.llmapi.ai/api/v1/images)

### Edit (`POST /v1/images/edits`)

Set LLMAPI_KEY to your LLM API key.

```python
import base64
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.llmapi.ai/v1",
    api_key=os.environ["LLMAPI_KEY"],
)

result = client.images.edit(
    model="gemini-3.1-flash-image-preview",
    image=open("photo.png", "rb"),
    prompt="Replace the sky with a sunset",
)
with open(f"edited.{result.output_format}", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))
```

Docs: [Edit docs](https://docs.llmapi.ai/api/v1/images)

## More from Google

- [Nano Banana 2.1](https://llmapi.ai/models/gemini-nano-banana-2-1/): $0.0336 per image
- [Nano Banana 2 Lite](https://llmapi.ai/models/gemini-3-1-flash-lite-image/): $0.0336 per image
- [Gemini 3 Pro Image (Preview)](https://llmapi.ai/models/google-gemini-3-pro-image-preview/): $2 / $120 per 1M input / output

Prices synced 2026-11-03.

Next step: [Get API key](https://app.llmapi.ai/signup)
