Production-ready FastAPI image generation service powered by diffusers with 4-step distilled models.
| Model ID | Steps | VRAM | Description |
|---|---|---|---|
qwen-2512-fp8-4step | 4 | ~20GB | Qwen FP8 with 4-step distillation (default) |
flux-klein-4b | 4 | ~13GB | FLUX.2 Klein 4B distilled |
qwen-2512-fp8-4step:
qwen_image_2512_fp8_e4m3fn_scaled_4steps_v1.0.safetensors (20.5 GB)flux-klein-4b:
Qwen Lightning:
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 1328x1328 |
| 16:9 | 1664x928 |
| 9:16 | 928x1664 |
FLUX Klein:
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 1024x1024 |
| 16:9 | 1280x720 |
| 9:16 | 720x1280 |
# Clone repository
git clone https://github.com/gordo-v1su4/image-gen-endpoint.git
cd image-gen-endpoint
# Build and run with GPU support
docker compose up --build -d
# View logs
docker compose logs -f
Models download automatically from HuggingFace on first use (~30GB total).
Generate with Qwen Lightning (default):
curl -X POST https://your-server.com/v1/images/create \
-H "Content-Type: application/json" \
-d '{
"prompt": "A majestic lion in the African savanna at golden hour",
"width": 1328,
"height": 1328,
"steps": 4,
"guidance_scale": 1.0
}'
Generate with FLUX Klein:
curl -X POST https://your-server.com/v1/images/create \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cyberpunk cityscape at night",
"model": "flux-klein-4b",
"width": 1024,
"height": 1024,
"steps": 4
}'
Response Format (OpenAI-compatible):
{
"data": [{"b64_json": "...base64 encoded image..."}],
"created": 1706500000,
"model": "qwen-2512-fp8-4step"
}
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check with GPU info |
/v1/images/create | POST | Generate image from prompt |
/v1/images/edit | POST | Edit image with AI |
/docs | GET | Swagger UI documentation |
/test-ui | GET | Web-based test interface |
# Install NVIDIA Container Toolkit
sudo apt-get install nvidia-container-toolkit
# Configure Docker runtime
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Verify GPU access
docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi
| Variable | Default | Description |
|---|---|---|
HF_HOME | /opt/models/huggingface | HuggingFace cache directory |
CUDA_VISIBLE_DEVICES | 0 | GPU device to use |
┌─────────────────────────────────────┐
│ FastAPI Application │
├─────────────────────────────────────┤
│ Model Manager │
│ ┌─────────────┐ ┌───────────────┐ │
│ │Qwen Lightning│ │ FLUX Klein │ │
│ │ (diffusers) │ │ (diffusers) │ │
│ └─────────────┘ └───────────────┘ │
├─────────────────────────────────────┤
│ HuggingFace Hub │
│ (automatic model caching) │
└─────────────────────────────────────┘
Apache 2.0 - See LICENSE for details.
77 commits
20 commits
Python
32.3%
HTML
29.2%
JavaScript
23.3%
Shell
5.6%
CSS
3.9%
Dockerfile
3.0%
MDX
2.8%
Production-ready FastAPI image generation service powered by diffusers with 4-step distilled models.
| Model ID | Steps | VRAM | Description |
|---|---|---|---|
qwen-2512-fp8-4step | 4 | ~20GB | Qwen FP8 with 4-step distillation (default) |
flux-klein-4b | 4 | ~13GB | FLUX.2 Klein 4B distilled |
qwen-2512-fp8-4step:
qwen_image_2512_fp8_e4m3fn_scaled_4steps_v1.0.safetensors (20.5 GB)flux-klein-4b:
Qwen Lightning:
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 1328x1328 |
| 16:9 | 1664x928 |
| 9:16 | 928x1664 |
FLUX Klein:
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 1024x1024 |
| 16:9 | 1280x720 |
| 9:16 | 720x1280 |
# Clone repository
git clone https://github.com/gordo-v1su4/image-gen-endpoint.git
cd image-gen-endpoint
# Build and run with GPU support
docker compose up --build -d
# View logs
docker compose logs -f
Models download automatically from HuggingFace on first use (~30GB total).
Generate with Qwen Lightning (default):
curl -X POST https://your-server.com/v1/images/create \
-H "Content-Type: application/json" \
-d '{
"prompt": "A majestic lion in the African savanna at golden hour",
"width": 1328,
"height": 1328,
"steps": 4,
"guidance_scale": 1.0
}'
Generate with FLUX Klein:
curl -X POST https://your-server.com/v1/images/create \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cyberpunk cityscape at night",
"model": "flux-klein-4b",
"width": 1024,
"height": 1024,
"steps": 4
}'
Response Format (OpenAI-compatible):
{
"data": [{"b64_json": "...base64 encoded image..."}],
"created": 1706500000,
"model": "qwen-2512-fp8-4step"
}
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check with GPU info |
/v1/images/create | POST | Generate image from prompt |
/v1/images/edit | POST | Edit image with AI |
/docs | GET | Swagger UI documentation |
/test-ui | GET | Web-based test interface |
# Install NVIDIA Container Toolkit
sudo apt-get install nvidia-container-toolkit
# Configure Docker runtime
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Verify GPU access
docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi
| Variable | Default | Description |
|---|---|---|
HF_HOME | /opt/models/huggingface | HuggingFace cache directory |
CUDA_VISIBLE_DEVICES | 0 | GPU device to use |
┌─────────────────────────────────────┐
│ FastAPI Application │
├─────────────────────────────────────┤
│ Model Manager │
│ ┌─────────────┐ ┌───────────────┐ │
│ │Qwen Lightning│ │ FLUX Klein │ │
│ │ (diffusers) │ │ (diffusers) │ │
│ └─────────────┘ └───────────────┘ │
├─────────────────────────────────────┤
│ HuggingFace Hub │
│ (automatic model caching) │
└─────────────────────────────────────┘
Apache 2.0 - See LICENSE for details.
77 commits
20 commits
Python
32.3%
HTML
29.2%
JavaScript
23.3%
Shell
5.6%
CSS
3.9%
Dockerfile
3.0%
MDX
2.8%