Imagies image generation
Aigate uses Imagies for local image generation through stable-diffusion.cpp. Set IMAGIES=1 for CPU or IMAGIES_CUDA=1 for NVIDIA. Use model IDs such as local-imagies-cpu-sd-turbo and local-imagies-cuda-sd-turbo with the gateway's OpenAI-compatible image API.
The CPU service and its download job use IMAGIES_GENERATION_CPU_IMAGE, which defaults to psyb0t/imagies:latest. The CUDA pair use IMAGIES_GENERATION_CUDA_IMAGE, which defaults to psyb0t/imagies:latest-cuda. Supply a published tag or build and load those images from the Imagies checkout before starting the profiles. The weights directory is ${DATA_DIR}/imagies (.data/imagies by default). Set DATA_DIR_IMAGIES to use a different host directory. Compose mounts that directory at /data/models/generation. The downloader runs as UID 0 and needs write access to this directory. The generation services mount the same files read-only and need read access as UID 10001.
Reuse weights when upgrading
The CPU and CUDA services share a single weights directory. If your weights already live under .data/imagies, keep using that directory. Otherwise set DATA_DIR_IMAGIES to your existing weights directory before starting the profile. See the upgrading guide for the setting and model ID changes.
Backend endpoints
sdcpp in a backend URL is the Imagies engine ID for stable-diffusion.cpp. Call image generation through Aigate on port 4000. The engine-control routes below live on the internal Imagies services.
| Endpoint | URL | Description |
|---|---|---|
| Image generation | POST /v1/images/generations | OpenAI-compatible, proxied through LiteLLM |
| Load model | PUT /v1/generation/engines/sdcpp/model | Preload a model with its full ID in the JSON model field |
| Unload model | DELETE /v1/generation/engines/sdcpp/model | Free VRAM/RAM |
| Cancel generation | DELETE /v1/generation/engines/sdcpp/active | Kill in-progress generation |
| Status | GET /v1/generation/engines/sdcpp | Resident model, available models, loading and generation state |
| Models list | GET /v1/models | Available models |
| Health | GET /healthz | Generation worker health |
Models
CPU (IMAGIES=1): sd-turbo, sdxl-turbo
CUDA (IMAGIES_CUDA=1): sd-turbo, sdxl-turbo, sdxl-lightning, flux-schnell, juggernaut-xi
Behavior
- Auto-load: sending a generation request loads the model automatically if not loaded
- Model hot-swap: requesting a different model stops the current the generation worker, starts a new one
- Idle timeout: unloads model after 5 minutes of inactivity (configurable)
- Non-blocking: concurrent requests get 503 immediately instead of queuing. The LiteLLM resource manager's hardware lock handles scheduling.
- CUDA resource manager: only one CUDA job (LLM, image gen, TTS, STT) runs at a time. Competing services are unloaded before the request proceeds.
Environment variables
CUDA runtime needs a compatible NVIDIA GPU, driver and NVIDIA Container Toolkit. For a custom build, set CUDA_ARCHITECTURES when running make build-cuda in Imagies and set IMAGIES_GENERATION_CUDA_IMAGE to that image tag. Missing gated FLUX or Juggernaut weights require HF_TOKEN and access to their repositories.
| Variable | Default | Description |
|---|---|---|
IMAGIES_IDLE_TIMEOUT | 5m | CPU idle timeout before auto-unload |
IMAGIES_CUDA_IDLE_TIMEOUT | 5m | CUDA idle timeout before auto-unload |
IMAGIES_MEM_LIMIT | 12g | CPU container memory limit |
IMAGIES_MEMSWAP_LIMIT | 24g | CPU container memory + swap limit |
IMAGIES_CPUS | 4.0 | CPU container CPU limit |
IMAGIES_CUDA_MEM_LIMIT | 12g | CUDA container memory limit |
IMAGIES_CUDA_MEMSWAP_LIMIT | 24g | CUDA container memory + swap limit |
IMAGIES_CUDA_CPUS | 4.0 | CUDA container CPU limit |
IMAGIES_LOAD_TIMEOUT / IMAGIES_CUDA_LOAD_TIMEOUT | 10m | Max time to wait for model load |
IMAGIES_VERBOSE / IMAGIES_CUDA_VERBOSE | false | Debug logging |
IMAGIES_LOG_LEVEL / IMAGIES_CUDA_LOG_LEVEL | info | Log level |