Summary notes: This is a summary of Alex Prompter’s (@alex_prompter) long X post of November 4, 2026, “Spend ChatGPT Pro API credits on GPT Image 2.5 with a capped script”, not a reprint of the original. Original link: https://x.com/alex_prompter/status/2117737582172008954
Alex Prompter spotted an easily wasted benefit: eligible ChatGPT Pro plans include $100 to $500 in monthly API credits, but they must be claimed manually once in the billing settings to receive them, and whatever is unused by the end of the month expires. He wrote a prompt that has Claude Code or Codex build a local script to turn those credits into images — with the amount spent decided by you.
First, understand the credit rules
The author first checked OpenAI’s own pages and confirmed several key rules:
- The credits cover the Images API, and do not cover Codex called via API key, nor do they raise the usage limit for logged-in Codex; so images are the most straightforward way to spend this money.
- The first grant of credits is prorated; sizes above 2560×1440 are still labelled experimental by OpenAI, which is also why the script insists on “first produce one test image”.
- The largest request is quality set to max at 3840×2160, which applies to both models of GPT Image 2.5; but note there are five quality levels in total, and high is only the third — at the same size, high produces only 3,336 output tokens, while max produces 13,342; when quality is not specified, the default is auto.
Cost estimates
- According to OpenAI’s pricing calculator, one image at max quality, 3840×2160, costs about $0.40 in output tokens; the $200 credit tier can produce about 500 images a month.
- Batch mode is listed at half price, which in theory could double that, but OpenAI’s credits page does not say whether credits can be used for Batch, and the author did not factor that into his conclusion.
- The script’s default size is 2560×1440, about $0.22 per image; at that size, max quality corresponds to 7,370 output tokens, and high to 1,843.
- Pricing basis (checked by the author on November 2): output tokens at $30 per million, text input tokens at $5 per million; the real cost is based on the usage fields returned by the API, and when missing, the estimated value is used and a warning is given; he verified with 100 input tokens plus 13,342 output tokens, and the cost should be $0.40076.
The biggest pitfall: once the credits burn out, it keeps spending real money
The author points out the real trap: the free credits burn first, and once they are gone, the API does not stop automatically — if the account still has purchased credits or auto-recharge turned on, it will keep charging real money. Just waiting for the credit_balance_exhausted error to stop it won’t hold. So the script keeps its own ledger, and stops once you reach the number you set.
What kind of script the prompt asks the agent to build
The prompt the author gives is structured in seven parts — task, inputs, API facts, build, review, rules, and wrap-up — with the core being that Claude Code or Codex should only write the script and run tests, and not actually call the OpenAI API or actually generate images. The script should have these capabilities:
- Hard cap: a
--max-spendparameter, with the amount set by the user, remaining effective after a crash or restart; - Dry run:
--dry-runonly prints the to-do list, per-image cost, total cost, and cap — no network access, no reading the key; - Test one first:
--testfirst produces one image and prints the comparison of the real cost against the estimate; before there is a test record for that model, quality, and size combination, refuse to run the full batch; if the actual cost is more than 10% above the estimate, refuse to continue until the user passes in a higher estimated token count; - Resume from a checkpoint: keep a ledger next to the script, marking each line started before sending the request, and only marking it done and recording tokens and cost after the image is saved to disk; on a re-run, skip completed lines, count lines that were started but not completed at the full estimated amount, and only re-run them with
--retry-started; - No double charging: before each request, check whether “accumulated cost plus the next image’s estimate” exceeds the cap, or whether the credits have expired — stop if so;
- Content blocks are not retried: on a content-moderation block or an image-generation user error, just record it as blocked and move to the next line, without retrying;
- Keys are never written to disk: the key is only read from the
OPENAI_API_KEYenvironment variable, never printed or saved; errors print only the HTTP status code and error code; - Restrained retries: the SDK’s max_retries is set to 0; on rate limiting or server errors, back off according to Retry-After, with a cap on attempts; a timeout is counted at the full estimated amount and is not retried automatically;
- Credit errors stop immediately: the moment a credit-exhausted, spending-cap, or usage-limit error is hit, stop at once.
Reviewer subagent: send a fresh agent to pick it apart
Once the script is written and the tests pass, the prompt requires sending a brand-new subagent (not a fork, not read-only) to review it: give it only the review criteria, the script path, and the rules — not the API facts section — and let it read OpenAI’s official pages itself. The reviewer subagent may only write inside ./judge-tests, all API calls use mocked values and a fake key; it checks each parameter, rate, and error code one by one against OpenAI’s image generation, pricing, and error code guides, and any page that fails to load is recorded as “unverified” — it must never count as passing; it also verifies with mocked usage (100 input tokens, 13,342 output tokens) that the calculated cost must be $0.40076; and it must prove that the cap takes effect before the next request and survives a restart, that a crash does not re-request completed lines, that a full batch is refused when there is no test record, that a moderation block requests only once, that credit exhaustion stops immediately, that a dry run makes zero calls, and that a fake key does not appear in any output or ledger. Each item outputs pass, fail, or unverified, with the command output attached; if it fails, fix it, then have a new subagent review again, for at most two rounds.
Wrap-up rules and usage advice
- Put it in a new folder; prompts.txt, the output directory, and the ledger stay local only, and are added to gitignore; don’t read the key, don’t touch the billing settings.
- After the review, stop, first give the user the review table (failures and unverified items first), then write out the three commands in the order dry run, test, full batch, for the user to run themselves in the terminal.
- The author’s usage advice is: spend the credits on work you would have paid for anyway, such as blog header images, ad backgrounds, or a website’s main visuals; 500 images nobody uses is equally a waste of a month’s credits.
Summary
The structure of this post is worth borrowing: first check the three questions — “how the credits are calculated, when they expire, and what happens once they burn out” — then have the agent write the script; the script itself doesn’t aim for many features, but centres on three things — spending with a cap, failures that don’t double-charge, and verifying the calculation before running; finally, use an independent subagent to review it against the official documentation. Before copying the prompt directly, remember to first go to the billing settings and confirm whether your Pro plan actually has these credits, how much they are, and what the expiry date is.
Written by

