NanoBanana - Cost Estimator
Know what a batch run will cost before you run it
- network
- input_tokens
- estimated_usd
- breakdown
If you've ever queued a 10,000-item batch against a paid API and watched the bill climb, this node is for you. It estimates the USD cost of a Gemini prompt before you actually spend anything: it counts your input tokens with the free count_tokens API, multiplies by a per-model price table, adds your expected output tokens, and hands back a number and a readable breakdown.
It's a pre-flight tool, not an accounting tool. The estimate is rough - the output-token figure is your guess, and the price table is a snapshot that goes stale - but "rough and wrong by ten percent" beats "no idea and billed for real."
How it works
The mechanism is short. You give it a prompt and a model; it calls count_tokens (free, doesn't touch quota) to get the real input-token count. Then it looks up the model in an internal price table - prices in USD per million tokens, input and output separately - and computes:
(input_tokens × input_price + expected_output_tokens × output_price) / 1,000,000, times your run multiplier.
Three inputs do the real work:
- expected_output_tokens - your guess at how many tokens the model will produce (default 500). This is the biggest source of error, so don't sweat it; just be in the right ballpark.
- runs - a multiplier for batched workflows. Want to know what 1,000 iterations will cost? Set this to 1000.
- custom_model - if your model isn't in the price table, the node warns and falls back to gemini-2.5-flash rates rather than silently returning zero.
Outputs: input_tokens (the real counted INT), estimated_usd (FLOAT), and breakdown (STRING - the readable per-line math, ideal for a text display node or the console).
Installation
One of the utility nodes in the NanoBanana2 pack:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai
Or search NanoBanana2 in ComfyUI Manager. Needs an API key from aistudio.google.com for the token-count call.
Gotchas
Know its blind spots so you don't trust it too hard. It counts text tokens only - an image-heavy prompt costs more than this node says, because images aren't tokenized by count_tokens. The price table is a snapshot from when the pack shipped; Gemini pricing changes, and for preview models it may have no entry at all (hence the flash-rate fallback). And the output side is fundamentally a guess, since nobody knows the output length until the model answers. Use it to catch the expensive surprises - a runaway context, a huge batch - not to predict a bill to the cent.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | — | |
| model | COMBO | gemini-2.5-flash | 35 options: gemini-pro-latest, gemini-flash-latest, gemini-flash-lite-latest, gemini-3-pro-preview, gemini-3-flash-preview, gemini-3.1-pro-preview, +29 |
| prompt | STRING | — | |
| custom_modelopt | STRING | — | |
| expected_output_tokensopt | INT | 5000–65536 | Your estimate of how many tokens the model will produce. |
| runsopt | INT | 11–1000000 | Multiplier for batched workflows. |
| networkopt | NB_NETWORK | Optional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress). |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| input_tokens | INT | — |
| estimated_usd | FLOAT | — |
| breakdown | STRING | — |