Install
openclaw skills install gpt-image-2-generationGenerate images from text prompts using the WellAPI gpt-image-2 model. Use this skill whenever the user asks to create, draw, render, or generate an image, picture, illustration, artwork, photo, or visual from a textual description. Handles API key onboarding, authenticated requests to https://wellapi.ai/v1/images/generations, and decoding the returned base64 image into a local file.
openclaw skills install gpt-image-2-generationGenerate images from natural-language prompts using the gpt-image-2 model hosted at WellAPI. The skill calls POST https://wellapi.ai/v1/images/generations, decodes the returned b64_json, and writes the image to disk.
Trigger this skill when the user asks for things like:
If the user asks for image editing (in-painting, variations, etc.), this skill currently only covers text-to-image generation; tell the user so.
WELLAPI_API_KEY is set, it will be used.~/.config/gpt-image-2-generation/config.json%USERPROFILE%\.config\gpt-image-2-generation\config.jsonWhen no key can be located, before making any API call show the user this short prompt verbatim (translate to the user's language if appropriate) — do not expand it into multiple "options / methods", do not show shell commands, do not ask follow-up questions like "do you already have a key":
请粘贴你的 WellAPI API Key。 如果还没有,请前往 https://wellapi.ai/register?channel=c_qqn3vdvc 注册后领取免费 API Key。
Please paste your WellAPI API Key. If you don't have one yet, register at https://wellapi.ai/register?channel=c_qqn3vdvc to get a free key.
Wait for the user to reply with the key, then call the helper script to securely store it:
python3 scripts/setup_api_key.py
The script reads the key from stdin and persists it to the per-user config file with 0600 permissions. Never echo or log the full key after it is captured. Do not describe environment-variable alternatives unless the user explicitly asks.
Use the bundled script scripts/generate_image.py. It accepts CLI arguments, builds the request, sends it with Authorization: Bearer <key>, decodes the base64 image, and writes the file.
| Flag | Meaning |
|---|---|
--prompt | The text description of the image to generate. |
| Flag | Default | Allowed values |
|---|---|---|
--n | 1 | integer, number of images |
--size | 1024x1024 | e.g. 512x512, 1024x1024, 1024x1536, 1536x1024 |
--quality | low | low, medium, high |
--format | jpeg | jpeg, png, webp |
--model | gpt-image-2 | model name |
--output | ./gpt-image-2_<timestamp>.<format> | output file path. When --n > 1, an index suffix is added. |
--api-key | (auto) | overrides env / config file |
--timeout | 600 (or $WELLAPI_TIMEOUT) | HTTP timeout in seconds. The endpoint is synchronous and a single image typically takes 1–3 minutes, so keep this generous. |
# Minimal
python3 scripts/generate_image.py --prompt "大海"
# Custom size + format + output path
python3 scripts/generate_image.py \
--prompt "A futuristic city skyline at dusk, cyberpunk style" \
--size 1024x1024 \
--quality high \
--format png \
--output ./city.png
The script prints the absolute path(s) of the saved image(s) on success and exits non-zero on failure.
Request body sent to https://wellapi.ai/v1/images/generations:
{
"model": "gpt-image-2",
"prompt": "大海",
"n": 1,
"size": "1024x1024",
"quality": "low",
"format": "jpeg"
}
Headers
Authorization: Bearer <WELLAPI_API_KEY>
Content-Type: application/json
Response (the image is in data[i].b64_json):
{
"created": 1778236581,
"data": [{ "b64_json": "iVBORw0KGg..." }],
"output_format": "png",
"quality": "low",
"size": "1024x1024",
"usage": { "input_tokens": 8, "output_tokens": 196, "total_tokens": 204 }
}
The skill base64-decodes each b64_json entry and writes the bytes to disk using output_format (or the requested --format) as the file extension.
prompt, and any explicit size, quality, format, n.scripts/setup_api_key.py).scripts/generate_image.py with the parsed arguments. The endpoint is synchronous and commonly takes 1–3 minutes — wait for the script to return; do not abort or retry early. If your tool runner has its own command timeout, raise it (e.g. ≥ 600s) before invoking the script.--timeout / set WELLAPI_TIMEOUT to a larger value.Whenever WellAPI returns a non-200 status (typical examples: 400, 401, 403, 404, 429, 5xx), the script appends a remediation hint to its error output. Always relay this hint to the user verbatim — the most common root cause is that the API Key's group does not have available capacity for gpt-image-2.
Tell the user (translate to their language if needed):
接口返回非 200 状态码,可能是该 API Key 所属分组资源不足。请登录 https://wellapi.ai 的「API 令牌管理」,把此 API Key 的分组修改为 「官转OpenAI分组」 或 「优质官转OpenAI分组」,保存后重新让我生成图片即可。
Only after the user confirms they have switched groups (or explicitly asks to retry) should you re-invoke scripts/generate_image.py. Do not silently retry on 4xx/5xx — the same group will fail again.
SKILL.md — this file (metadata + instructions)scripts/generate_image.py — performs the generationscripts/setup_api_key.py — interactive helper to store the API keyscripts/api_key.py — shared helpers for locating/loading the keyREADME.md — marketplace listing0600 permissions and is never committed, logged, or echoed.https://wellapi.ai.