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-imageAuthentication
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
- First Turn: Send a regular request with
prompt(and optionalimage) - Response: The response includes
next_turn_contents- a pre-formatted conversation history - Next Turn: Copy
next_turn_contentsto your payload’scontentsfield, then add your new instruction to the last user turn - Repeat: Continue iterating until satisfied
First Turn Request
First Turn Response (with next_turn_contents)
Second Turn Request (Using next_turn_contents)
Copynext_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
textfield in the last user turn - Add reference image: Include a
fileDatawithfileUripointing to a GCS or HTTP URL - Empty fields are ignored: Empty
textorfileUriare automatically filtered out - Conversation history: Each response includes updated
next_turn_contentsfor the next iteration
Model Specifications
Pricing
- Input (text, image, video): $0.30 per 1M tokens
- Image output: 0.0387 per image**)
- Text output: $2.50 per 1M tokens
Tips for Better Results
- Prompt Clarity: Use detailed, specific prompts for precise results.
- Multi-turn Iteration: For complex edits, use multi-turn mode to refine the image step by step.
- Reference Images: Provide up to 3 reference images to guide style and composition.