gemini-image-simple

Generate and edit images via the Gemini API using Python's standard library.

Updated Mar 16, 2026
One-click install
npx skills add https://github.com/zhouxiumin/zxm-skills --skill gemini-image-simple-zhouxiumin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gemini-image-simple
Source: https://github.com/zhouxiumin/zxm-skills/tree/main/skills/gemini-image-simple
Command: npx skills add https://github.com/zhouxiumin/zxm-skills --skill gemini-image-simple-zhouxiumin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a self-contained way to generate and edit images using the Gemini API without external dependencies, enabling developers to add AI-assisted visuals to projects without managing packages.

Core Features & Use Cases

  • Pure Python stdlib HTTP requests via urllib.request to Gemini API.
  • Generate new images from prompts and edit existing images with optional input.
  • Model switching and output options with zero-install requirements.
  • Environment-based configuration through API key and base URL.

Quick Start

Run the generator script with a prompt and an output path, for example: python {baseDir}/scripts/generate.py 'A cat wearing a hat' cat.png

Frequently Asked Questions about gemini-image-simple

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate images with the Gemini API using only the Python standard library?

You can generate images with the Gemini API using pure Python stdlib by sending HTTP requests via urllib.request, eliminating the need for external dependencies like pip packages. This skill handles base64 image payloads and model selection directly.

Can I edit existing images with Gemini without installing additional Python packages?

Yes, you can edit existing images with Gemini without additional Python packages by passing base64 image payloads through urllib.request. The skill supports optional input images for AI-driven editing alongside text prompts.

Do I need pip or external dependencies to use the Gemini API for image generation in Python?

No, you do not need pip or external dependencies because this skill relies entirely on Python's standard library. It uses urllib.request for HTTP requests, enabling zero-install execution in environments where package management is restricted.

How do I configure the API key and base URL for Gemini image generation?

Configure the API key and base URL for Gemini image generation using environment variables ZXM_GEMINI_API_KEY and ZXM_GEMINI_API_BASE_URL. This environment-based setup allows secure configuration without hardcoding credentials in scripts.

What is the best way to run a Python script for prompt-based image generation?

The best way to run prompt-based image generation is executing the generator script with your prompt and output path, such as: python generate.py 'A cat wearing a hat' cat.png. This directly triggers the Gemini API to save the visual output.

What limitations should I expect when using Python stdlib for Gemini API image generation?

When using Python stdlib for Gemini API image generation, limitations include manual handling of base64 encoding and robust error handling without third-party libraries. Network errors and API rate limits must be managed within urllib.request constraints.