agentleFS
fajrisilmi12-cyberfajrisilmi12-cyber/hermes-socmed-function/skills/image-gen-9router/SKILL.md

image-gen-9router

Skill20 starsChanged 3 months agoMITView on GitHub

Generate images via 9Router. FLUX, Imagen, DALL-E, SD.

The file

Files
SKILL.md

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

EndpointPurpose
GET /v1/models/imageList available image models (with owned_by provider)
GET /v1/models/info?id=<model_id>Per-model params, capabilities, size enum
POST /v1/images/generationsGenerate image(s)
POST /v1/images/generations?response_format=binaryGenerate 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 3
  • openai/dall-e-3 — OpenAI DALL-E 3
  • cf/@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 / FieldReturns
default (URL response)JSON with data[0].url to a hosted image
?response_format=binaryraw image bytes
response_format: b64_json in bodyJSON 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 Authorization header even though 9Router is local. Without it, returns 401 Invalid API key. The env var name is NINEROUTER_KEY, value typically sk-... 35 chars.
  • Some providers ignore size and n. gemini (nano-banana) and huggingface providers only respect prompt; 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 --list to dump available models.

Reference docs

  • references/upstream-skill.md — full upstream decolua/9router SKILL.md for /v1/images/generations
  • references/model-catalog.md — full model list with owned_by and known params

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.