Guide
How to Use Gemini 3 Pro Image via the Gemini API (Dec 2025)
A practical, accurate guide to generating images with Google’s Gemini 3 Pro Image model using the Gemini API.
Last reviewed: 2025-12-07
ACTD
AI Coding Tools Directory
Editorial Team
The AI Coding Tools Directory editorial team researches, tests, and reviews AI-powered development tools to help developers find the best solutions for their workflows.
Note: This guide uses the Gemini 3 Pro Image model as documented in the Gemini API. It avoids fictional names/features and sticks to the preview model IDs available via ai.google.dev.
1) Get a Gemini API key
- Go to Google AI Studio.
- Click Get API key and create/select a Google Cloud project.
- Copy the key (starts with
AIza…). Store it securely (env vars or.env, not in git).
Example env var:
export GEMINI_API_KEY="your_key_here"
2) Install the SDK
- Python:
pip install google-generativeai - Node.js:
npm install @google/generative-ai
3) Generate an image (Python)
import os
import google.generativeai as genai
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
model = genai.GenerativeModel("gemini-3-pro-image-preview")
prompt = "A serene Japanese garden at sunset with a koi pond and bridge"
response = model.generate_content([prompt])
if response.candidates:
image_bytes = response.candidates[0].content.parts[0].inline_data.data
with open("image.png", "wb") as f:
f.write(image_bytes)
print("Saved image.png")
else:
print("No image generated")
4) Generate an image (Node.js)
import fs from "fs/promises";
import { GoogleGenerativeAI } from "@google/generative-ai";
const apiKey = process.env.GEMINI_API_KEY;
const genAI = new GoogleGenerativeAI(apiKey);
const model = genAI.getGenerativeModel({ model: "gemini-3-pro-image-preview" });
async function run() {
const prompt = "Product shot of matte black wireless headphones on a gray gradient background";
const result = await model.generateContent([prompt]);
const data = result.response.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;
if (!data) {
console.log("No image generated");
return;
}
await fs.writeFile("product.png", Buffer.from(data, "base64"));
console.log("Saved product.png");
}
run().catch(console.error);
5) Good prompts and considerations
- Be specific: subject, style, lighting, resolution, and aspect.
- Keep sensitive content within policy; follow Google’s use-case and safety guidelines.
- Respect preview limits/quotas; check the Gemini API docs for pricing and rate limits.
- Do not embed API keys in code; use env vars/secrets.
6) Where to find official details
- Model docs and code samples: https://ai.google.dev/gemini-api/docs
- Pricing/quotas: https://ai.google.dev/pricing
- Safety/policy: https://ai.google.dev/policies
This guide stays aligned with the official Gemini API; no fictional model names or unsupported features.*** End Patch
Tools Mentioned in This Article
Frequently Asked Questions
How do I get started with Gemini 3 Pro Image via the Gemini API (Dec 2025)?
A practical, accurate guide to generating images with Google’s Gemini 3 Pro Image model using the Gemini API.
Explore More AI Coding Tools
Browse our comprehensive directory of AI-powered development tools, IDEs, and coding assistants.
Browse All Tools