How to Use ODS for Image Generation: Stable Diffusion and ComfyUI Setup
ODS (Open-Source Distributed Stack) provides containerized AI services for local image generation through extensions like Stable Diffusion Forge and ComfyUI, exposing stable REST APIs on localhost without requiring manual port configuration.
ODS (Open-Source Distributed Stack) simplifies local AI deployment by orchestrating containerized services through Docker Compose. When using ODS for image generation, you can choose between Stable Diffusion Forge and ComfyUI extensions, both delivering version-agnostic APIs that remain stable across releases. This guide walks through the complete setup process—from installation to API calls—using the actual source implementation in the Osmantic/ODS repository.
Understanding the ODS Architecture for Image Generation
ODS builds its runtime environment from a base compose file (ods/docker-compose.base.yml) merged with GPU-specific overlays (e.g., ods/docker-compose.amd.yml). Each image generation extension contributes its own compose fragment, such as ods/extensions/services/forge/compose.yaml for Stable Diffusion Forge or ods/extensions/services/comfyui/compose.yaml for ComfyUI.
The system creates a unified Docker network named ods that allows seamless inter-service communication. When enabled, these services expose REST endpoints on localhost without additional port-forwarding, with API contracts defined in their respective manifest files (manifest.yaml).
Installing and Enabling Image Generation Services
Installing ODS
Begin by running the platform-specific installer script (install.sh for Linux/macOS or install.ps1 for Windows). The installer automatically detects your GPU tier and selects the appropriate Docker overlay to ensure proper CUDA or ROCm support. This phase establishes the base infrastructure in ods/docker-compose.base.yml before any image generation capabilities are added.
Enabling Extensions
Activate your preferred image generation backend using the CLI or Dashboard UI:
- Stable Diffusion Forge: Run
ods enable forgeor select Stable Diffusion Forge in Extensions → Dashboard UI - ComfyUI: Run
ods enable comfyuivia CLI
Enabling an extension copies its compose fragment into the active stack. The manifest files at ods/extensions/services/forge/manifest.yaml and ods/extensions/services/comfyui/manifest.yaml define the service metadata, default ports, and health check endpoints.
Starting the Stack and Verifying Health
Launch the containers with:
ods up
Alternatively, use the standard Docker Compose command:
docker compose up -d
The installer executes a health-check phase defined in ods/installers/phases/12-health.sh to verify that image generation services are reachable before completing installation. This ensures the containers are fully initialized before accepting API requests.
Generating Images via the REST API
ODS exposes stable, version-agnostic endpoints that follow the de-facto standard stable-diffusion API specification. Because services run inside the ods Docker network with published ports, you can reach them directly on localhost.
Using Stable Diffusion Forge
The Forge service runs on port 7860 and provides the standard /sdapi/v1/txt2img endpoint. The container uses the image ghcr.io/ai-dock/stable-diffusion-webui-forge with GPU acceleration configured through the compose overlay.
Send a text-to-image request to:
http://localhost:7860/sdapi/v1/txt2img
Additional endpoints include /sdapi/v1/img2img for image-to-image generation and /sdapi/v1/options for configuration management, as documented in the upstream project.
Using ComfyUI
ComfyUI operates on port 8188 using the image ghcr.io/comfyanonymous/ComfyUI:latest. Unlike Forge, ComfyUI accepts prompt graphs via the /prompt endpoint:
http://localhost:8188/prompt
This endpoint expects JSON payloads containing node-based workflow definitions rather than simple parameter objects.
Complete Code Examples
cURL Examples
Generate an image with Stable Diffusion Forge:
curl -X POST http://localhost:7860/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt":"a futuristic city at sunrise, ultra-realistic",
"steps":30,
"cfg_scale":7,
"width":512,
"height":512,
"sampler_name":"Euler a"
}' \
--output output.png
For ComfyUI, send a prompt graph:
curl -X POST http://localhost:8188/prompt \
-H "Content-Type: application/json" \
-d '{
"prompt": [
{"type":"KSampler","inputs":{"seed":12345,"steps":30,"cfg":7,"sampler_name":"euler_a"}},
{"type":"CLIPTextEncode","inputs":{"text":"a dreamy forest with mist"}}
]
}' \
--output comfy_output.png
Python Examples
Generate images programmatically with Forge:
import requests
payload = {
"prompt": "a cyberpunk street, neon lights, detailed",
"steps": 25,
"cfg_scale": 8,
"width": 512,
"height": 512,
"sampler_name": "Euler a"
}
resp = requests.post(
"http://localhost:7860/sdapi/v1/txt2img",
json=payload,
timeout=120
)
resp.raise_for_status()
with open("generated.png", "wb") as f:
f.write(resp.content)
Summary
- ODS for image generation relies on Docker Compose fragments defined in
ods/extensions/services/forge/compose.yamlandods/extensions/services/comfyui/compose.yaml - Enable services via
ods enable forgeorods enable comfyui, then start withods up - The installer validates health through
ods/installers/phases/12-health.shbefore completing - Stable Diffusion Forge exposes
/sdapi/v1/txt2imgon port 7860, while ComfyUI uses/prompton port 8188 - Both services maintain stable API contracts across releases, ensuring scripts remain compatible with future model updates
Frequently Asked Questions
What GPU support does ODS provide for image generation?
ODS automatically detects your hardware tier during installation and applies the appropriate Docker overlay, such as ods/docker-compose.amd.yml for AMD GPUs or NVIDIA CUDA configurations. The compose fragments in ods/extensions/services/forge/compose.yaml mount the correct drivers and runtime libraries for your specific GPU architecture.
How do I switch between Stable Diffusion Forge and ComfyUI?
You can enable both services simultaneously since they operate on different ports (7860 and 8188 respectively). Use ods enable forge and ods enable comfyui to activate each extension, then run ods up to rebuild the stack. The unified ods network allows both services to coexist without port conflicts.
Does ODS modify the upstream API endpoints?
No, ODS does not modify the upstream API contracts. The services expose endpoints exactly as implemented in their respective projects (e.g., /sdapi/v1/txt2img for Forge). ODS only guarantees network stability and container orchestration, ensuring endpoints remain reachable on localhost without manual port-forwarding configuration.
Where are the manifest files located for image generation services?
Each extension stores its metadata in a manifest.yaml file. For Stable Diffusion Forge, this is ods/extensions/services/forge/manifest.yaml. For ComfyUI, it is ods/extensions/services/comfyui/manifest.yaml. These files define service IDs, exposed ports, GPU overlay requirements, and health check endpoints used by the installer.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →