# Gemini 3.1 Flash Image Preview · Image Editing

Generate and edit images from text with Gemini 3.1 Flash Image Preview · Image Editing from fal through one Spiral API key. It runs in the background and returns images. Pay as you go, with no subscription.

- Provider: fal
- Category: Image
- Runs: In the background
- Returns: image
- Tool id: `fal` / `fal-ai/gemini-3.1-flash-image-preview/edit`
- Page: https://spiral.ai/tools/fal/fal-ai/gemini-3.1-flash-image-preview/edit

## Pricing

`resolution`: 0.5K $0.078, 1K (default) $0.104, 2K $0.156, 4K $0.208 per image. Billed on `num_images`, default 1.

## Limits

- Longest queue wait: 1 hour
- Run deadline: 30 minutes
- Longest run, end to end: 225 minutes
- Largest inline input: 1 MB
- Largest input file: 2 GB
- Largest output: 5 GB

## Input

| Field | Kind | Allowed | Default | Description |
| --- | --- | --- | --- | --- |
| `prompt` (required) | text |  | — | The prompt for image editing. |
| `image_urls` | URLs or files |  | — | The URLs of the images to use for image-to-image generation or image editing. Optional when at least one of `video_url`, `audio_url`, or `pdf_url` is provided. |
| `history` | JSON |  | — | Previous native Gemini turns, including original parts and thought signatures from conversations. The current prompt starts a new user turn. |
| `context` | JSON |  | — | Ordered text, image, PDF, UTF-8 text-file or video parts appended to the current prompt. Original media bytes are preserved; images count toward the total 14-reference limit. |
| `return_history` | true or false |  | false | Return reusable native conversations with original image parts and provider thought signatures. Uses a native provider. Each generated conversation is independent; send its messages as history for the next turn. |
| `thinking_level` | one of | minimal, high | — | Controls thinking effort ('minimal' or 'high') and requests thought summaries. Omit to use the provider default ('minimal'); thinking cannot be disabled. |
| `image_passthrough` | true or false |  | false | Send reference images and return provider images without resizing or re-encoding, preserving transparency and metadata. Uses direct Google or Vertex APIs; the returned image format may differ from output_format. |
| `include_thoughts` | true or false |  | — | Whether to include thought summaries. Omit to preserve the existing behavior: an explicit thinking_level requests summaries. Set limit_generations=false to return summary text in description. This does not disable thinking or return intermediate thought images. |
| `temperature` | number | 0 to 2 | — | Sampling temperature. Omit to use the provider default of 1. Explicit values use a direct Google or Vertex API. |
| `top_p` | number | 0 to 1 | — | Nucleus sampling probability. Omit to use the provider default of 0.95. Explicit values use a direct Google or Vertex API. |
| `max_output_tokens` | number (whole) | 1 to 32768 | — | Maximum output tokens for the generation. Omit to retain the provider default. Explicit values use a direct Google or Vertex API. |
| `num_images` | number (whole) | 1 to 4 | 1 | The number of images to generate. |
| `seed` | number (whole) |  | — | The seed for the random number generator. |
| `aspect_ratio` | one of | auto, 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16, 4:1, 1:4, 8:1, 1:8 | auto | The aspect ratio of the generated image. Supports extreme ratios: 4:1, 1:4, 8:1, 1:8. |
| `output_format` | one of | jpeg, png, webp | png | The format of the generated image. |
| `safety_tolerance` | one of | 1, 2, 3, 4, 5, 6 | 4 | The safety tolerance level for content moderation. 1 is the most strict (blocks most content), 6 is the least strict. |
| `system_prompt` | text |  |  | Optional system instruction that steers the model's persona and output style across the request. Leave blank to omit; when provided, it is sent as the system instruction to Gemini (or as a system message on OpenAI-compatible providers). |
| `resolution` | one of | 0.5K, 1K, 2K, 4K | 1K | The resolution of the image to generate. |
| `video_url` | URL or file |  | — | Optional video to use as input context. Accepts an http(s)/data URL to a video file (downloaded and sent inline, max 15MB) or a YouTube URL (passed through to the model without downloading). |
| `audio_url` | URL or file |  | — | Optional audio file to use as input context. Accepts an http(s)/data URL (downloaded and sent inline, max 15MB). |
| `pdf_url` | URL or file |  | — | Optional PDF document to use as input context. Accepts an http(s)/data URL (downloaded and sent inline, max 15MB). |
| `limit_generations` | true or false |  | true | 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. |
| `enable_web_search` | true or false |  | false | 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. |
| `enable_image_search` | true or false |  | false | Ground image generation with Google Image Search. Can be combined with enable_web_search; source attribution is returned in grounding_metadata. Uses direct Google or Vertex APIs. |

## Example

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "fal",
    "model": "fal-ai/gemini-3.1-flash-image-preview/edit",
    "input": {
      "prompt": "make a photo of the man driving the car down the california coastline"
    }
  }'
```

Try it in the Playground: https://spiral.ai/start?provider=fal&model=fal-ai%2Fgemini-3.1-flash-image-preview%2Fedit

## Common questions

### Gemini 3.1 Flash Image Preview · Image Editing

**How much does Gemini 3.1 Flash Image Preview · Image Editing cost?**

`resolution`: 0.5K $0.078, 1K (default) $0.104, 2K $0.156, 4K $0.208 per image. Billed on `num_images`, default 1. You pay as you go from one Spiral balance, with no subscription, and a failed run is not charged.

**How do I use Gemini 3.1 Flash Image Preview · Image Editing through an API?**

Send `POST /v1/runs` with `"provider": "fal"`, `"model": "fal-ai/gemini-3.1-flash-image-preview/edit"` and the input fields on this page, using one Spiral API key. It runs in the background: poll the run, or name a webhook to be told when it finishes.

**Do I need an account with fal to use Gemini 3.1 Flash Image Preview · Image Editing?**

No. Spiral runs it on its own fal account and charges your Spiral balance.

**Can my AI agent use Gemini 3.1 Flash Image Preview · Image Editing?**

Yes. Agents find and run it through Spiral's MCP server, CLI or agent skill, with the same API key.

