Transform photos into coloring book pages using FLUX and GPT Image APIs. Implement the provider pattern for easy model swapping, and optimize with image pre/post-processing pipelines.
Start learning at learnwithparam.com. Regional pricing available with discounts of up to 60%.
- Image-to-image generation models (FLUX Kontext, GPT Image)
- Provider pattern for multi-model support
- Image pre/post-processing pipelines
- Async polling workflows for long-running generation tasks
- FastAPI - High-performance async Python web framework
- FLUX Kontext Pro - Image-to-image generation via Fireworks AI
- GPT Image - OpenAI's image generation API
- LLM Provider Pattern - Supports Fireworks, OpenRouter, Gemini, OpenAI
- Pillow - Image processing and optimization
- Docker - Containerized development
- Python 3.11+
- uv (installed automatically by
make setup) - An API key from any supported LLM provider
# One command to set up and run
make dev
# Or step by step:
make setup # Create .env and install dependencies
# Edit .env with your API key
make run # Start the FastAPI servermake build # Build the Docker image
make up # Start the container
make logs # View logs
make down # Stop the containerOnce running, open http://localhost:8000/docs for the interactive Swagger UI.
Work through these incrementally to build the full application:
- The "Echo" API - Return an uploaded image as-is to verify the upload pipeline
- The First Conversion - Call FLUX to convert an image to a coloring page
- The Refactored Provider - Extract image generation into the provider pattern
- The Alternative Provider - Add GPT Image as a second provider option
- The Optimizer - Add image pre/post-processing (resize, compress, enhance contrast)
- The Developer (Bonus) - Build a simple frontend to upload and preview results
- The Enhancer (Bonus) - Add prompt engineering for different art styles
make help Show all available commands
make setup Initial setup (create .env, install deps)
make dev Setup and run (one command!)
make run Start FastAPI server
make build Build Docker image
make up Start container
make down Stop container
make clean Remove venv and cache
- Start the course: learnwithparam.com/courses/ai-image-generation
- AI Bootcamp for Software Engineers: learnwithparam.com/ai-bootcamp
- All courses: learnwithparam.com/courses