🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

ImageGen

from ai_infra.imagegen import ImageGen
View source
ai_infra.imagegen

Provider-agnostic image generation. Supports OpenAI (DALL-E), Google (Imagen), Stability AI, and Replicate. Auto-detects provider from environment variables if not specified.

python
# Zero-config: auto-detects from env vars
    gen = ImageGen()
    images = gen.generate("A sunset over mountains")

    # Explicit provider and model
    gen = ImageGen(provider="google", model="imagen-4.0-generate-001")
    images = gen.generate("A futuristic city", n=2)

    # Save generated image
    images[0].save("output.png")

Environment Variables: - OPENAI_API_KEY: For OpenAI DALL-E - GOOGLE_API_KEY or GEMINI_API_KEY: For Google Imagen - STABILITY_API_KEY: For Stability AI - REPLICATE_API_TOKEN: For Replicate

Constructor
ImageGen(provider: str | None = None, model: str | None = None, api_key: str | None = None, kwargs: Any = {}) -> None
ParameterTypeDefaultDescription
providerstr|NoneNoneProvider name ("openai", "google", "stability", "replicate"). Auto-detected from env vars if not specified.
modelstr|NoneNoneModel name. Uses provider default if not specified.
api_keystr|NoneNoneAPI key. Uses env var if not specified.
kwargsAny{}—

Methods

On This Page

Constructoragenerateasynceditgeneratelist_modelsstaticlist_providersstaticvariations