Skip to main content

pixgen

One CLI. Every image model. Your keys.

Generate and edit images with OpenAI, Google Gemini, and OpenRouter from one typed command. Pixgen runs locally, writes plain files, and returns versioned JSON for both humans and coding agents.

PyPI Python 3.14+ CI MIT licence

Quickstart · Tutorial · Why Pixgen · Agent skill · Models · Usage · Configuration · Development

pixgen fanning one prompt out to OpenAI, Google, and OpenRouter models, writing files atomically, and returning JSON

Quickstart

Pixgen requires Python 3.14 or newer.

uv tool install --python python3.14 pixgen   # or try it once: uvx --python python3.14 pixgen --help

uv tool installs Pixgen into its own isolated environment and puts pixgen on your PATH. --python python3.14 makes uv use (or download) Python 3.14, so it works even if your default Python is older.

export OPENAI_API_KEY=sk-...         # bring your own key
pixgen create "A modern cabin beside a Norwegian fjord" \
  --model openai/gpt-image-2 \
  --output cabin.png

That's it: cabin.png is on disk. Update later with uv tool upgrade pixgen. For a walkthrough that uses Claude Code or Codex to analyse this repository, then sends the resulting prompts to Pixgen, see the image generation tutorial. It also covers model groups and all three providers.

Why Pixgen

  • One contract, many providers. The same create and edit commands work across Google, OpenAI, and OpenRouter accounts you authenticate yourself.
  • Fan out in one command. Repeat --model, or name a model group, and Pixgen runs every target concurrently, with live per-target progress.
  • Checked before you pay. Model discovery is offline, and requests are validated locally before any paid call reaches a provider.
  • Files you can trust. Artifacts are written atomically, so you never get a half-written image.
  • Built for agents and scripts. --json returns a versioned envelope with typed, per-target errors.
  • Bring your own keys. Not tied to any single provider, account or subscription; pay for what you use with your own API keys.

pixgen --json returns a versioned result envelope with per-target artifacts and typed errors

Agent skill

Install the pixgen-cli skill to teach Claude Code and Codex agents how to use Pixgen's CLI, including its JSON output and model groups:

npx skills add difegam/pixgen --skill pixgen-cli --agent claude-code --agent codex

Add --global to install it for your user account instead of this project:

npx skills add difegam/pixgen --skill pixgen-cli --agent claude-code --agent codex --global

For image requests, the skill prefers an image-generation tool exposed by the active agent harness when one is available. Pixgen provides the CLI workflow when you ask for Pixgen, need its provider and model choices, or want to compare models. Install Pixgen itself and configure a provider API key to run those CLI requests; installing the skill only adds agent instructions.

Providers and models

Provider API key Models Create Edit
OpenAI OPENAI_API_KEY openai/gpt-image-2, openai/gpt-image-1-mini ✓ ✓
Google Gemini GEMINI_API_KEY gemini/gemini-3.1-flash-image, gemini/gemini-3.1-flash-lite-image, gemini/gemini-3-pro-image ✓ ✓
OpenRouter OPENROUTER_API_KEY openrouter/google/gemini-3.1-flash-image (up to 14 reference images) ✓ ✓
openrouter/openai/gpt-image-2.5-sunburst (up to 16 reference images) ✓ ✓
openrouter/meta/muse-image ✓ —

OpenRouter model IDs keep OpenRouter's upstream slug. muse-image is create-only because the Images API does not document reference-image input for it. Reference images go through OpenRouter's Images API.

Run pixgen model list for the current catalogue. It needs no credentials.

Usage

Shared commands

Root create and edit take canonical provider/model IDs and keep each provider's defaults. create accepts repeated --model options or one configured --group, but not both. edit takes explicit models and the common strict width:height aspect ratio. Ratios are reduced to canonical form (21:9 becomes 7:3), and every selected model must support the value you ask for.

pixgen create "A modern cabin beside a Norwegian fjord" \
  --group product-hero \
  --output cabin.png

pixgen edit "Remove the background" \
  --image cabin.png \
  --model openai/gpt-image-2 \
  --aspect-ratio 3:2 \
  --output cabin-transparent.png

pixgen create sends one prompt to OpenAI, Gemini, and OpenRouter at once and saves each result locally

Combine reference images with a prompt:

pixgen create "Combine the product and visual style" \
  --group product-hero \
  --reference product.png \
  --reference style.png \
  --output campaign.png

pixgen edit removes the background from cabin.png and writes cabin-cutout.png

Local image optimisation

Create common website-ready variants from a local image with Pillow:

pixgen optimize photo.jpg --web

See the image optimisation guide for custom sizes, format and quality options, dry runs, and output handling.

Provider-native commands

Each provider command exposes that provider's native Pydantic parameters as typed options, and targets one provider-local model. It uses the same preflight, output, timeout, variant, and JSON rendering as the shared commands.

pixgen create openai "A modern cabin beside a Norwegian fjord" \
  --model gpt-image-2 \
  --quality high \
  --size 1536x1024 \
  --output cabin.png

pixgen create gemini "A modern cabin beside a Norwegian fjord" \
  --model gemini-3.1-flash-image \
  --aspect-ratio 16:9 \
  --output cabin.png

pixgen create openrouter "A modern cabin beside a Norwegian fjord" \
  --model google/gemini-3.1-flash-image \
  --resolution 2K \
  --aspect-ratio 16:9 \
  --output cabin.png

pixgen edit openrouter "Remove the background" \
  --image cabin.png \
  --model openai/gpt-image-2.5-sunburst \
  --quality high \
  --output cabin-transparent.png

OpenRouter commands accept either the upstream slug or the full Pixgen ID after --model. Groups only apply to root create. Provider-native commands keep their own options.

Model groups

Save a line-up of models once, then reuse it with --group:

pixgen group create product-hero \
  --model openai/gpt-image-2 \
  --model gemini/gemini-3.1-flash-image \
  --description "Models suited to product hero images" \
  --tag product \
  --tag marketing

pixgen group list        # or: pixgen group ls

In an interactive terminal, leave out --model to fuzzy-search and multi-select models, then enter a description and optional tags. Group names must be new, and group create never replaces an existing group. Models are validated locally and the group is written to the resolved TOML configuration. No provider credentials are used.

Model discovery

pixgen model list and pixgen model get <provider/model> work offline. model list shows an interactive table by default, a grouped view with --tree, or machine-readable output with --json. model get reports native parameter schemas and supported shared aspect ratios.

pixgen model list --tree works offline, then pixgen group create and group ls save and show a model group

Shell completion

Enable completion for bash, zsh, or fish:

pixgen --install-completion

Restart the shell, or source its RC file, for completion to take effect. See the cyclopts shell completion docs for manual installation and troubleshooting.

Configuration

Set API keys in the environment. Prefixed and unprefixed names both work:

OPENAI_API_KEY=sk-...        # or PIXGEN_OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...           # or PIXGEN_GEMINI_API_KEY=...
OPENROUTER_API_KEY=...       # or PIXGEN_OPENROUTER_API_KEY=...

Optional settings use the PIXGEN_ prefix and nest with __:

PIXGEN_CONFIG=/absolute/path/to/pixgen.toml
PIXGEN_GENERATION__MAX_PARALLEL_REQUESTS=4
PIXGEN_GENERATION__MAX_VARIANTS=10
PIXGEN_GENERATION__MAX_JOBS=10
PIXGEN_GENERATION__REQUEST_TIMEOUT_SECONDS=300
PIXGEN_GENERATION__REQUEST_RETRIES=0
PIXGEN_GENERATION__OUTPUT_DIR=./output

generation.request_retries sets the number of automatic retries per provider request and defaults to 0. Retrying timed-out image generation requests can produce duplicate images if a provider completed the request but its response was lost. Retry behaviour depends on the provider's transport; for example, OpenAI and OpenRouter retry connection errors, while Gemini also retries transient API errors and timeouts.

Reusable create-only model groups live in the TOML configuration:

[groups.product-hero]
description = "Models suited to product hero images"
tags = ["product", "marketing"]
models = [
  "openai/gpt-image-2",
  "gemini/gemini-3.1-flash-image",
]

description and tags are presentation metadata shown by group list. They do not affect generation.

Roadmap

Not in Pixgen yet: video generation, OS-keyring credentials, UUIDv7 history, resumable background video, external provider plugins, MCP, workflow orchestration, local inference, and group show.

Development

The project uses uv, just, Ruff, Pyrefly, pytest, and pre-commit:

just init        # uv sync + install hooks
just lint        # ruff check --fix + ruff format
just type-check  # pyrefly
just test        # pytest
just check       # full hook suite

The terminal animations in this README are rendered by docs/demo/render_demos.py. It needs no API keys and requires ffmpeg:

uv run python docs/demo/render_demos.py           # all demos
uv run python docs/demo/render_demos.py create    # just one
Releasing

Releases are published to PyPI by the Release workflow when a version tag is pushed. Publishing uses PyPI trusted publishing (OIDC), so no token is stored, and uploads include PEP 740 attestations.

just build              # build sdist and wheel into dist/
just release minor      # bump (patch|minor|major), commit, and tag vX.Y.Z
git push origin main vX.Y.Z

The workflow runs the CI checks, builds with uv build --no-sources, smoke tests the wheel and source distribution, then publishes from the pypi environment once it is approved. The tag must match the version in pyproject.toml, or the workflow fails before building. See Releasing for the one-time PyPI setup and troubleshooting.

Documentation

License

MIT. See LICENSE.

Metadata

Release files for pixgen 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pixgen 0.2.1
File Size Uploaded Provenance Actions
pixgen-0.2.1.tar.gz 60.9 kB With provenance Details for pixgen-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pixgen 0.2.1
File Interpreter ABI Platform Actions
pixgen-0.2.1-py3-none-any.whl Python 3 none any Details for pixgen-0.2.1-py3-none-any.whl

Total release size: 144.0 kB

Release files / pixgen-0.2.1.tar.gz

Download URL pixgen-0.2.1.tar.gz
Size 60.9 kB
Tags Source
SHA-256 checksum
How to use checksums
42dd3811034753b718e3c5ec0a4124fbacb4e54928291175eca4fb990492c174
BLAKE2b-256 checksum
How to use checksums
13abbefe61293ca1994b8f00acea79b430766011fd9b588f6225ef1532730f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / pixgen-0.2.1-py3-none-any.whl

Download URL pixgen-0.2.1-py3-none-any.whl
Size 83.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bd8f5395aebaae51ced622463dd406935de34a4e9bea07ed55e67ab0cc26d29
BLAKE2b-256 checksum
How to use checksums
583ac79f285b13db4e4eaf770c54567b1c1871bb1fe9a04b2ac7f4b943a8f938
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for pixgen 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pixgen-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page