AI · Automation 2026 Completed

FLUX Image Generator — Serverless GPU Text-to-Image

Private text-to-image web app: a FastAPI front end sends prompts to FLUX.1-schnell running on a serverless A100 GPU and keeps a gallery of past generations.

Built by Redoan Uzzaman, Full-Stack Developer & AI Engineer.

FLUX Image Generator — Serverless GPU Text-to-Image

Overview

FLUX Image Generator is a compact, self-hosted text-to-image tool. It splits the work into a cheap always-on web tier and an on-demand GPU tier, so there is no need to rent a GPU server around the clock.

How it works

The web tier is a small FastAPI app in a Docker container. It serves a minimal dark UI where you type a prompt and see the result in a gallery. It sits behind HTTP Basic authentication with constant-time credential checks, and it saves each generated image so earlier results stay browsable.

Prompts are forwarded with an API key to a Modal serverless endpoint that runs FLUX.1-schnell on an A100-40GB GPU. Smaller 24 GB GPUs ran out of memory with the model in bfloat16, which drove the GPU choice.

Engineering notes

The model weights are baked into the Modal container image at build time instead of being downloaded at startup, which keeps cold starts far shorter. Warm requests return an image in a few seconds. The GPU scales to zero when idle, so cost tracks actual use. Secrets for the gateway key and the Hugging Face token are kept in Modal's secret store, not in the code. The front end deploys as a standard Docker application behind a reverse proxy with automatic HTTPS.

Key Features

  • FLUX.1-schnell text-to-image on serverless A100 GPUs
  • Lightweight FastAPI front end with a dark gallery UI
  • Persistent history of generated images
  • HTTP Basic auth with constant-time credential comparison
  • Model weights baked into the image for faster cold starts
  • Scale-to-zero GPU backend secured with an API key

Tech Stack

  • Python
  • FastAPI
  • Modal
  • FLUX.1
  • Hugging Face Diffusers
  • Docker
  • httpx

Want something like this built?

Redoan Uzzaman takes on AI, automation and full-stack projects for clients worldwide.