---
name: aitproxy-image
description: Generate or edit images through the user's AITProxy/CLIProxyAPI service at aitproxy.wilsonsliu.cn. Use when the user asks to generate images, draw something, create AI art, text-to-image, image-to-image, edit/modify a reference image, combine images, generate posters, or explicitly mentions AITProxy, NanoBanana, gemini-3.1-flash-image, gpt-image-2, 生图, 文生图, 图生图, 改图, 画一张, or AI 绘画.
---

# AITProxy Image

Use the bundled scripts to call the user's proxy image models. Default base URL is `https://aitproxy.wilsonsliu.cn`.

## Credentials

Use `AITPROXY_API_KEY`. If it is empty, fall back to `AIPROXY_API_KEY` because the user's OpenClaw config already uses that name.

Never print API keys. If both env vars are missing, ask the user to configure one of them.

## Models

Known working image models:

- `gemini-3.1-flash-image`: default. Supports text-to-image, image editing, and multiple reference images through Gemini native `generateContent`.
- `gpt-image-2`: OpenAI-compatible image generation through `/v1/images/generations`.
- `gpt-image-2-2026-04-21`: dated OpenAI image snapshot.

List currently available image models:

```bash
bash "$CODEX_HOME/skills/aitproxy-image/scripts/list-models.sh" | grep -Ei 'image|banana'
```

## Generate

Use the unified script:

```bash
python3 "$CODEX_HOME/skills/aitproxy-image/scripts/generate.py" \
  --model gemini-3.1-flash-image \
  --prompt "一只穿宇航服的橘猫，赛博朋克霓虹背景" \
  --out /tmp/aitproxy-image/cat.png
```

For reference images, pass `--image` one or more times:

```bash
python3 "$CODEX_HOME/skills/aitproxy-image/scripts/generate.py" \
  --model gemini-3.1-flash-image \
  --image /absolute/path/person.jpg \
  --prompt "把这个人换成穿西装的样式，保留面部特征" \
  --out /tmp/aitproxy-image/suit.png
```

For `gpt-image-2`, `--size` and `--n` are supported:

```bash
python3 "$CODEX_HOME/skills/aitproxy-image/scripts/generate.py" \
  --model gpt-image-2 \
  --prompt "watercolor sunset" \
  --size 1024x1024 \
  --n 2 \
  --out /tmp/aitproxy-image/sunset.png
```

After generation, show the image using an absolute Markdown image path:

```markdown
![generated image](/absolute/path/to/image.png)
```

## Troubleshooting

- `401 missing api key`: neither `AITPROXY_API_KEY` nor `AIPROXY_API_KEY` is set.
- `401 invalid api key`: the key is not a client key accepted by `/v1`; use the OpenClaw `AIPROXY_API_KEY` or create a client key in the management UI.
- Model returns text only: use `generate.py`; it forces Gemini image output with `responseModalities`.
- If management-generated keys appear in config but fail on `/v1`, prefer the existing OpenClaw `AIPROXY_API_KEY`; the remote service may not hot-reload newly added keys immediately.
