chatgpt-images-fallback
ChatGPT Images Fallback
Overview
Use this skill when a task needs a new image file at a known path, but API-based generation may fail because the provider has no remaining image quota. Keep the normal API-first path, and only use chatgpt.com/images as a fallback for quota-class failures.
Setup
Install the browser dependency once before using website fallback:
cd scripts
npm install
The browser fallback expects:
- a local Chrome installation
- a reusable ChatGPT login session
- write access to the target output directory
Workflow Decision Tree
- Collect:
- prompt text or prompt file
- output directory
- target filename
- primary provider settings
- Run
scripts/generate_with_fallback.pyto try the primary provider. - If the script returns
saved, stop and use the generated file. - If the script returns
needs_chatgpt_fallback, openhttps://chatgpt.com/images. - Generate the image from the exact same prompt.
- Download the first generated image.
- Run
scripts/finalize_download.pyto move the downloaded file into the requested directory and rename it to the requested filename. - For batch fallback, prefer
scripts/run_chatgpt_fallback.mjsover doing the website steps manually.
Inputs
prompt_textorprompt_fileoutput_dirfilenameprimary_providerdownloads_dirwhen browser download automation is used
Default behavior:
- Fallback only for quota-like failures
- Download the first ChatGPT candidate
- Backup an existing target file before overwrite
Primary Provider Step
Run:
python scripts/generate_with_fallback.py `
--prompt-file <path-or-omit> `
--prompt-text <text-or-omit> `
--output-dir <dir> `
--filename <name> `
--primary google-gemini
Interpret the JSON result:
status = "saved": primary generation succeededstatus = "needs_chatgpt_fallback": browser fallback is requiredstatus = "error": do not fall back automatically unless the error class is quota-related
ChatGPT Images Fallback Step
When fallback is required:
- Open
https://chatgpt.com/images - Ensure the user is logged in
- Paste the exact prompt from the script result
- Submit generation
- Wait until the first result is visible and downloadable
- Download the first result only
- Finalize it with:
python scripts/finalize_download.py `
--downloaded-file <downloaded-image> `
--output-dir <dir> `
--filename <name>
Use the first generated image by default. Do not stop to ask the user to choose among multiple candidates unless the user explicitly asked to review options.
Detailed browser steps are in references/browser-flow.md.
Batch browser fallback:
cd scripts
npm install
node scripts/run_chatgpt_fallback.mjs `
--manifest <fallback-manifest.json> `
--manifest-out <chatgpt-results.json>
Full pipeline:
cd scripts
python scripts/run_pipeline.py `
--jobs-file <image-jobs.json> `
--fallback-manifest <fallback-manifest.json> `
--chatgpt-results <chatgpt-results.json>
Error Handling
Only auto-fall back for quota-class failures such as:
quota exceededinsufficient creditsRESOURCE_EXHAUSTED- provider-specific messages indicating exhausted paid or free tier image quota
Do not auto-fall back for:
- invalid prompt payloads
- authentication failures
- permission errors unrelated to quota
- file path mistakes
- network errors that look transient but not quota-related
Scripts
-
scripts/generate_with_fallback.py- tries the primary provider
- classifies quota errors
- saves a successful API result directly
- returns a JSON payload for browser fallback when needed
-
scripts/finalize_download.py- moves the downloaded browser image to the requested output path
- backs up an existing target file before overwrite
- emits JSON with the final saved path
-
scripts/run_jobs.py- runs a batch of image jobs from a JSON file
- saves successful primary generations immediately
- writes a fallback manifest listing only the jobs that must be completed via
chatgpt.com/images - is the preferred entry point for article and social-post image sets
-
scripts/run_chatgpt_fallback.mjs- opens
chatgpt.com/imagesin a persistent Chrome profile - waits for manual login if needed
- generates each fallback image from the manifest
- fetches the first generated image and finalizes it to the requested filename
- opens
-
scripts/run_pipeline.py- runs the full sequence end to end
- first executes
run_jobs.py - then invokes browser fallback only when fallback jobs exist
Notes
- This skill is for new image generation only.
- Keep prompt text identical between primary generation and ChatGPT fallback.
- Prefer PNG output when possible.
- If the generated website download filename is generic, rely on
finalize_download.pyfor the final rename step. - If
run_chatgpt_fallback.mjscannot find the prompt box, reuse the same profile directory after logging in manually once.
More from zhangga/aihub
yahoo-data-fetcher
Fetch real-time stock quotes from Yahoo Finance.
20xai-stock-sentiment
Real-time stock sentiment analysis using Twitter/X data via Grok. Use when analyzing stock ticker sentiment, tracking retail investor mood, or gauging market reaction to events.
17remotion
Remotion renderer for json-render that turns JSON timeline specs into videos. Use when working with @json-render/remotion, building video compositions from JSON, creating video catalogs, or rendering AI-generated video timelines.
15skill-hub-builder
Scaffold and maintain a personal skill hub repository for collecting, syncing, and distributing commonly used agent skills. Use when setting up a reusable skill hub, adding external or local skills, updating bundles, or preparing one-click install flows for a team.
12sensight
触发:查热搜/热榜(抖音/微博/小红书/推特/头条/百度);社交媒体语义搜索(微博/微信/小红书/推特,任意话题);查特定作者/账号近期发文动态;查 AI 行业资讯(论文/博客/模型发布/口碑/深度摘要)。不触发:通用知识问答、代码生成、静态事实类问题。
10long-run-harness
Use for long-running, multi-step work where the agent should keep driving toward the true final outcome across many cycles instead of stopping after one pass. Trigger when the user wants autonomous progress, durable state, session recovery, single-task execution, validation, and review gates in an existing git repository or a similarly structured workspace.
10