$npx -y skills add freestylefly/canghe-skills --skill canghe-image-genAI image generation with OpenAI, Google, DashScope and Canghe APIs. Supports text-to-image, reference images, aspect ratios. Sequential by default; parallel generation available on request. Use when user asks to generate, create, or draw images.
| 1 | # Image Generation (AI SDK) |
| 2 | |
| 3 | Official API-based image generation. Supports OpenAI, Google, DashScope (阿里通义万象), and Canghe providers. |
| 4 | |
| 5 | ## Script Directory |
| 6 | |
| 7 | **Agent Execution**: |
| 8 | 1. `SKILL_DIR` = this SKILL.md file's directory |
| 9 | 2. Script path = `${SKILL_DIR}/scripts/main.ts` |
| 10 | |
| 11 | ## Preferences (EXTEND.md) |
| 12 | |
| 13 | Use Bash to check EXTEND.md existence (priority order): |
| 14 | |
| 15 | ```bash |
| 16 | # Check project-level first |
| 17 | test -f .canghe-skills/canghe-image-gen/EXTEND.md && echo "project" |
| 18 | |
| 19 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 20 | test -f "$HOME/.canghe-skills/canghe-image-gen/EXTEND.md" && echo "user" |
| 21 | ``` |
| 22 | |
| 23 | ┌──────────────────────────────────────────────────┬───────────────────┐ |
| 24 | │ Path │ Location │ |
| 25 | ├──────────────────────────────────────────────────┼───────────────────┤ |
| 26 | │ .canghe-skills/canghe-image-gen/EXTEND.md │ Project directory │ |
| 27 | ├──────────────────────────────────────────────────┼───────────────────┤ |
| 28 | │ $HOME/.canghe-skills/canghe-image-gen/EXTEND.md │ User home │ |
| 29 | └──────────────────────────────────────────────────┴───────────────────┘ |
| 30 | |
| 31 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 32 | │ Result │ Action │ |
| 33 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 34 | │ Found │ Read, parse, apply settings │ |
| 35 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 36 | │ Not found │ Use defaults │ |
| 37 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 38 | |
| 39 | **EXTEND.md Supports**: Default provider | Default quality | Default aspect ratio | Default image size | Default models |
| 40 | |
| 41 | Schema: `references/config/preferences-schema.md` |
| 42 | |
| 43 | ## Usage |
| 44 | |
| 45 | ```bash |
| 46 | # Basic |
| 47 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png |
| 48 | |
| 49 | # With aspect ratio |
| 50 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image out.png --ar 16:9 |
| 51 | |
| 52 | # High quality |
| 53 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --quality 2k |
| 54 | |
| 55 | # From prompt files |
| 56 | npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png |
| 57 | |
| 58 | # With reference images (Google multimodal or OpenAI edits) |
| 59 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png |
| 60 | |
| 61 | # With reference images (explicit provider/model) |
| 62 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --provider google --model gemini-3-pro-image-preview --ref source.png |
| 63 | |
| 64 | # Specific provider |
| 65 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --provider openai |
| 66 | |
| 67 | # DashScope (阿里通义万象) |
| 68 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只可爱的猫" --image out.png --provider dashscope |
| 69 | |
| 70 | # Canghe third-party gateway |
| 71 | npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只可爱的猫" --image out.png --provider canghe |
| 72 | ``` |
| 73 | |
| 74 | ## Options |
| 75 | |
| 76 | | Option | Description | |
| 77 | |--------|-------------| |
| 78 | | `--prompt <text>`, `-p` | Prompt text | |
| 79 | | `--promptfiles <files...>` | Read prompt from files (concatenated) | |
| 80 | | `--image <path>` | Output image path (required) | |
| 81 | | `--provider google\|openai\|dashscope\|canghe` | Force provider (default: google) | |
| 82 | | `--model <id>`, `-m` | Model ID (`--ref` with OpenAI requires GPT Image model, e.g. `gpt-image-1.5`) | |
| 83 | | `--ar <ratio>` | Aspect ratio (e.g., `16:9`, `1:1`, `4:3`) | |
| 84 | | `--size <WxH>` | Size (e.g., `1024x1024`) | |
| 85 | | `--quality normal\|2k` | Quality preset (default: 2k) | |
| 86 | | `--imageSize 1K\|2K\|4K` | Image size for Google (default: from quality) | |
| 87 | | `--ref <files...>` | Reference images. Supported by Google multimodal, OpenAI edits (GPT Image models), and Canghe (`image_url`). If provider omitted: Google first, then OpenAI, then Canghe | |
| 88 | | `--n <count>` | Number of images | |
| 89 | | `--json` | JSON output | |
| 90 | |
| 91 | ## Environment Variables |
| 92 | |
| 93 | | Variable | Description | |
| 94 | |----------|-------------| |
| 95 | | `OPENAI_API_KEY` | OpenAI API key | |
| 96 | | `GOOGLE_API_KEY` | Google API key | |
| 97 | | `DASHSCOPE_API_KEY` | DashScope API key (阿里云) | |
| 98 | | `CANGHE_API_KEY` | Canghe API key | |
| 99 | | `OPENAI_IMAGE_MODEL` | OpenAI model override | |
| 100 | | `GOOGLE_IMAGE_MODEL` | Google model override | |
| 101 | | `DASHSCOPE_IMAGE_MODEL` | DashScope model override (default: z-image-turbo) | |
| 102 | | `CANGHE_IMAGE_MODEL` | Canghe model override (default: gemini-3-pro-image-preview) | |
| 103 | | `OPENAI_BASE_URL` | Custom OpenAI endpoint | |
| 104 | | `GOOGLE_BASE_URL` | Custom Google endpoint | |
| 105 | | `DASHSCOPE_BASE_URL` | Custom DashScope endpoint | |
| 106 | | `CANGHE_BASE_URL` | Custom Canghe endpoint (default: `https://api.cangh |