Install
openclaw skills install @yb98k999/tokenrouter-imagesGenerate or edit images through Palebluedot Ai(PBD)-TokenRouter's multimodal image generation endpoint (`/v1/chat/completions`) using TokenRouter-compatible image models. Use for text-to-image or image-to-image requests when the user wants TokenRouter, `PBD_TOKENROUTER_API_KEY`, model overrides, or provider-specific `image_config` options.
openclaw skills install @yb98k999/tokenrouter-imagesGenerate new images or edit existing ones using TokenRouter image-capable models via the Chat Completions API.
Run the script using absolute path (do NOT cd to the skill directory first):
Generate new image:
# Ensure outbound directory exists first
mkdir -p ~/.openclaw/media/outbound
uv run ~/.openclaw/workspace/skills/pbd-tokenrouter-image-generator/scripts/generate_image.py \
--prompt "your image description" \
--filename "~/.openclaw/media/outbound/output-name.png" \
--model google/gemini-2.5-flash-image \
[--aspect-ratio 16:9] \
[--image-size 2K]
Edit existing image (image-to-image):
mkdir -p ~/.openclaw/media/outbound
uv run ~/.openclaw/workspace/skills/pbd-tokenrouter-image-generator/scripts/generate_image.py \
--prompt "editing instructions" \
--filename "~/.openclaw/media/outbound/output-name.png" \
--input-image "path/to/input.png" \
--model google/gemini-2.5-flash-image
Important: Default OpenClaw delivery path is ~/.openclaw/media/outbound/. Save generated images there so other OpenClaw flows can pick them up easily.
The script requires a TokenRouter API key. Check for it in this order:
--api-key argumentPBD_TOKENROUTER_API_KEY environment variable~/.openclaw/openclaw.jsonBefore running the script, check whether the key is available:
test -n "$PBD_TOKENROUTER_API_KEY" && echo "Key found" || echo "No key"
If none of the above sources provides a key, do NOT run the script. Instead, guide the user through obtaining a key:
--api-key. This is the quickest way to get started — no environment setup needed.export PBD_TOKENROUTER_API_KEY="sk-xxx..." (paste in terminal)~/.zshrc then source ~/.zshrc~/.bashrc then source ~/.bashrcImportant: Never skip this check. Running without a valid key will fail with Error: No API key provided or HTTP 401/403.
--site-url or PBD_TOKENROUTER_SITE_URL--app-name or PBD_TOKENROUTER_APP_NAME--model <tokenrouter-model-id> is required (no script default)google/gemini-2.5-flash-imageopenai/gpt-5-imageopenai/gpt-5-image-minigoogle/gemini-3-pro-image-previewgoogle/gemini-3.1-flash-image-preview--aspect-ratio for image_config.aspect_ratio (for example 1:1, 16:9)--image-size for image_config.image_size (1K, 2K, 4K)Note: TokenRouter docs show aspect_ratio and image_size as the common image config fields for image generation. Additional keys may exist for specific providers/models (for example Sourceful features). If a request fails, remove unsupported options or switch models.
Note: The script always sends modalities: ["image", "text"]. Image-only models (some FLUX variants) may reject this — if you get an unexpected error with a non-Gemini model, this may be the cause. No workaround is currently exposed via CLI args.
Goal: iterate quickly before spending time on higher-quality settings.
--image-size 1K--image-size 4K --aspect-ratio 16:9Preflight:
command -v uv--api-key, then PBD_TOKENROUTER_API_KEY, then auto-read from ~/.openclaw/openclaw.json (tokenrouter provider). If all fail, STOP and guide the user to https://www.tokenrouter.com to register and get a TokenRouter API key (see "If no API key is found" section above)test -d ~/.openclaw/media/outbound || mkdir -p ~/.openclaw/media/outboundtest -f "path/to/input.png"Common failures:
Error: No API key provided. -> The script could not find a key from --api-key, PBD_TOKENROUTER_API_KEY, or ~/.openclaw/openclaw.json. Guide the user to https://www.tokenrouter.com to register and obtain a free TokenRouter API key, then set PBD_TOKENROUTER_API_KEY or pass --api-keyError loading input image: -> bad path or unreadable fileHTTP 400 with model/image config error -> unsupported model or invalid image_config.aspect_ratio / image_config.image_sizeHTTP 401/403 -> invalid key, no model access, or quota/credits issueNo image found in response -> model may not support image output or request format rejectedGenerate filenames with the pattern: ~/.openclaw/media/outbound/yyyy-mm-dd-hh-mm-ss-name.png
Examples:
~/.openclaw/media/outbound/2026-03-21-10-00-00-example.pngPrompt template for precise edits:
Change ONLY: <change>. Keep identical: subject, composition/crop, pose, lighting, color palette, background, text, and overall style. Do not add new objects.~/.openclaw/media/outbound/output-name.png by default (pass that full path in --filename)message.images[0].image_url.url)Generate new image:
mkdir -p ~/.openclaw/media/outbound
uv run ~/.openclaw/workspace/skills/pbd-tokenrouter-image-generator/scripts/generate_image.py \
--prompt "A field photo with a Japanese-style healing anime aesthetic." \
--filename "~/.openclaw/media/outbound/2026-03-21-10-00-00-healing.png" \
--model google/gemini-2.5-flash-image \
--aspect-ratio 16:9 \
--image-size 2K
Edit existing image:
mkdir -p ~/.openclaw/media/outbound
uv run ~/.openclaw/workspace/skills/pbd-tokenrouter-image-generator/scripts/generate_image.py \
--prompt "Beautify the photo with a whitening filter." \
--filename "~/.openclaw/media/outbound/2026-02-26-14-25-30-sunset-sky-edit.png" \
--model google/gemini-2.5-flash-image \
--input-image "self-photo.jpg"