Skip to main content

Unified multi-provider AI image generation library (Gemini, OpenAI, xAI)

Project description

pixbridge

CI License: Apache 2.0 Python 3.11+

Multi-provider AI image generation library supporting Gemini, OpenAI, and xAI.

Features

  • Unified ImageClient API across providers
  • Image generation from structured YAML prompts
  • Style transfer (Gemini)
  • Reference image support for identity consistency (Gemini)
  • Consistency checking (generate N images from the same prompt for comparison)
  • Image integrity checks (transparency, corruption, truncation)
  • Thread-safe usage logging (JSONL)

Setup

uv sync

CLI

pixbridge providers                          # List available providers
pixbridge generate prompt.yaml               # Generate from YAML prompt
pixbridge style-transfer img.png --style anime-dark
pixbridge consistency-check anime-dark -n 5
pixbridge check output/                      # Check image integrity

Usage as library

from pixbridge.client import ImageClient
from pixbridge.models import ImagePrompt, GenerationNotes

client = ImageClient(provider="gemini")
prompt = ImagePrompt(
    full_prompt="A mountain landscape at sunset",
    generation_notes=GenerationNotes(
        aspect_ratio="16:9",
        key_requirements=["photorealistic"],
    ),
)
path = client.generate_image(prompt, output_dir="output")

Providers

Provider Models Style Transfer Reference Images
Gemini gemini-3-pro-image-preview yes yes
OpenAI gpt-image-2 (default), gpt-image-1.5, gpt-image-1, gpt-image-1-mini no no
xAI grok-imagine-image no no

Any model can be selected at runtime with --model. The CLI also accepts size presets 720p, 1080p, 2160p, or a raw WxH string (resolved per-provider). OpenAI (gpt-image-2) validates sizes by rule — any WxH where both dimensions are divisible by 16, the ratio is within [1:3, 3:1], and max(W, H) ≤ 3840 — so true 9:16 (1152x2048) and 16:9 (2048x1152) work; 1024x1024, 1024x1536, 1536x1024, 2560x1440, 3840x2160 are recommended values surfaced for autocompletion.

Provider capability surface

Each provider exposes a uniform capability surface via provider.capabilities (a ProviderCapabilities), so callers can reason about size rules without branching on the provider name:

Method Returns OpenAI Gemini / Vertex xAI
validate_size(size) raises ValueError if invalid rule-based (÷16, ratio, max-dim) must be 1K/2K no-op (unconstrained)
recommended_sizes() list[str] for docs/autocomplete 7 sizes incl. true 9:16/16:9 ["1K", "2K"] []
aspect_to_size(ratio) str | None (named ratio → WxH) e.g. "9:16" → "1152x2048" None (ratio passed to API) None
max_dim() int | None (px ceiling) 3840 None None
native_size(w, h) str | None (raw WxH → native size) validates + passes WxH through buckets to 1K/2K None

To read a provider's capabilities without instantiating it or supplying credentials (e.g. for offline size resolution), use the registry:

from pixbridge.providers import get_capabilities

caps = get_capabilities("openai")   # also "gemini", "xai", "vertex"; None if unknown
caps.validate_size("1152x2048")     # passes; raises ValueError on invalid sizes
caps.native_size(2048, 1152)        # -> "2048x1152"

get_capabilities("vertex") returns Gemini's surface (Vertex shares it) and never requires GOOGLE_CLOUD_PROJECT.

Style presets

Style-transfer presets are Markdown files looked up by name. Pass --style (or the style argument) as a preset name (anime-dark), a subdir-qualified name (anime/anime-dark), a path to a .md file, or raw prompt text.

The preset directory resolves in this order: an explicit ImageClient(style_presets_dir=...) / --styles-dir argument, then the PIXBRIDGE_STYLE_PRESETS_DIR environment variable, then prompts/style-transfer relative to the current working directory. When none of these contain the named preset, the value is treated as raw prompt text.

export PIXBRIDGE_STYLE_PRESETS_DIR=~/my-styles
pixbridge style-transfer img.png --style anime-dark
pixbridge style-transfer img.png --style anime-dark --styles-dir ./other-styles
client = ImageClient(provider="gemini", style_presets_dir="~/my-styles")

Configuration

Per-provider defaults live in model_config.yaml (auto-discovered from the current working directory, or pass --config path/to/file.yaml). Resolution order: --model CLI flag > config file > hardcoded provider default.

providers:
  openai:
    default_model: gpt-image-2
  gemini:
    default_model: gemini-3.1-flash-image-preview

Testing

just test

Contributing

Contributions are welcome — see CONTRIBUTING.md for the development setup and PR guidelines. To report a security issue, see SECURITY.md.

License

Licensed under the Apache License 2.0. See the NOTICE file for attribution requirements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixbridge-0.1.1.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixbridge-0.1.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file pixbridge-0.1.1.tar.gz.

File metadata

  • Download URL: pixbridge-0.1.1.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pixbridge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a063fd9c304c39e944b576d8ab699ada2fe3606ec1aef2cd0a3005698a6483df
MD5 88211174a5ab0109e43c2add07473692
BLAKE2b-256 a6193e20602f808c12d2f7fecc8edb70df4980257c95c49c88fe9f5e098f1854

See more details on using hashes here.

File details

Details for the file pixbridge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pixbridge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pixbridge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 96657313728ad79a3aa63b2cb7061d32f5b04ed2652b90e895233bb83666ee48
MD5 f31ec10ea722ca0c8ed8bb0fee896407
BLAKE2b-256 91cd78d8ddfcf82d73376c45d436d26af9cc84e0d7c57444a8193a1c8b791a17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page