Add ComfyUI image generation (/v1/images/generations)

OpenAI-compatible image endpoint that proxies to a ComfyUI server: fills a
workflow template with per-request params (prompt/size/n/seed/steps/checkpoint),
submits to ComfyUI, polls history, fetches images, returns OpenAI image shape.

- router.py: _handle_image + fill_workflow + route; env ROUTER_COMFYUI /
  ROUTER_COMFY_CHECKPOINT / ROUTER_COMFY_WORKFLOW
- comfyui-workflow.json: default SD/SDXL text2img template with {{SENTINELS}}
- docs/IMAGES.md + README: config, usage, custom workflows
- verified: templating + clean error when ComfyUI is down; end-to-end pending
  a live ComfyUI

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Joseph Costa
2026-07-05 03:14:51 -05:00
co-authored by Claude Opus 4.8
parent 5bd8142d30
commit 2f95e6be96
4 changed files with 190 additions and 1 deletions
+4
View File
@@ -98,6 +98,8 @@ Everything is environment variables (read by `run.sh` / the router):
| `ROUTER_AUDIO_MODEL` | `gemma4:e4b` | model used for audio/transcription |
| `ROUTER_API_KEY` | *(unset)* | if set, require this Bearer token on /v1 |
| `ROUTER_UNCENSORED_KEY` | *(unset)* | Bearer token that forces the uncensored fleet |
| `ROUTER_COMFYUI` | `http://127.0.0.1:8188` | ComfyUI server for image generation |
| `ROUTER_COMFY_CHECKPOINT` | *(unset)* | checkpoint filename for the default image workflow |
> ⚠️ `ROUTER_OLLAMA` is the router's **client** target — keep it `127.0.0.1`.
> Do **not** confuse it with Ollama's own `OLLAMA_HOST` server-bind variable.
@@ -117,6 +119,7 @@ main thing to customize for your machine. See [docs/ROUTING.md](docs/ROUTING.md)
| POST | `/v1/messages` | Anthropic Messages (Claude Code) → LiteLLM |
| POST | `/v1/audio/transcriptions` | Whisper-shaped speech-to-text |
| POST | `/v1/audio/translations` | speech → English text |
| POST | `/v1/images/generations` | OpenAI-shaped image gen → ComfyUI |
| GET | `/v1/models` | lists route targets |
| GET | `/`, `/api/version`, `/api/tags`, `/api/ps`, POST `/api/show` | Ollama-native probes (so `ollama launch` accepts the router) |
| GET | `/healthz` | liveness |
@@ -126,6 +129,7 @@ main thing to customize for your machine. See [docs/ROUTING.md](docs/ROUTING.md)
- [docs/DEPLOY.md](docs/DEPLOY.md) — run as a service, expose it, tunnels, Caddy
- [docs/ROUTING.md](docs/ROUTING.md) — how routing decides + customizing the map
- [docs/AUDIO.md](docs/AUDIO.md) — voice input & transcription
- [docs/IMAGES.md](docs/IMAGES.md) — image generation via ComfyUI
- [docs/BENCHMARKS.md](docs/BENCHMARKS.md) — the benchmark harnesses & sample results
## Security