Quickstart
Generating images with lexigram-multimedia-image in minutes — zero API keys required.
Install
Section titled “Install”uv add lexigram-multimedia-imageThe default backend (local-http) needs nothing else. Only pick an extra when you switch backends:
uv add "lexigram-multimedia-image[stability]" # Stability AIuv add "lexigram-multimedia-image[openai]" # OpenAI images APIlexigram-multimedia-image depends on lexigram and lexigram-contracts (installed automatically).
Minimal Working Example
Section titled “Minimal Working Example”import asyncio
from lexigram import Applicationfrom lexigram.contracts.multimedia import ImageProvider, ImageRequestfrom lexigram.multimedia.image import ImageModule
async def main() -> None: async with Application.boot(modules=[ImageModule.configure()]) as app: image: ImageProvider = await app.container.resolve(ImageProvider)
result = await image.generate( ImageRequest(prompt="a cozy cabin in the snow", width=1024, height=1024) )
if result.is_ok(): asset = result.unwrap() # MediaAsset(mime_type, provider, bytes_data, ...) with open("cabin.png", "wb") as f: f.write(asset.bytes_data) else: print(f"generation failed: {result.unwrap_err()}")
if __name__ == "__main__": asyncio.run(main())Point ImageModule.configure() at a server implementing POST /generate
({"prompt", "width", "height", "format"} → image bytes) at
http://localhost:5005, and this runs as-is.
What Just Happened
Section titled “What Just Happened”ImageModule.configure()created aDynamicModulewrapping anImageGenerationProviderand exportingImageProviderandImageGenerationTask.- During
Application.boot()the provider’sregister()ran:ImageConfigwas bound in the container as a singleton.- The
backendfield ("local-http"by default) selectedLocalHttpImageProvider, which was registered as theImageProvider. ImageGenerationTaskwas wired around the same backend for thelexigram-taskssubmit()path.
- Your code resolved
ImageProviderfrom the container and calledgenerate(ImageRequest(...))— the provider returnedResult[MediaAsset, ImageGenerationError], so the failure case was a handledErr, never a silent crash.
Next Steps
Section titled “Next Steps”- Guide — backends, concepts, patterns
- How-Tos — task-oriented recipes
- Configuration — all config keys and env-var overrides