image-gen-9router
Generate images via 9Router. FLUX, Imagen, DALL-E, SD.
fajrisilmi12-cyber · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add fajrisilmi12-cyber/hermes-socmed-function --skill image-gen-9router技能说明
name: image-gen-9router description: Generate images via 9Router. FLUX, Imagen, DALL-E, SD.
Image Generation via 9Router
9Router is a local OpenAI-compatible gateway that exposes image generation
through /v1/images/generations. The same service handles LLM routing (it's
the AGY model Hermes uses) and image gen. Image gen is genuinely free via
the Cloudflare provider.
When to use this skill
- User wants to generate an image from a text prompt
- User wants AI art for an Instagram post / story / reel
- User wants to compare multiple image models (FLUX vs DALL-E vs Imagen)
- User has a working 9Router setup (NINEROUTER_URL + NINEROUTER_KEY in env)
9Router is the same service as AGY
Discovery: cat ~/.hermes/config.yaml shows
model:
base_url: http://localhost:20128/v1
That localhost:20128 is 9Router. Image gen and LLM chat go through the
same gateway, but with different endpoints and different model IDs. The
key (NINEROUTER_KEY) is shared.
Endpoints
| Endpoint | Purpose |
|---|---|
GET /v1/models/image | List available image models (with owned_by provider) |
GET /v1/models/info?id=<model_id> | Per-model params, capabilities, size enum |
POST /v1/images/generations | Generate image(s) |
POST /v1/images/generations?response_format=binary | Generate and return raw bytes |
Auth: Authorization: Bearer $NINEROUTER_KEY (required even for local 9Router).
Discover available models
curl -s $NINEROUTER_URL/v1/models/image \
-H "Authorization: Bearer $NINEROUTER_KEY" | jq '.data[].id'
Common models:
cf/@cf/black-forest-labs/flux-2-klein-4b— small, fast, free (Cloudflare)cf/@cf/black-forest-labs/flux-2-klein-9b— larger, more detail (Cloudflare)cf/@cf/black-forest-labs/flux-2-dev— development build (Cloudflare)gemini/gemini-3-pro-image-preview— Google's Imagen 3openai/dall-e-3— OpenAI DALL-E 3cf/@cf/leonardo/phoenix-1.0— Leonardo Phoenix via Cloudflare
Generate an image (Python)
import httpx, os
resp = httpx.post(
f"{os.environ['NINEROUTER_URL']}/v1/images/generations?response_format=binary",
headers={"Authorization": f"Bearer {os.environ['NINEROUTER_KEY']}"},
json={"model": "cf/@cf/black-forest-labs/flux-2-klein-4b",
"prompt": "your prompt here",
"size": "1024x1024"},
timeout=120,
)
resp.raise_for_status()
open("/tmp/out.png", "wb").write(resp.content)
Or use the template:
python3 templates/generate_image.py "your prompt" -o /tmp/out.png
python3 templates/generate_image.py "your prompt" --post --caption "IG caption"
Response formats
| Query / Field | Returns |
|---|---|
| default (URL response) | JSON with data[0].url to a hosted image |
?response_format=binary | raw image bytes |
response_format: b64_json in body | JSON with data[0].b64_json base64 string |
For posting to social media, use binary and save to disk, then upload to your CDN.
Pitfalls
- Always set
Authorizationheader even though 9Router is local. Without it, returns 401Invalid API key. The env var name isNINEROUTER_KEY, value typicallysk-...35 chars. - Some providers ignore
sizeandn.gemini(nano-banana) andhuggingfaceproviders only respectprompt; they return one image at their own size. codex(gpt-5.4-image) requires ChatGPT Plus/Pro and uses SSE streaming. Not for batch use. Zernio will return 400.- FLUX.2 Klein 4B is small but free — quality is good for stylized art, weaker for photorealistic faces. Use 9B for higher fidelity.
- Image content from Cloudflare is moderated. NSFW prompts return 400 with moderation error. Don't try to bypass.
timeout=120— first call can take 30-60s for cold model load. Set generous timeout.
Available templates
templates/generate_image.py— CLI: generate + optional IG post via Zernio. Uses FLUX.2 Klein 4B by default. Supports--listto dump available models.
Reference docs
references/upstream-skill.md— full upstreamdecolua/9routerSKILL.md for/v1/images/generationsreferences/model-catalog.md— full model list withowned_byand known params