imageapi is a Codex skill for text-to-image generation through the configured gzxsy.vip image endpoint.
It is designed for agent use, not manual one-off scripting. The skill:
- converts the user request into an optimized English prompt
- supports optional reference images and automatically switches to the edit flow when references are present
- supports
sizeandqualitycontrols - returns a single JSON object on stdout for both success and failure
- keeps the API key in local config only
- Text-to-image generation
- Reference-image-conditioned editing/generation
- Structured output for agents
- Clear failure codes for config, prompt, reference-image, output, and API errors
- Mask-based editing
- Background removal
- Batch generation
- Cloud-side key management
- Install or sync the skill into the local Codex skills directory:
C:\Users\BenLi\.codex\skills\imageapi - Ensure
config.jsonexists next toconfig.example.json. - Fill in your local
api_keyinconfig.json. - Restart or reload Codex so the skill is discoverable.
Use this one-line command to install or update the skill from GitHub on a machine that already has the target agent runtime and git access:
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $root='C:\Users\BenLi'; if (-not (Test-Path \"$root\.codex\skills\imageapi\")) { git clone https://github.com/CercaTrovato/imageapi.git \"$root\.codex\skills\imageapi\" } else { git -C \"$root\.codex\skills\imageapi\" pull --ff-only }"For an agent to install itself from a prompt, give it the command above and instruct it to run it unchanged.
These agents can use their own skill directories with the same repository source:
- Claude:
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $root='C:\Users\BenLi\.claude\skills'; New-Item -ItemType Directory -Force -Path $root | Out-Null; if (-not (Test-Path \"$root\imageapi\")) { git clone https://github.com/CercaTrovato/imageapi.git \"$root\imageapi\" } else { git -C \"$root\imageapi\" pull --ff-only }"
- OpenCode:
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $root='C:\Users\BenLi\.agents\skills'; New-Item -ItemType Directory -Force -Path $root | Out-Null; if (-not (Test-Path \"$root\imageapi\")) { git clone https://github.com/CercaTrovato/imageapi.git \"$root\imageapi\" } else { git -C \"$root\imageapi\" pull --ff-only }"
{
"api_base": "https://gzxsy.vip",
"api_key": "your_api_key_here",
"model": "gpt-image-2"
}The skill is intended to be triggered by agent instructions such as:
- "Use imageapi to generate an image"
- "Use the imageapi skill"
- "Generate an image and include reference images if useful"
The CLI accepts:
python .\scripts\generate_image.py --prompt "optimized English prompt" --ref "ref1.png" "https://example.com/ref.png" --size 1024x1024 --quality autoThe script always prints one JSON object to stdout:
- success:
ok: trueoutputpromptsizequalityreference_images- optional
revised_prompt - optional
usage
- failure:
ok: falseerror.codeerror.messageerror.retryableerror.details
Common codes include:
CONFIG_MISSINGCONFIG_INVALID_JSONCONFIG_MISSING_FIELDPROMPT_EMPTYREF_IMAGE_INVALIDREF_IMAGE_UNREADABLEAUTH_FAILEDRATE_LIMITEDAPI_TIMEOUTAPI_HTTP_ERRORAPI_BAD_RESPONSEIMAGE_DOWNLOAD_FAILEDOUTPUT_WRITE_FAILEDUNSUPPORTED_SIZEUNSUPPORTED_QUALITY
- Keep
config.jsonout of Git. - Use
config.example.jsonas the committed template. - Run the script directly for smoke tests.
- Use the structured JSON contract when building agent integrations.
- Config file loads
- Empty prompt returns
PROMPT_EMPTY - Invalid
size/qualityreturnUNSUPPORTED_* - Invalid reference image returns
REF_IMAGE_INVALID - Success returns
ok: true - Failure returns
ok: false
- The repository must not contain your live API key.
- Only the local
config.jsonshould hold the actual key. - If the key changes, update the local config and keep the Git-tracked example file empty.
- Do not paste
config.jsoninto chat or commit it to GitHub.
SKILL.md- Codex skill instructionsscripts/generate_image.py- CLI implementationconfig.example.json- committed config templateconfig.json- local-only config, ignored by Gitagents/openai.yaml- UI metadata for Codex