GEMINI LABJP
ROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 termsROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 terms
Articles/API / SDK
API / SDK/2026-06-22Advanced

Structured Product Image Analysis with the Gemini API — A Production Pipeline Built on Thousands of Photos

Turn a one-off image analysis script into a production pipeline that auto-generates tags, descriptions, and categories at scale — covering structured output, resumable batches, measured cost, and model routing learned from real indie-developer operation.

Gemini API230Vision4structured-output28python104batch2cost-optimization31indie-dev47

Premium Article

As an indie developer working on apps and store assets, I keep rediscovering how quietly the boring work — tidying up image metadata — eats my time. For a stretch I was tagging and writing descriptions for assets by hand as they grew by the hundreds. Even at a few dozen seconds each, that adds up to half a day gone.

So I switched to multimodal analysis with the Gemini API. But the first script I wrote — "send one image, get one result" — worked as a prototype yet showed its cracks the moment I pushed thousands of images through it. A single mid-run failure meant starting over, my cost estimates were too optimistic, and the category coming back would occasionally drift. After rebuilding it a few times for Dolice Labs, it settled into something that keeps running in production.

This article focuses on that delta — from a one-off prototype to a pipeline that survives failure. We'll start with the basics, then layer in measured cost, a resumable batch, and the operational details you won't find in the docs.

Prerequisites and Setup

What You'll Need

  • Python 3.10 or later
  • A Google AI Studio API key (get one at Google AI Studio)
  • The google-genai package

Setting Up Your Environment

# Create and activate a virtual environment
python -m venv gemini-image-env
source gemini-image-env/bin/activate  # Windows: gemini-image-env\Scripts\activate
 
# Install dependencies
pip install google-genai Pillow

Set your API key as an environment variable:

export GEMINI_API_KEY="your-api-key-here"

If you're new to the Gemini API, the Gemini API Quickstart Guide is a great place to start.

Basic Image Analysis — Extracting Information from a Single Product Photo

Let's start with the simplest case: sending a single product image to the Gemini API and getting a natural language description back.

# basic_image_analysis.py
import os
from google import genai
from google.genai import types
 
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
 
def analyze_product_image(image_path: str) -> str:
    """Analyze a product image and return a description."""
    with open(image_path, "rb") as f:
        image_data = f.read()
 
    response = client.models.generate_content(
        model="gemini-3.1-pro",
        contents=[
            types.Content(
                role="user",
                parts=[
                    types.Part.from_bytes(data=image_data, mime_type="image/jpeg"),
                    types.Part.from_text(
                        "Analyze this product image. Describe the product name, "
                        "category, color, material, and key features in detail."
                    ),
                ],
            )
        ],
    )
    return response.text
 
# Usage
result = analyze_product_image("product_sample.jpg")
print(result)
 
# Expected output:
# This is a white crew-neck T-shirt made from soft cotton fabric.
# It features a minimalist design with a small embroidered logo
# on the chest. The material appears to be 100% cotton, making it
# ideal for casual everyday wear.

This works well enough for a quick analysis, but the free-form text output is hard to process programmatically. Let's fix that with Structured Output.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Measured cost, latency, and accuracy across thousands of images, plus the break-even point for routing between Flash and Pro
A checkpoint-based batch you can stop and resume without losing work — complete, copy-paste-ready code
The undocumented gotchas: enum drift, schema strictness, and pre-upload downscaling, with fixes that survive real runs
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $15 for lifetime access
View Membership →

Related Articles

API / SDK2026-05-16
Automating Firebase Crashlytics Analysis with Gemini API — A Real-World Implementation from an Indie App
A real-world implementation record of automating Firebase Crashlytics log analysis with Gemini API, validated during development of an indie wallpaper app (v2.1.0). Includes Before/After code for a RecyclerView crash fix and a production cost breakdown.
API / SDK2026-05-14
Controlling thinking_budget in Gemini 2.5 Pro — Cut Costs by 70% Without Sacrificing Reasoning Quality
Leaving thinking_budget unset in Gemini 2.5 Pro leads to unexpected costs. This guide covers task-level budget design, dynamic control, and production monitoring with working Python code.
API / SDK2026-08-22
Once You Pass Twenty Mediation Groups, How Do You Find the Setting That Went Missing?
As ad mediation groups multiply, missing sources and type drift accumulate quietly. Here is the split I settled on: normalize the settings into one matrix, let code confirm the gaps, and send Gemini only the cells that need judgment.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →