// AGENT MEDIA · HOW-TO

Image generation from the command line

Two commands get you a working image generator in a terminal: npm i -g @clize/clize, then clize login. The third command generates. You do not obtain an OpenAI or Google API key, do not export anything into your shell profile and do not sign up with a model vendor — the hosted path carries a platform credential, so there is no secret of yours to store or rotate. Every generation prints a quote first and charges nothing until you add --confirm; one image is $0.05. The bytes land on disk as a file, not as a blob in your terminal, which is what makes the next command in the pipeline possible.

No provider API keyQuote before chargeWrites a real fileReconnects to long jobs

How to generate an image from the command line

Three commands, no API key and no configuration file. The first two are once per machine; the third is the one you will run again.

  1. Install the CLI. Run npm i -g @clize/clize. It needs Node 20 or newer and installs the clize command globally. If you manage Node with volta, asdf, nodenv, pnpm or bun, clize update knows about that and verifies the running version after upgrading.
  2. Log in once. Run clize login. It opens a browser to authorise with GitHub, Google or email; --github uses the device flow and --token pastes a key manually for CI. This is the only credential involved — there is no model-vendor key to fetch afterwards.
  3. Ask for a quote, then confirm. Run clize gen image "your prompt". With no --confirm flag it prints the price and spends nothing. Add --confirm and the same command generates the image and writes it to ./clize-assets/ unless you point --out somewhere else.

Three commands, and one of them is free to try

Nothing is configured in between. After the install and the login, the generator is a command:

$ npm i -g @clize/clize
$ clize login
$ clize gen image "a red bicycle leaning on a wall"

That third line, exactly as written, does not generate anything. It returns the price:

{
  "quote": {
    "model": "gpt-image-2",
    "modality": "image",
    "estUsd": 0.05,
    "currency": "USD"
  },
  "message": "📋 Quote about $0.05 (image). Add --confirm to generate
   (confirm: true in MCP; charged to your clize balance, refused if it is insufficient)."
}

Add --confirm and the same command generates. That split is the whole safety model, and it is worth understanding before you wire this into a script: the flag is required on every generation, there is no pre-approved allowance that skips it, and there is no spending ceiling you can set instead. A loop that forgets the flag burns no money; a loop that includes it spends five cents per iteration, visibly, on a prepaid balance that refuses the call when it runs dry.

If you want the agent in your editor to drive this rather than you, clize install writes the skill into Claude Code and into the shared ~/.agents/skills directory that Codex, Pi and OpenClaw read. Run it with --dry-run first and it prints exactly what it would touch and writes nothing.

The API-key problem, solved by not having one

Read the other command-line image generators for this search and one section keeps reappearing under different names: how the tool looks after your provider key. The most thorough page in the results gives it a whole onboarding script and instructs the agent, in as many words, never to ask you to paste an API key into the chat — dpf login opens a browser and approves the machine instead. Careful design, and also an answer to a problem the design created: the tool needs a credential that belongs to you, so now the credential has to be looked after.

The hosted path here does not have that problem to solve, because the upstream credential is not yours. It is a platform credential the operator configures once; you never see it, never paste it and never rotate it. What you hold is a clize session created by clize login, and its blast radius is your prepaid balance rather than a model vendor account with a billing address attached.

Three consequences follow. A new machine takes thirty seconds — install, log in, generate, with no key to dig out of a password manager. CI is not a special case: clize login --token takes a key for headless environments and no vendor secret reaches the build. And an agent can run unattended without you deciding in advance how much of your OpenAI account it may spend, because it cannot reach your OpenAI account at all.

The honest trade is model choice. A CLI that takes your key can point at anything that key opens; this one offers what it hosts — gpt-image-2 and nano-banana-2, the latter resolving upstream to nano-banana-pro. Two models, one price. If you need a specific fine-tune on a specific marketplace, use a different tool.

What comes back is a file, not a blob

This decides whether a generator is scriptable, and most tutorials skip it. A confirmed run writes the bytes to disk and prints metadata about them — not base64 into your terminal, and not a megabyte of image data for an agent to carry in its context window.

The successful response adds two things to the job record you already saw in the quote: a files array, where each entry is a path and a byte count, and a hint that reads, verbatim, "Image written to disk — Read it and judge yourself; once satisfied deploy it into a site or attach it to an email." Default location is ./clize-assets/<job id>_<index>.png; --out ./hero.png overrides it, and with several images the index is appended to the name you chose.

A path on disk is a composable thing, which is the whole reason to want a CLI instead of a web app. Two pipelines the same install already covers:

# generate, then publish it as part of a site
$ clize gen image "hero image, wide, dark background" --out ./site/hero.png --confirm
$ clize deploy ./site

# generate, then attach it to an outbound email (draft first — --confirm sends)
$ clize gen image "invoice header, minimal" --out ./header.png --confirm
$ clize email send --to buyer@example.com --subject "Your order" --attach ./header.png

Note that the second pipeline has two independent gates rather than one. Generating charges only with --confirm; sending mail to a stranger also returns a draft until --confirm. The CLI's own help for that flag reads "attachment paths, comma-separated (e.g. an image from gen image)", which tells you the pairing is designed rather than incidental.

Because the file exists, an agent can look at what it made: read the PNG back, judge it against the brief, change the prompt, generate again — a loop that is impossible when the output is a link it cannot open.

Reference images, masks, and asking for several at once

Text-only prompting runs out quickly once you need the same product, the same character or the same palette twice. Three flags cover most of it, and each has a limit that is enforced before anything is charged rather than after.

FlagWhat it doesLimit
--ref a.png,b.pngImage-to-image, edits and composition. Read from disk and uploaded for you.16 on gpt-image-2, 14 on nano-banana-2. 10MB each encoded, 80MB in total.
--mask m.pngInpainting: repaint part of a base image.Needs a base image via --ref, and only works on the nano-banana models.
--n 4Several images from one job.Only meaningful on nano-banana-2.
--size 1024x1024, --out, --modelDimensions, destination, which of the two models.The quote does not change with size.

The refusals are worth showing, because a tool that fails clearly is a tool you can script against. All three of these were produced on 4 September 2026 by running the command; none of them cost anything:

$ clize gen image "a red bicycle" --n 4
❌ [400] gpt-image-2 uses the async path and makes 1 image per job;
   run several jobs for more, or use --model nano-banana-2.

$ clize gen image "…" --model nano-banana-2 --mask m.png
❌ --mask inpainting needs a base image via --ref (the mask only applies to the base image).

$ clize gen image "…" --mask m.png --ref a.png
❌ [400] The gpt-image-2 async path does not support --mask yet;
   use --model nano-banana-2 for inpainting.

The batching rule in practice: twelve variants means twelve jobs on gpt-image-2, or one job with --n 12 on nano-banana-2. A shell loop over a file of prompts does the first — and that is where quote-first earns its keep: run the loop once without --confirm and you get twelve prices and zero charges, a dry run you did not have to build.

When a job takes minutes and the session drops

gpt-image-2 runs on an asynchronous path: the command submits the job and then waits for it, up to --timeout seconds, 300 by default. Most images come back well inside that. Some do not, and the CLIs built around a single blocking call have nowhere to put the ones that do not.

Three commands make a long job survivable, and they are the same three that make video usable at all:

$ clize gen image "…" --async          # submit and return the job id immediately
$ clize gen jobs                       # running jobs first, then recent ones
$ clize gen status gen_1a2b3c4d        # poll one job once; may complete and write to disk

clize gen jobs is the reconnect point after a session break, and it is deliberately blunt about scale. On the account used to check this page it answers with "count": 1414, "running": 4 and a note that only 50 are listed, every running one included. Four jobs were still in flight from a July session; none of them was lost, and none of them needed the terminal that started them to still be open.

clize gen status polls the provider once. If the job finished while you were away, that call is what materialises the file on disk. If the id is wrong, it says so rather than hanging: ❌ [500] Generation job gen_nonexistent not found (clize gen jobs shows them all). And clize gen list --modality image is the record afterwards — id, model, state, prompt, cost, one row each, filterable by modality and scoped to the checked-out project when you have run clize use.

An agent that starts a job, gets interrupted and returns in a new session can therefore find its own work from the CLI alone. Long jobs are the normal case for video rather than the edge case — see generating video from the command line, where a render can take sixteen minutes.

What it costs, and what a failure costs

One image is $0.05 on either hosted model. Asking for several in one job on nano-banana-2 scales as you would expect, with the rounding falling your way: two quote $0.10, four quote $0.19, ten quote $0.48. Reference images add nothing — the quote for one image with two --ref files attached is still $0.05, because the price depends on images out and never on images in. Video is $0.48 a clip and music $0.12 a track on the same gate.

A generation that fails is refunded in full, and the mechanism is worth stating precisely: the job record keeps the amount it quoted, and the money returns as a separate credit on your balance labelled with the failure reason. Read clize balance, not the job record, to see what you actually paid.

What has no equivalent here is a spending cap you set yourself. There is no monthly allowance and no budget command; the whole control surface is the --confirm flag on each call. A credit ceiling stops a runaway after it has spent up to the ceiling; a per-call flag stops it at zero, but also means you cannot hand an agent a budget and walk away.

How this compares to the other command-line generators

ToolChoose it ifRead 4 Sep 2026
Open-source CLIs on GitHubYou want the source, your own key and no intermediary at all.You supply and store the provider key; no quote step, no refunds, no hosted balance.
dreampixelforge (dpf)You want a brand-aware creative system with vision checks and a hard credit cap per run.Browser approval per machine, an account of its own, and its own MCP endpoint.
wondaIts marketing-automation framing is what you are after.Still "Join the waitlist" on the homepage.
Vendor APIs directlyYou need a specific model, a specific resolution tier or volume pricing.You are writing the wrapper yourself.
clizeYou want no provider key, one flat price, a quote before every charge, files on disk and jobs that survive a session.Two image models, no user-settable budget, prepaid balance.

Pricing the batch rather than the call is a separate exercise, and the image generation cost calculator does it against eleven published rates. For one model in particular, what Nano Banana Pro costs on each route works through the subscription, official and resale numbers.

// FAQ

How do I generate an image from the command line?

Install a CLI that talks to an image model, then run one command. With Clize that is npm i -g @clize/clize, then clize login, then clize gen image "your prompt". The third command prints a quote and spends nothing; adding --confirm generates the image and writes it to ./clize-assets/ or wherever --out points. No provider API key is involved at any step.

Do I need my own OpenAI or Google API key?

Not on the hosted path. The upstream credential is a platform credential the operator configures once, so there is nothing for you to obtain, paste into a config file, export into your shell or rotate later. The only credential on your machine is the clize session that clize login creates, and what it can spend is your prepaid clize balance.

Where does the generated image go?

To a file. By default ./clize-assets/<job id>_<index>.png, or wherever --out points; with several images the index is appended to the name you chose. The command prints the path and byte count rather than the image data, which is what lets the next command use it — clize deploy for a site, or clize email send --attach for an outbound message.

Can I generate several images in one command?

On nano-banana-2, yes: --n 4 returns four images from one job and quotes $0.19. On gpt-image-2 no, and it says so rather than silently returning one — "gpt-image-2 uses the async path and makes 1 image per job; run several jobs for more, or use --model nano-banana-2". For a batch across many prompts, a shell loop over the command is the normal approach.

What happens if a generation takes several minutes or my session drops?

Run it with --async and the command returns a job id immediately instead of waiting. clize gen jobs lists everything still running plus recent history, so a new session can find work started by an old one, and clize gen status <id> polls a single job once and writes the file to disk if it has finished. Nothing is lost when the terminal that started the job is closed.

How much does each image cost, and what if it fails?

A flat $0.05 per image on either hosted model, with reference images adding nothing to the quote. A generation that fails is refunded in full as a credit on your balance — note that the job record still displays the amount it quoted, so read clize balance rather than the record to see what you actually paid. There is no free tier and no spending cap you can set; the control is the --confirm flag on every call.

clize gen image — a quote first, a file afterwards

Generate one from your own terminal.

Install, log in, and run the command without --confirm. You will get the exact price for your prompt and your model, and nothing will be generated or charged until you add the flag.

$ npm i -g @clize/clize && clize login
$ clize gen image "a red bicycle leaning on a wall"
$ clize gen image "a red bicycle leaning on a wall" --out ./bike.png --confirm
[ Agent Media by Clize → ]