Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate images via OpenAI, Google, OpenRouter, DashScope, Jimeng, Seedream, and Replicate APIs with batch support.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/codex-image2-fallback.md
1---2name: codex-image2-fallback3description: Fallback behavior when baoyu-image-gen lacks OpenAI API credentials but Codex/native image generation is available4---56# Codex Image2 Fallback78When using `baoyu-image-gen` with `--provider openai --model gpt-image-2`, the CLI can fail with:910```text11OPENAI_API_KEY is required. Codex/ChatGPT desktop login does not automatically grant OpenAI Images API access to this script.12```1314This is expected. The `openai` provider uses the public OpenAI Images API and needs `OPENAI_API_KEY`. Codex / ChatGPT image2 entitlement is a separate runtime-native path.1516## Practical fallback pattern17181. Try `baoyu-image-gen` when provider credentials are available.192. If it fails only because `OPENAI_API_KEY` is missing, do not leave the user waiting.203. Prefer a Codex/native raster backend in this order:21- Codex runtime native `imagegen` skill/tool, if available.22- `baoyu-image-gen --provider codex-cli` (preferred — wraps the bundled `scripts/codex-imagegen/main.ts`; the underlying repo-level package lives at `packages/baoyu-codex-imagegen/src/main.ts` for standalone callers), if `codex` CLI is installed/logged in.23- Hermes native `image_generate`, if available.244. Be transparent about reference-image behavior:25- If the fallback backend accepts references, pass the reference images.26- If it does not, derive a concise identity-preserving prompt from the references and state that it is a text-description fallback, not strict reference-image editing.275. Return the generated media path or structured backend error promptly.2829## User-facing wording3031Use concise wording such as:3233> The OpenAI API path needs `OPENAI_API_KEY`; Codex login is a separate image2 backend. I used the available Codex/native image backend instead. Reference images were [passed directly / reconstructed from visual traits].3435Avoid implying that `baoyu-image-gen --provider openai` can use Codex OAuth without a dedicated provider implementation.36