# Image Gen 9router

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

- **Type:** Skill
- **Install:** `agentstack add skill-fajrisilmi12-cyber-hermes-socmed-function-image-gen-9router`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [fajrisilmi12-cyber](https://agentstack.voostack.com/s/fajrisilmi12-cyber)
- **Installs:** 0
- **Category:** [Content & Media](https://agentstack.voostack.com/c/content-and-media)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [fajrisilmi12-cyber](https://github.com/fajrisilmi12-cyber)
- **Source:** https://github.com/fajrisilmi12-cyber/hermes-socmed-function/tree/main/skills/image-gen-9router

## Install

```sh
agentstack add skill-fajrisilmi12-cyber-hermes-socmed-function-image-gen-9router
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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
```yaml
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=` | 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

```bash
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)

```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:
```bash
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 `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

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [fajrisilmi12-cyber](https://github.com/fajrisilmi12-cyber)
- **Source:** [fajrisilmi12-cyber/hermes-socmed-function](https://github.com/fajrisilmi12-cyber/hermes-socmed-function)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-fajrisilmi12-cyber-hermes-socmed-function-image-gen-9router
- Seller: https://agentstack.voostack.com/s/fajrisilmi12-cyber
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
