Skip to main content
Model ID
Calling method: sync

Gemini 2.5 Flash Image API Usage Guide

Overview

Gemini 2.5 Flash Image is optimized for image understanding and generation, offering a balance of price and performance. It uses the speed and cost-effectiveness of Gemini 2.5 Flash to provide fast and efficient image generation and editing capabilities. Supports text-to-image, image editing, and multi-turn conversations. Each generated image consumes 1290 tokens. Reference: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-image

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Submit Image Generation Request

Base URL

Endpoint

Request Format

Request Parameters

Response

Check Request Status

Endpoint

Example

Response

Request Status Values

List Your Requests

Endpoint

Example

Get Model Information

Endpoint

Example

List Available Models

Endpoint

Example

Response

Multi-turn Conversation (Iterative Image Editing)

This model supports multi-turn conversations for iterative image editing. After generating an image, you can continue refining it by providing additional instructions.

How It Works

  1. First Turn: Send a regular request with prompt (and optional image)
  2. Response: The response includes next_turn_contents - a pre-formatted conversation history
  3. Next Turn: Copy next_turn_contents to your payload’s contents field, then add your new instruction to the last user turn
  4. Repeat: Continue iterating until satisfied

First Turn Request

First Turn Response (with next_turn_contents)

Second Turn Request (Using next_turn_contents)

Copy next_turn_contents to contents, then fill in the last user turn with your new instruction:

Multi-turn Tips

  • Text-only edits: Just fill in the text field in the last user turn
  • Add reference image: Include a fileData with fileUri pointing to a GCS or HTTP URL
  • Empty fields are ignored: Empty text or fileUri are automatically filtered out
  • Conversation history: Each response includes updated next_turn_contents for the next iteration

Model Specifications

Pricing

  • Input (text, image, video): $0.30 per 1M tokens
  • Image output: 30per1Mtokens(1290tokensperimage30 per 1M tokens (1290 tokens per image ≈ **0.0387 per image**)
  • Text output: $2.50 per 1M tokens

Tips for Better Results

  1. Prompt Clarity: Use detailed, specific prompts for precise results.
  2. Multi-turn Iteration: For complex edits, use multi-turn mode to refine the image step by step.
  3. Reference Images: Provide up to 3 reference images to guide style and composition.