Index of every page on this site: llms.txt
All skills
massgen avatar

/image-generation

@007bd85
by massgenmassgen/massgen1.2k stars
184
Run it yourself

Guide to image generation and editing in MassGen. Use when creating images, editing existing images, iterating on image designs, or choosing between image backends (OpenAI, Google Gemini/Imagen, Grok, OpenRouter).

Use this Skill: https://skilld.dev/gh/massgen/massgen/image-generation

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈58 tokens for metadata: the name and description. ≈1k when used: this file. ≈2.9k more on demand in 3 files.

Description uses 2.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈232 characters, or 2.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Image Generation

Generate images using generate_media with mode="image". The system auto-selects the best backend based on available API keys.

Quick Start

# Simple text-to-image (auto-selects backend)
generate_media(prompt="A cat in space", mode="image")

# Specify backend and quality
generate_media(prompt="A logo for a coffee shop", mode="image",
               backend_type="openai", quality="high")

# Batch generation (parallel)
generate_media(prompts=["sunset over ocean", "mountain landscape", "city at night"],
               mode="image", max_concurrent=3)

Backend Comparison

Backend Default Model Strengths API Key
Google (priority 1) gemini-3.1-flash-image-preview (Nano Banana 2) Fast, flexible sizes, image editing, multi-turn GOOGLE_API_KEY or GEMINI_API_KEY
OpenAI (priority 2) gpt-5.4 High quality, transparent backgrounds, continuation via response ID OPENAI_API_KEY
Grok (priority 3) grok-imagine-image 1k resolution, continuation via stored data URI XAI_API_KEY
OpenRouter (priority 4) google/gemini-3.1-flash-image-preview Access to multiple models via single API OPENROUTER_API_KEY

Key Parameters

Parameter Description Example
prompt Text description of the image "A watercolor painting of mountains"
backend_type Force a specific backend "google", "openai", "grok", "openrouter"
model Override default model "gemini-3-pro-image-preview" for studio quality
quality Image quality (OpenAI) "low", "medium", "high", "auto"
size Image dimensions See backends reference
aspect_ratio Aspect ratio "16:9", "1:1", "4:5"
input_images Source images for image-to-image editing ["photo.jpg"]
continue_from Continuation ID for multi-turn editing result["continuation_id"]

Image-to-Image Editing

Transform existing images by providing input_images:

generate_media(
    prompt="Make it look like a watercolor painting",
    mode="image",
    input_images=["photo.jpg"]
)

Supported backends for image-to-image: Google (Gemini), OpenAI, Grok. The system auto-selects if your current backend doesn't support it.

Multi-Turn Editing (Continuation)

Iteratively refine images using continue_from:

# First generation
result = generate_media(prompt="A logo for a coffee shop", mode="image")

# Refine using the continuation ID
result2 = generate_media(
    prompt="Make the text larger and add a cup icon",
    mode="image",
    continue_from=result["continuation_id"]
)

Each backend uses a different continuation mechanism:

  • OpenAI: Passes previous_response_id (stateless)
  • Google Gemini: In-memory chat store (LRU, 50 items)
  • Grok: In-memory data URI store (LRU, 50 items)

Continuation only works for single image generation (not batch).

Google: Gemini vs Imagen

Google supports two API paths. Gemini (Nano Banana 2) is the default and recommended for most use cases. Imagen is only needed for advanced reference-image editing features.

  • Gemini models (gemini-*): generate_content() — text-to-image, image editing via input_images, multi-turn continuation
  • Imagen models (imagen-*): generate_images() / edit_image() — text-to-image with negative_prompt/seed/guidance_scale, plus style transfer, control editing, and subject consistency via reference images

For studio-quality precision and text rendering, use: model="gemini-3-pro-image-preview" (Pro-tier).

Need More Control?

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo4 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides comprehensive documentation and examples for generating and editing images using multiple AI backends (Google, OpenAI, Grok, OpenRouter). It is assessed as low risk due to the inherent surface for indirect prompt injection when processing user-provided prompts and images through generative models.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 007bd85. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Steadyupdated 9 months ago

README badge

README badge for massgen/massgen/image-generation