Install
openclaw skills install cpa-gpt-image-2Use a text model such as gpt-5.4 with the image_generation tool over an OpenAI-compatible /v1/responses endpoint, matching the CPA blog example. Do not call gpt-image-2 as a direct model on gateways that do not expose it.
openclaw skills install cpa-gpt-image-2Use this skill when image generation should go through the CPA blog pattern: a normal text model invokes the image_generation tool over a compatible /v1/responses endpoint.
/v1/responses endpointimage_generation toolgpt-5.4tools: [] text fallbacks from the gatewayDo not treat gpt-image-2 as the direct model on gateways that do not expose that model.
Correct pattern:
gpt-5.4tools: [{"type": "image_generation", "output_format": "png"}]Wrong pattern for this gateway:
gpt-image-2 when the provider does not publish that modelThe script resolves credentials in this order.
Base URL:
IMAGE_GEN_BASE_URLOTCBOT_BASE_URLCPA_BASE_URLOPENAI_BASE_URLmodels.json otcbot provider baseUrlAPI key:
IMAGE_GEN_KEYOTCBOT_API_KEYCPA_API_KEYOPENAI_API_KEYmodels.json otcbot provider apiKeyModel default:
IMAGE_GEN_MODELOTCBOT_IMAGE_MODELCPA_MODELgpt-5.4Optional:
IMAGE_GEN_OUTPUT_FORMAT — default pngCPA_SESSION_ID — session id header value, default test-sessionCPA_USER_AGENT — custom user-agent headerCPA_VERSION — request header version, default 0.122.0CPA_ORIGINATOR — request header originator, default codex_cli_rsThe script calls:
${BASE_URL%/}/v1/responsesUse the bundled script:
python3 skills/cpa-gpt-image-2/scripts/generate_image.py \
--prompt "画一只可爱的松鼠" \
--output /tmp/squirrel.png \
--model gpt-5.4
Recommended env contract:
export IMAGE_GEN_BASE_URL='http://192.168.10.8:8317/v1'
export IMAGE_GEN_KEY='sk-xxxx'
export IMAGE_GEN_MODEL='gpt-5.4'
Override model when needed:
python3 skills/cpa-gpt-image-2/scripts/generate_image.py \
--prompt "a cinematic fox detective in Bangkok neon rain" \
--output /tmp/fox.png \
--model gpt-5.4 \
--format png
The script:
/v1/responsesuser-agent, version, originator, session_idimage_generation tool, defaulting to stream: falsedata: payloads when streaming is enabledrate_limit_exceeded image responses when the server provides a retry delayPreferred non-streaming version:
curl --location "$IMAGE_GEN_BASE_URL/responses" \
--header "Authorization: Bearer $IMAGE_GEN_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gpt-5.4",
"input": "画一只可爱的松鼠",
"tools": [
{
"type": "image_generation",
"output_format": "png"
}
],
"instructions": "you are a helpful assistant",
"tool_choice": "auto",
"stream": false,
"store": false
}'
Streaming version when needed:
curl --location "$IMAGE_GEN_BASE_URL/responses" \
--header "Authorization: Bearer $IMAGE_GEN_KEY" \
--header "user-agent: ${CPA_USER_AGENT:-codex-tui/0.122.0 (Manjaro 26.1.0-pre; x86_64) vscode/3.0.12 (codex-tui; 0.122.0)}" \
--header "version: ${CPA_VERSION:-0.122.0}" \
--header "originator: ${CPA_ORIGINATOR:-codex_cli_rs}" \
--header "session_id: ${CPA_SESSION_ID:-test-session}" \
--header 'accept: text/event-stream' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.4",
"input": "画一只可爱的松鼠",
"tools": [
{
"type": "image_generation",
"output_format": "png"
}
],
"instructions": "you are a helpful assistant",
"tool_choice": "auto",
"stream": true,
"store": false
}'
gpt-5.4 plus image_generation tool instead of direct gpt-image-2 model calls.OTCBOT_BASE_URL and OTCBOT_API_KEY explicitly when testing.