返回 Skill 列表
extension
分类: 其它需要 API Key

image2调用技能

该技能用于通过 中转站 的 Image2 接口生成或编辑图片,支持文本生图和基于已有图片的改图。使用前需要按说明引导配置 APINEBULA_API_KEY 或 OPENAI_API_KEY 以及中转站接口环境变量。技能内置三种模型档位:normal、vip、pro,分别对应不同的 Image2 模型;支持方图、横图、竖图三种画幅,并可设置 low、medium、high 等质量参数。生成结果会自动保存到当前目录下的 image2_outputs/ 文件夹中,适合用于快速生成插画、写实照片、产品图、场景图,或对已有图片进行风格和内容修改。

person作者: 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