Skip to main content

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.

EndpointURLDescription
Image generationPOST /v1/images/generationsOpenAI-compatible, proxied through LiteLLM
Load modelPUT /v1/generation/engines/sdcpp/modelPreload a model with its full ID in the JSON model field
Unload modelDELETE /v1/generation/engines/sdcpp/modelFree VRAM/RAM
Cancel generationDELETE /v1/generation/engines/sdcpp/activeKill in-progress generation
StatusGET /v1/generation/engines/sdcppResident model, available models, loading and generation state
Models listGET /v1/modelsAvailable models
HealthGET /healthzGeneration 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.

VariableDefaultDescription
IMAGIES_IDLE_TIMEOUT5mCPU idle timeout before auto-unload
IMAGIES_CUDA_IDLE_TIMEOUT5mCUDA idle timeout before auto-unload
IMAGIES_MEM_LIMIT12gCPU container memory limit
IMAGIES_MEMSWAP_LIMIT24gCPU container memory + swap limit
IMAGIES_CPUS4.0CPU container CPU limit
IMAGIES_CUDA_MEM_LIMIT12gCUDA container memory limit
IMAGIES_CUDA_MEMSWAP_LIMIT24gCUDA container memory + swap limit
IMAGIES_CUDA_CPUS4.0CUDA container CPU limit
IMAGIES_LOAD_TIMEOUT / IMAGIES_CUDA_LOAD_TIMEOUT10mMax time to wait for model load
IMAGIES_VERBOSE / IMAGIES_CUDA_VERBOSEfalseDebug logging
IMAGIES_LOG_LEVEL / IMAGIES_CUDA_LOG_LEVELinfoLog level