Back to skills
extension
Category: OtherAPI key required

image2调用技能

Generate or edit images with API Nebula Image2 via the user's relay endpoint. Use when Codex needs to run an interactive or scripted Image2 workflow with normal, VIP, or Pro models, prompt entry, model/size/quality validation, API calling, saving the result, and opening the output on Windows or macOS.

personAuthor: user_6f7c9fbdhubcommunity

API Nebula Image2

Use this skill to generate or edit images through API Nebula's OpenAI-compatible Image2 endpoints.

Quick Start

Run the interactive CLI:

python scripts/image2_cli.py

The script asks for:

  • mode: generate or edit
  • prompt
  • model: normal, VIP, or Pro
  • size: square, landscape, or portrait
  • quality and optional advanced parameters

It validates the supported values before calling the API, saves the result under image2_outputs/, and opens the output file automatically on Windows, macOS, or Linux.

API Key

The script does not hardcode secrets. Set one of these environment variables before running:

APINEBULA_API_KEY=<your key>

or:

OPENAI_API_KEY=<your key>

Configure API Versions

There are two configuration layers:

  1. Endpoint version: configure the generation/edit API addresses.
  2. Model version: configure normal, VIP, and Pro model keys.

Default endpoints are already built in:

https://apinebula.com/v1/images/generations
https://apinebula.com/v1/images/edits

To override both endpoints with one base URL:

macOS/Linux:

export APINEBULA_BASE_URL='https://apinebula.com/v1'

Windows PowerShell:

setx APINEBULA_BASE_URL "https://apinebula.com/v1"

To override the two endpoint versions separately:

macOS/Linux:

export APINEBULA_GENERATION_ENDPOINT='https://apinebula.com/v1/images/generations'
export APINEBULA_EDIT_ENDPOINT='https://apinebula.com/v1/images/edits'

Windows PowerShell:

setx APINEBULA_GENERATION_ENDPOINT "https://apinebula.com/v1/images/generations"
setx APINEBULA_EDIT_ENDPOINT "https://apinebula.com/v1/images/edits"

If each model version has its own API key, configure per-version keys:

macOS/Linux:

export APINEBULA_API_KEY_NORMAL='normal-key'
export APINEBULA_API_KEY_VIP='vip-key'
export APINEBULA_API_KEY_PRO='pro-key'

Windows PowerShell:

setx APINEBULA_API_KEY_NORMAL "normal-key"
setx APINEBULA_API_KEY_VIP "vip-key"
setx APINEBULA_API_KEY_PRO "pro-key"

Fallback order:

  • normal model: APINEBULA_API_KEY_NORMAL, then APINEBULA_API_KEY, then OPENAI_API_KEY
  • VIP model: APINEBULA_API_KEY_VIP, then APINEBULA_API_KEY, then OPENAI_API_KEY
  • Pro model: APINEBULA_API_KEY_PRO, then APINEBULA_API_KEY, then OPENAI_API_KEY

Models And Sizes

Use the API mapping in references/api-nebula-image2.md for exact supported values.

Primary model choices:

  • normal: gpt-image-2
  • vip: gpt-image-2-vip
  • pro: gpt-image-2-pro

Primary size choices:

  • square: 2048x2048
  • landscape: 3840x2160
  • portrait: 2160x3840

Do not use 4096x4096; the API rejects it because the longest edge must not exceed 3840.

Noninteractive Examples

Generate:

python scripts/image2_cli.py generate \
  --prompt "一只可爱的金毛小狗坐在白色摄影棚地面上,3D卡通收藏玩具质感,无文字、无水印。" \
  --model vip \
  --size square \
  --quality high

Edit:

python scripts/image2_cli.py edit \
  --prompt "保留主体,把背景改成干净白色摄影棚。" \
  --image /path/to/input.png \
  --model vip \
  --size square \
  --quality high

Use --no-open when running in a headless environment.

Validation Workflow

Before making a live request:

python scripts/image2_cli.py generate --prompt "测试小狗" --model vip --size square --dry-run

If a request fails, read the server error. Common causes:

  • API key missing or invalid.
  • The requested model is not enabled for the relay account.
  • A size, quality, or format value is outside the allowed set.
  • Python SSL fails on macOS. In that case, install requests so the script can use certifi:
python -m pip install requests