Gemini 3.1 Flash Image API Usage Guide
Overview
Gemini 3.1 Flash Image is optimized for image understanding and generation, balancing speed and cost. It supports text-to-image, image-guided editing, and multi-turn iterative workflows viacontents.
Reference: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-1-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
Gemini Native Interface (alternative)
In addition to the GMI-shape/requests endpoint above, this model accepts
the Vertex-native generateContent shape — request body matches what
Google’s generateContent
uses. Customers already running on google-genai SDK or any HTTP client
that follows Google’s REST contract can plug in by changing only the
base_url and Authorization header.
Endpoint
Curl example
google-genai SDK example
Multi-turn
Passcontents as user/model/user alternation. The last turn must be
role: "user". Reference images on user turns go in
parts[].inlineData (base64) — same field shape as Google’s
generateContent.
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_contentswith prior conversation context - Next Turn: Copy
next_turn_contentsinto payloadcontents, then append your new user instruction - Repeat: Continue until the result is satisfactory
Model Specifications
Capabilities
- Supported: System instructions, Count Tokens, Thinking
- Not supported: Code execution, Function calling, Gemini Live API, implicit/explicit context caching, Vertex AI RAG Engine, Chat completions
Pricing
- Input (text, image): $0.50 per 1M tokens
- Text output (response/reasoning): $3.00 per 1M tokens
- Image output: $60 per 1M tokens
- 512 output image: 747 tokens (about $0.045/image)
- 1K output image: 1120 tokens (about $0.067/image)
- 2K output image: 1680 tokens (about $0.101/image)
- 4K output image: 2520 tokens (about $0.15/image)
Tips for Better Results
- Use specific and descriptive prompts for stable outputs.
- For complex edits, use multi-turn mode with
contentsfor iterative refinement. - Use high-quality reference images and keep composition/style instructions explicit.