Codex GPT Image 2 Generation
Run the bundled script to generate and save text-to-image assets with the fixed gpt-image-2 model.
Execution contract
- For a request using this Skill, run
scripts/generate_business_image.py. Do not substitute Codex's built-in or hosted image_gen call.
- Read the Key automatically from the active provider in Codex
config.toml. Do not ask the user to paste a Key and do not accept a Key, model, or base URL as an argument.
- When the user supplies only a prompt, pass only
--prompt; let the script use its defaults.
- Do not automatically retry a failed or timed-out generation because the first request may still consume quota.
- Treat the task as complete only after at least one real local image file exists and is presented to the user.
Security contract
- Read
$CODEX_HOME/config.toml, defaulting to ~/.codex/config.toml. Select the provider named by top-level model_provider, require its base_url to be https://api.tu-zi.com/coding, and use only its experimental_bearer_token value.
- Do not fall back to
auth.json or another provider's token.
- Never display, log, return, copy, or rewrite the API Key.
- Never accept a Key, model name, or base URL as a command-line argument.
- Never add a credential to this Skill, a project, a ZIP, an image prompt, or a generated file.
- Stop if Codex uses another authentication format or the configured Key cannot access
gpt-image-2.
Read references/runtime.md when diagnosing credentials, API compatibility, or another user's installation. Read references/prompting.md when the business-image request needs prompt structure or visual constraints.
Workflow
Preserve the user's business facts, brand wording, required text, composition, dimensions, and exclusions. Do not invent a logo, certification, discount, price, product claim, or contact detail.
If the user did not choose a layout, omit layout arguments. The script defaults to size=auto, one image, quality=auto, PNG, and automatic background.
Run the script with the prompt and only the options the user actually requested. Pass the prompt as one safely quoted argument; never interpolate it into executable shell syntax.
Parse the JSON result. Require exit code 0 and a nonempty saved_files array. Confirm every returned path exists and is nonempty.
Use the non-sensitive timings object to report performance only when useful. api_request_ms covers the synchronous API wait, image_download_ms covers returned image URL downloads, save_images_ms covers download/decoding plus local writes, and total_ms covers the complete script run. Do not infer billing from these values.
Present each image using its absolute local path. In Codex Desktop, include both an inline image and a download link:

[下载原图](/absolute/path/to/image.png)
Do not claim that an attachment was returned unless it is visibly rendered. If inline rendering fails, still provide the verified absolute file link.
Report API errors concisely without exposing credentials or automatically retrying.
Credential check
Check whether the current Codex configuration contains a usable Key without making an API request:
python3 <skill-directory>/scripts/generate_business_image.py --status
The status result shows only whether a credential exists, which config file was checked, and which provider was selected. It never shows the Key.
Generate an image
Normal prompt-only flow:
python3 <skill-directory>/scripts/generate_business_image.py \
--prompt "面向企业客户的云服务宣传主视觉,深蓝科技风,留出标题区域"
Add rendering options only when requested:
python3 <skill-directory>/scripts/generate_business_image.py \
--prompt "面向企业客户的云服务宣传主视觉,深蓝科技风,留出标题区域" \
--aspect-ratio 16:9 \
--quality auto \
--output-format png \
--output-dir /absolute/path/to/generated-images
Optional arguments:
--size auto|1K|1024x1024|1536x1024|1024x1536
--aspect-ratio 1:1|16:9|9:16|3:2|2:3
--quality auto|low|medium|high
--output-format png|jpeg|webp
--background auto|transparent|opaque
--count 1..10
--output-dir /absolute/path
Do not pass both --size and --aspect-ratio. Transparent backgrounds require PNG or WebP.
Without --output-dir, files are saved under $CODEX_HOME/generated_images/codex-gpt-image-2-generation, defaulting to ~/.codex/generated_images/codex-gpt-image-2-generation.
Boundaries
- Support text-to-image generation only. Do not claim to edit a reference image.
- Keep the model fixed to
gpt-image-2, even if the user asks this Skill to switch models. Use a different Skill for other models.
- Keep the API endpoint fixed to the Tuzi Codex-group synchronous image endpoint at
https://api.tu-zi.com/coding/v1/images/generations.
- A successful Codex text-model session does not prove the same Key has an available
gpt-image-2 channel. Report the upstream error if access is unavailable.
- Download returned HTTPS URLs or decode returned Base64 images and detect the real image format from the file content.
- Treat requested size and aspect ratio as targets rather than guaranteed output dimensions. Inspect the saved file when exact dimensions matter, then crop or resize in a separate step.
1---2name: codex-gpt-image-2-generation3description: Generate, persist, and display text-to-image assets with Tuzi's fixed gpt-image-2 model by automatically reading the active model provider's experimental_bearer_token from Codex config.toml. Use when the user invokes this Skill or asks for a business image, marketing visual, product illustration, poster, social image, transparent asset, or other image through their Codex-configured Tuzi account without manually entering a Key. Run the bundled script so the result is a real local file instead of relying on Codex's hosted image attachment handoff.4---56# Codex GPT Image 2 Generation78Run the bundled script to generate and save text-to-image assets with the fixed `gpt-image-2` model.910## Execution contract1112- For a request using this Skill, run `scripts/generate_business_image.py`. Do not substitute Codex's built-in or hosted `image_gen` call.13- Read the Key automatically from the active provider in Codex `config.toml`. Do not ask the user to paste a Key and do not accept a Key, model, or base URL as an argument.14- When the user supplies only a prompt, pass only `--prompt`; let the script use its defaults.15- Do not automatically retry a failed or timed-out generation because the first request may still consume quota.16- Treat the task as complete only after at least one real local image file exists and is presented to the user.1718## Security contract1920- Read `$CODEX_HOME/config.toml`, defaulting to `~/.codex/config.toml`. Select the provider named by top-level `model_provider`, require its `base_url` to be `https://api.tu-zi.com/coding`, and use only its `experimental_bearer_token` value.21- Do not fall back to `auth.json` or another provider's token.22- Never display, log, return, copy, or rewrite the API Key.23- Never accept a Key, model name, or base URL as a command-line argument.24- Never add a credential to this Skill, a project, a ZIP, an image prompt, or a generated file.25- Stop if Codex uses another authentication format or the configured Key cannot access `gpt-image-2`.2627Read [references/runtime.md](references/runtime.md) when diagnosing credentials, API compatibility, or another user's installation. Read [references/prompting.md](references/prompting.md) when the business-image request needs prompt structure or visual constraints.2829## Workflow30311. Preserve the user's business facts, brand wording, required text, composition, dimensions, and exclusions. Do not invent a logo, certification, discount, price, product claim, or contact detail.322. If the user did not choose a layout, omit layout arguments. The script defaults to `size=auto`, one image, `quality=auto`, PNG, and automatic background.333. Run the script with the prompt and only the options the user actually requested. Pass the prompt as one safely quoted argument; never interpolate it into executable shell syntax.344. Parse the JSON result. Require exit code 0 and a nonempty `saved_files` array. Confirm every returned path exists and is nonempty.355. Use the non-sensitive `timings` object to report performance only when useful. `api_request_ms` covers the synchronous API wait, `image_download_ms` covers returned image URL downloads, `save_images_ms` covers download/decoding plus local writes, and `total_ms` covers the complete script run. Do not infer billing from these values.366. Present each image using its absolute local path. In Codex Desktop, include both an inline image and a download link:3738 ```markdown39 40 [下载原图](/absolute/path/to/image.png)41 ```42437. Do not claim that an attachment was returned unless it is visibly rendered. If inline rendering fails, still provide the verified absolute file link.448. Report API errors concisely without exposing credentials or automatically retrying.4546## Credential check4748Check whether the current Codex configuration contains a usable Key without making an API request:4950```bash51python3 <skill-directory>/scripts/generate_business_image.py --status52```5354The status result shows only whether a credential exists, which config file was checked, and which provider was selected. It never shows the Key.5556## Generate an image5758Normal prompt-only flow:5960```bash61python3 <skill-directory>/scripts/generate_business_image.py \62 --prompt "面向企业客户的云服务宣传主视觉,深蓝科技风,留出标题区域"63```6465Add rendering options only when requested:6667```bash68python3 <skill-directory>/scripts/generate_business_image.py \69 --prompt "面向企业客户的云服务宣传主视觉,深蓝科技风,留出标题区域" \70 --aspect-ratio 16:9 \71 --quality auto \72 --output-format png \73 --output-dir /absolute/path/to/generated-images74```7576Optional arguments:7778```text79--size auto|1K|1024x1024|1536x1024|1024x153680--aspect-ratio 1:1|16:9|9:16|3:2|2:381--quality auto|low|medium|high82--output-format png|jpeg|webp83--background auto|transparent|opaque84--count 1..1085--output-dir /absolute/path86```8788Do not pass both `--size` and `--aspect-ratio`. Transparent backgrounds require PNG or WebP.8990Without `--output-dir`, files are saved under `$CODEX_HOME/generated_images/codex-gpt-image-2-generation`, defaulting to `~/.codex/generated_images/codex-gpt-image-2-generation`.9192## Boundaries9394- Support text-to-image generation only. Do not claim to edit a reference image.95- Keep the model fixed to `gpt-image-2`, even if the user asks this Skill to switch models. Use a different Skill for other models.96- Keep the API endpoint fixed to the Tuzi Codex-group synchronous image endpoint at `https://api.tu-zi.com/coding/v1/images/generations`.97- A successful Codex text-model session does not prove the same Key has an available `gpt-image-2` channel. Report the upstream error if access is unavailable.98- Download returned HTTPS URLs or decode returned Base64 images and detect the real image format from the file content.99- Treat requested size and aspect ratio as targets rather than guaranteed output dimensions. Inspect the saved file when exact dimensions matter, then crop or resize in a separate step.