Nodes/ComfyUI-NanoBanana2/NanoBanana - Cost Estimator
ComfyUI Node

NanoBanana - Cost Estimator

Know what a batch run will cost before you run it

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Cost Estimator
  • network
  • input_tokens
  • estimated_usd
  • breakdown
api_key
modelgemini-2.5-flash
prompt
custom_model
expected_output_tokens500
runs1

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.

CategoryNanoBanana2/Config

Inputs (7)

NameTypeDefaultDescription
api_keySTRING
modelCOMBOgemini-2.5-flash35 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
promptSTRING
custom_modeloptSTRING
expected_output_tokensoptINT5000–65536Your estimate of how many tokens the model will produce.
runsoptINT11–1000000Multiplier for batched workflows.
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress).

Outputs (3)

NameTypeDescription
input_tokensINT
estimated_usdFLOAT
breakdownSTRING