cpa-gpt-image-2

Use 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.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "cpa-gpt-image-2" with this command: npx skills add shiftshen/cpa-gpt-image-2

cpa-gpt-image-2

Use 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.

What this skill does

  • sends a request to an OpenAI-compatible /v1/responses endpoint
  • matches the CPA blog example request shape closely
  • uses the image_generation tool
  • defaults to model gpt-5.4
  • prefers non-streaming mode by default for simpler and more stable parsing
  • can switch to streaming mode when needed
  • automatically retries short image rate-limit responses
  • automatically retries transient tools: [] text fallbacks from the gateway
  • keeps credentials in environment variables, never in the skill files

Important rule

Do not treat gpt-image-2 as the direct model on gateways that do not expose that model.

Correct pattern:

  • use a normal model such as gpt-5.4
  • pass tools: [{"type": "image_generation", "output_format": "png"}]
  • let the gateway/tool layer decide whether image generation is available

Wrong pattern for this gateway:

  • directly calling model gpt-image-2 when the provider does not publish that model

Default environment resolution

The script resolves credentials in this order.

Base URL:

  • IMAGE_GEN_BASE_URL
  • OTCBOT_BASE_URL
  • CPA_BASE_URL
  • OPENAI_BASE_URL
  • fallback to OpenClaw models.json otcbot provider baseUrl

API key:

  • IMAGE_GEN_KEY
  • OTCBOT_API_KEY
  • CPA_API_KEY
  • OPENAI_API_KEY
  • fallback to OpenClaw models.json otcbot provider apiKey

Model default:

  • IMAGE_GEN_MODEL
  • OTCBOT_IMAGE_MODEL
  • CPA_MODEL
  • fallback to current OpenClaw image/default model
  • final fallback: gpt-5.4

Optional:

  • IMAGE_GEN_OUTPUT_FORMAT — default png
  • CPA_SESSION_ID — session id header value, default test-session
  • CPA_USER_AGENT — custom user-agent header
  • CPA_VERSION — request header version, default 0.122.0
  • CPA_ORIGINATOR — request header originator, default codex_cli_rs

The script calls:

  • ${BASE_URL%/}/v1/responses

Default execution path

Use 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

Expected behavior

The script:

  1. reads credentials from env or OpenClaw otcbot defaults
  2. POSTs to /v1/responses
  3. sends codex-style headers: user-agent, version, originator, session_id
  4. requests the image_generation tool, defaulting to stream: false
  5. parses normal JSON, or SSE data: payloads when streaming is enabled
  6. auto-retries short rate_limit_exceeded image responses when the server provides a retry delay
  7. auto-retries transient gateway fallbacks where the tool list comes back empty and the response degrades to text
  8. extracts the first base64 image from the response
  9. writes the file to the requested output path

Fallback curl patterns

Preferred 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
  }'

Notes

  • Prefer the bundled script for repeatability.
  • Do not hardcode live keys, base URLs, or session ids into workspace docs.
  • This skill intentionally mirrors the CPA blog example request shape as closely as practical.
  • On this gateway, prefer gpt-5.4 plus image_generation tool instead of direct gpt-image-2 model calls.
  • For the known local otcbot endpoint, prefer setting OTCBOT_BASE_URL and OTCBOT_API_KEY explicitly when testing.
  • If the endpoint returns provider-specific SSE events, extend the SSE parser instead of changing the whole request shape.
  • If the user asks to send the generated file back in the current chat, use the normal file-delivery flow after generation.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Huo15 Openclaw Enhance

火一五·克劳德·龙虾增强插件 v5.7.8 — 全面适配 openclaw 2026.4.24:peerDep ^4.24 + build/compat 同步到 4.24 + 14 处 api.on 全部去掉 as any 改成 typed hook(hookName 联合类型 + handler 自动推断 Pl...

Registry SourceRecently Updated
General

Content Trend Analyzer

Aggregates and analyzes content trends across platforms to identify hot topics, user intent, content gaps, and generates data-driven article outlines.

Registry SourceRecently Updated
General

Prompt Debugger

Debug prompts that produce unexpected AI outputs — diagnose failure modes, identify ambiguity and conflicting instructions, test variations, compare model re...

Registry SourceRecently Updated
General

Indie Maker News

独行者 Daily - 变现雷达。读对一条新闻,少走一年弯路。每天5分钟,给创业者装上商业雷达。聚焦一人公司、副业、创业变现资讯,智能分类,行动导向。用户下载即能用,无需本地部署!

Registry SourceRecently Updated