CPA GPT Image 2
v1Use a text 模型 such as gpt-5.4 with the image_generation 工具 over an OpenAI-compatible /v1/响应s 端点, matching the CPA b记录 example. Do not call gpt-image-2 as a direct 模型 on gateways that do not expose it.
运行时依赖
安装命令
点击复制技能文档
cpa-gpt-image-2
Use this 技能 when image generation should go through the CPA b记录 pattern: a normal text 模型 invokes the image_generation 工具 over a compatible /v1/响应s 端点.
What this 技能 does 发送s a 请求 to an OpenAI-compatible /v1/响应s 端点 matches the CPA b记录 example 请求 shape closely uses the image_generation 工具 defaults to 模型 gpt-5.4 prefers non-流ing mode by default for simpler and more stable parsing can switch to 流ing mode when needed automatically retries short image rate-limit 响应s automatically retries transient 工具s: [] text fallbacks from the gateway keeps 凭证s in 环境 variables, never in the 技能 files 导入ant rule
Do not treat gpt-image-2 as the direct 模型 on gateways that do not expose that 模型.
Correct pattern:
use a normal 模型 such as gpt-5.4 pass 工具s: [{"type": "image_generation", "输出_格式化": "png"}] let the gateway/工具 layer decide whether image generation is avAIlable
Wrong pattern for this gateway:
directly calling 模型 gpt-image-2 when the 提供者 does not publish that 模型 Default 环境 resolution
The script resolves 凭证s in this order.
Base URL:
IMAGE_GEN_BASE_URL OTC机器人_BASE_URL CPA_BASE_URL OPENAI_BASE_URL fallback to OpenClaw 模型s.json otc机器人 提供者 baseUrl
API key:
IMAGE_GEN_KEY OTC机器人_API_KEY CPA_API_KEY OPENAI_API_KEY fallback to OpenClaw 模型s.json otc机器人 提供者 APIKey
模型 default:
IMAGE_GEN_模型 OTC机器人_IMAGE_模型 CPA_模型 fallback to current OpenClaw image/default 模型 final fallback: gpt-5.4
Optional:
IMAGE_GEN_输出_格式化 — default png CPA_会话_ID — 会话 id header value, default test-会话 CPA_USER_代理 — custom user-代理 header CPA_VERSION — 请求 header version, default 0.122.0 CPA_ORIGINATOR — 请求 header originator, default codex_命令行工具_rs
The script calls:
${BASE_URL%/}/v1/响应s Default execution path
Use the bundled script:
python3 技能s/cpa-gpt-image-2/scripts/生成_image.py \ --prompt "画一只可爱的松鼠" \ --输出 /tmp/squirrel.png \ --模型 gpt-5.4
Recommended env contract:
导出 IMAGE_GEN_BASE_URL='http://192.168.10.8:8317/v1' 导出 IMAGE_GEN_KEY='sk-xxxx' 导出 IMAGE_GEN_模型='gpt-5.4'
Override 模型 when needed:
python3 技能s/cpa-gpt-image-2/scripts/生成_image.py \ --prompt "a cinematic fox 检测ive in Bangkok neon rAIn" \ --输出 /tmp/fox.png \ --模型 gpt-5.4 \ --格式化 png
Expected behavior
The script:
reads 凭证s from env or OpenClaw otc机器人 defaults POSTs to /v1/响应s 发送s codex-style headers: user-代理, version, originator, 会话_id 请求s the image_generation 工具, defaulting to 流: false 解析s normal JSON, or SSE data: payloads when 流ing is enabled auto-retries short rate_limit_exceeded image 响应s when the server provides a retry delay auto-retries transient gateway fallbacks where the 工具 列出 comes back empty and the 响应 degrades to text 提取s the first base64 image from the 响应 writes the file to the 请求ed 输出 path Fallback curl patterns
Preferred non-流ing version:
curl --location "$IMAGE_GEN_BASE_URL/响应s" \ --header "Authorization: Bearer $IMAGE_GEN_KEY" \ --header "Content-Type: 应用/json" \ --data '{ "模型": "gpt-5.4", "输入": "画一只可爱的松鼠", "工具s": [ { "type": "image_generation", "输出_格式化": "png" } ], "instructions": "you are a helpful 助手", "工具_choice": "auto", "流": false, "store": false }'
流ing version when needed:
curl --location "$IMAGE_GEN_BASE_URL/响应s" \ --header "Authorization: Bearer $IMAGE_GEN_KEY" \ --header "user-代理: ${CPA_USER_代理:-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_命令行工具_rs}" \ --header "会话_id: ${CPA_会话_ID:-test-会话}" \ --header 'accept: text/event-流' \ --header 'Content-Type: 应用/json' \ --data '{ "模型": "gpt-5.4", "输入": "画一只可爱的松鼠", "工具s": [ { "type": "image_generation", "输出_格式化": "png" } ], "instructions": "you are a helpful 助手", "工具_choice": "auto", "流": true, "store": false }'
Notes Prefer the bundled script for repeatability. Do not hardcode live keys, base URLs, or 会话 ids into workspace docs. This 技能 intentionally mirrors the CPA b记录 example 请求 shape as closely as practical. On this gateway, prefer gpt-5.4 plus image_generation 工具 instead of direct gpt-image-2 模型 calls. For the known local otc机器人 端点, prefer 设置ting OTC机器人_BASE_URL and OTC机器人_API_KEY explicitly when 测试. If the 端点 returns 提供者-specific SSE 事件, extend the SSE 解析器 instead of changing the whole 请求 shape. If the user asks to 发送 the 生成d file back in the current chat, use the normal file