Free AI Image Generation in the Terminal: ChatGPT Plus + Gemini Guide
Generate AI images for free from your terminal using your ChatGPT Plus/Pro subscription, Gemini Nano Banana, and GPT Image 2 — one command, no browser.
Generate AI images for free from your terminal using your ChatGPT Plus/Pro subscription, Gemini Nano Banana, and GPT Image 2 — one command, no browser.
The cheapest way to generate AI images in 2026 is not the OpenAI API. It is not Midjourney. It is your existing ChatGPT Plus subscription — accessed through your terminal, with no browser, no API key, and no per-image bill. The trick is a small open-source CLI called nanaban, which reads your Codex OAuth token and proxies image generation through ChatGPT's backend so every image counts against your ChatGPT Plus / Pro quota instead of an API balance.
Same idea, broader picture. Nanaban unifies three image backends behind one command — GPT Image 2 (free via ChatGPT Plus/Pro), Google Gemini's Nano Banana 2 and Pro (cents per image), and OpenAI's GPT-5 Image and GPT-5 Image Mini via OpenRouter. You type a prompt, you get a file. Auto-named from the prompt. 14 aspect ratios. Script-friendly stdout. Works inside Claude Code, Codex, and Gemini agents as a Skill.
This guide walks through the whole setup. How nanaban works, how to wire up the free path, the four real workflows it unlocks, and where the trade-offs are. By the end you will have a terminal where typing five words produces a PNG in three seconds for zero marginal cost.
For most people, "AI image generation" means a web app — ChatGPT, Midjourney, OpenArt, Gemini. Type a prompt, wait, download. That works for one-off creative asks. It breaks for everything else.
| Use case | Browser pain | Terminal advantage |
|---|---|---|
| Batch generate 50 variations | 50 manual clicks + downloads | One while-loop over a prompts.txt file |
| LLM agent calls image gen as a tool | Impossible without an API | Standard subprocess call with --json output |
| CI pipeline generates social assets | Cannot do — no browser in CI | One CLI command in the workflow file |
| Test prompt variations rapidly | 20 seconds per iteration | 3 seconds per iteration in a terminal |
| Pipe an image into another tool | Download → upload → repeat | Pipe straight to `xargs open` or `imagemagick` |
The browser is the wrong tool for any workflow that touches more than one image. The terminal is where image generation belongs once you treat it as part of a real pipeline.
Install nanaban. Run codex login once. Run nanaban "your prompt". Every image you generate comes out of your ChatGPT Plus / Pro image quota — not an API bill, not Midjourney credits, not anything else you pay for separately.
That is it. If you already pay for ChatGPT Plus or Pro, you have already paid for this. Nanaban just gives you a terminal-native way to use the image quota you are already getting.
Pro tip: The mechanism here is fully legitimate. Nanaban uses the Codex OAuth token that the official Codex CLI writes to~/.codex/auth.jsonwhen you runcodex login. It hits the same backend your ChatGPT app does. You are not jailbreaking anything — you are using your own paid quota through a different client.
Nanaban is an open-source CLI built by Boris Djordjevic at Paperfoot AI / 199 Biotechnologies. It is MIT-licensed, ships as a Homebrew tap, an npm package, and standalone bun-compiled binaries for macOS and Linux. One command, one image, automatic filename, three-second turnaround in normal use.
What sets it apart from a thin OpenAI wrapper:
fox_snowy_forest_dawn.png. Collisions auto-increment.xargs, jq, or anything else.--json flag returns structured output with cost, duration, dimensions, and a fallback audit trail — exactly what an LLM agent needs to consume the result programmatically.nanaban edit photo.png "make it a pencil sketch" runs an image-to-image edit.-r style.png to apply that image's visual language (color, composition, texture) to a fresh generation.nanaban skill install registers it with Claude Code, Codex, and Gemini so an agent can call it directly.Source on GitHub at paperfoot/nanaban-cli. Full skill page on PromptsRush at /marketplace/skills/nanaban-cli.
Homebrew is the easiest path on macOS:
brew install paperfoot/tap/nanaban
npm if you already have Node 18+:
npm install -g nanaban
Or grab a standalone binary from the GitHub releases — bun-compiled, no Node.js runtime required. The macOS Apple Silicon one:
curl -L https://github.com/paperfoot/nanaban-cli/releases/latest/download/nanaban-darwin-arm64 -o /usr/local/bin/nanaban && chmod +x /usr/local/bin/nanaban
For the free GPT Image 2 backend, install Codex CLI and run:
codex login
This writes an OAuth token to ~/.codex/auth.json. Nanaban reads it on demand. From here on, every nanaban generation routes through ChatGPT's backend and decrements your ChatGPT Plus / Pro image quota.
If you do not have a ChatGPT subscription, skip this step and use one of the alternative backends:
nanaban auth set-openrouter # for OpenRouter (Gemini, GPT-5 Image)
nanaban auth set # for Gemini direct
nanaban "cyberpunk tokyo street neon rain"
Three seconds later there is a file in your current directory called something like cyberpunk_tokyo_street_neon_rain.png. Open it.
That is the entire setup. Five lines, three of which are a one-time install. Everything from here is optimisation.
| Backend | Cost per image | Best for | Aspect ratios |
|---|---|---|---|
| GPT Image 2 (via Codex OAuth) | $0 (uses ChatGPT Plus/Pro quota) | Strong text rendering, agentic planning, high fidelity | 1:1, 2:3, 3:2 |
| Nano Banana 2 (Gemini) | $0.067 | Fast batch work, extreme aspect ratios, panoramas | All 14 (including 1:8, 8:1) |
| Nano Banana Pro (Gemini) | $0.136 | Higher detail when budget allows | Standard 10 |
| GPT-5 Image (OpenRouter) | $0.193 | UI rendering, on-image typography | 1:1, 2:3, 3:2 |
| GPT-5 Image Mini (OpenRouter) | $0.041 | Budget OpenAI alternative | 1:1, 2:3, 3:2 |
The honest recommendation for most users: leave the default backend as GPT Image 2 (free), and pin Nano Banana 2 with --via gemini-direct or --model nb2 when you need a panoramic ratio that GPT Image 2 cannot produce.
If you do not have a ChatGPT subscription, Nano Banana 2 is the next-best default at $0.067 per image — cheap enough that a hundred generations cost less than a coffee.
The single biggest reason to leave the browser. Write fifty prompts in a text file, generate all fifty:
cat prompts.txt | while read p; do nanaban "$p"; done
On the free Codex backend this costs $0 (within your ChatGPT image quota). On Nano Banana 2 it costs about $3.35. Total time: under five minutes for fifty images.
Stdout is the file path only. Pipe it to whatever you want next:
nanaban "a red circle" --json | jq -r .file | xargs open
That command generates the image, parses the JSON output for the file path, and opens it in your default viewer. One line.
Edit an existing image with a natural-language instruction:
nanaban edit headshot.png "make it a pencil sketch"
Or apply a style reference to a fresh generation:
nanaban "portrait of a woman" -r vermeer_painting.png
The reference image's color, composition, and texture get applied to the generation. This is the cleanest path we have seen for style-locked product shots — one reference image, dozens of consistent product variations.
The big one for agent builders. Run:
nanaban skill install
This registers nanaban as a callable Skill in Claude Code, Codex, and Gemini. Any of those agents can now call nanaban as a tool — generate an image, get a file path back, use that file path in the next step.
For programmatic use, the --json flag returns a clean structured response:
{
"file": "fox_snowy_forest_dawn.png",
"model": "gpt-image-2",
"transport": "codex-oauth",
"cost_usd": 0,
"duration_ms": 2840,
"dimensions": "1024x1024",
"fallbacks_attempted": []
}
For a Claude Code agent building a thumbnail, this is exactly the contract you want — a known file path, a known cost, a known size, and an audit trail of which backend actually served the request.
The biggest practical difference between backends. If you are working in vertical 9:16 for Shorts or horizontal 16:9 for YouTube, you need Nano Banana 2.
| Aspect ratio | Nano Banana 2 | Nano Banana Pro | GPT Image 2 / GPT-5 |
|---|---|---|---|
| 1:1 (square) | Yes | Yes | Yes |
| 2:3 / 3:2 (standard photo) | Yes | Yes | Yes |
| 9:16 / 16:9 (social, video) | Yes | Yes | No |
| 1:4 / 4:1 (tall / wide) | Yes | No | No |
| 1:8 / 8:1 (extreme panorama) | Yes | No | No |
Resolution caps: GPT Image 2 and GPT-5 variants are 1024px only. Nano Banana 2 goes from 0.5K up to 4K — useful when you want a generation you can use at billboard size without upscaling.
Use the --ar flag to set the ratio and --size for the resolution:
nanaban "panoramic alpine landscape sunset" --ar 4:1 --size 4k
The free path is real but not magic.
codex login. Nanaban surfaces an AUTH_EXPIRED error code so an agent caller can handle the case cleanly.None of these break the use case. They are just the lines you should know exist before you build a pipeline that depends on the free path.
| Tool | Cost | Terminal-native | Best for |
|---|---|---|---|
| Nanaban (Codex backend) | $0 (with ChatGPT Plus/Pro) | Yes | Anyone with a ChatGPT subscription doing scripted image work |
| Nanaban (Gemini backend) | $0.067/img | Yes | Panoramic, vertical 9:16, batch work without ChatGPT |
| Midjourney | $10-30/mo | No (Discord) | Premium creative work, distinctive style |
| OpenAI DALL-E API | $0.04-0.17/img | Yes (via API) | Production app integration with billing tracking |
| OpenArt | Free tier + paid | No | Browser-based with multi-model access (Flux, Midjourney style) |
| ComfyUI + local models | $0 (hardware required) | No (mostly) | Air-gapped pro workflows with full control |
The honest split: nanaban for pipelines, scripts, agents, and any workflow that touches more than one image; OpenArt or Midjourney for browser-based creative exploration; ComfyUI for the air-gapped advanced lane. They are not competitors — they cover different jobs.
To make this concrete, here is the actual five-line pipeline we use to draft thumbnails for new blog posts. The input is a CSV of post titles; the output is a folder of thumbnail candidates.
tail -n +2 posts.csv | cut -d',' -f1 | while read title; do
nanaban "blog thumbnail, $title, bold typography, dark background, indigo accent" --ar 16:9 --model nb2 -o "thumbs/$(echo $title | tr ' ' '_' | tr -d '\"').png"
done
Reading from a 12-row CSV. Nano Banana 2 at $0.067 per image. Total cost: about $0.80. Total time: under two minutes. Browser equivalent: a half-hour of clicking.
For an LLM-driven version of the same workflow, the Claude Code agent calls nanaban --json as a tool, gets the file path back, and decides whether to regenerate based on the response. The agent loop is genuinely well-served by the structured JSON contract.
If you have a ChatGPT Plus or Pro subscription, you should install nanaban today. Five minutes of setup, and every image you generate from your terminal afterward costs you nothing on top of what you already pay. The free GPT Image 2 path alone justifies the install.
Even without a ChatGPT subscription, the multi-backend design makes nanaban a strong default — Nano Banana 2 at $0.067 per image is one of the cheapest serious image generators available, and the script-friendly interface is unmatched. If your workflow touches the terminal at all, this is the tool to wire in.
For the full install instructions, supported features, and FAQ, the skill page is at /marketplace/skills/nanaban-cli.
10 questions answered
How to Use Claude Code for FREE: The Complete 2026 Guide
Jun 12 · 14 min
How to Create a UI Design Skill Using design.md
Jun 12 · 19 min
AI Skills vs Prompts: What's the Difference?
Jun 11 · 18 min
HeyGen Hyperframes Prompts for Editing Videos: 40+ Working Examples
Jun 11 · 18 min
Claude Fable 5 Prompts for Web Developers: UI, Code Review, Debugging
Jun 11 · 18 min