comfyui-gemini-ownkey
A ComfyUI extension with 2 custom nodes.
Nodes (2)
ComfyUI Gemini Own Key
Run Nano Banana Pro (gemini-3-pro-image-preview) and other Google Gemini image models in
ComfyUI on your own Google billing — no ComfyUI credits.
ComfyUI's built-in Nano Banana Pro (Google Gemini Image) node is an API node: it routes through
api.comfy.org and charges ComfyUI credits. There is no field for your own Google key because the
node was never designed to accept one. This custom node talks to Google directly instead.
It supports two backends, which matters more than it sounds:
| Backend | Endpoint | Auth | Google Cloud $300 trial credit |
|---|---|---|---|
| AI Studio | generativelanguage.googleapis.com | API key | ❌ excluded by Google |
| Vertex AI | aiplatform.googleapis.com | gcloud login / service account | ✅ applies |
Since March 2026 Google explicitly excludes Gemini API in AI Studio from the $300 Cloud free trial. Every other ComfyUI Gemini node uses the AI Studio endpoint, so the trial credit cannot pay for them. The Vertex backend exists specifically to solve that.
Sources: Free Cloud features · Gemini API billing
Nodes
| Node | Inputs | Outputs | |---|---|---| | Nano Banana Pro (own API key) | prompt, up to 14 reference images (optional) | IMAGE, text | | Gemini Text/Vision (own API key) | prompt, images (optional) | text |
Both appear under the category Gemini (own key).
Widgets mirror the built-in node: prompt, backend, model, seed, aspect_ratio,
resolution (1K/2K/4K), response_modalities, system_prompt, api_key, timeout, plus
reference_mode (below). Leave images unconnected for text-to-image; connect a
Batch Images node for image-to-image or multi-reference work.
reference_mode — stop it copying faces
By default Gemini treats an attached image as something to preserve, so a reference photo tends to drag the person's face into the result even when your prompt describes someone else entirely. Gemini exposes no reference-strength parameter, so this node steers it with instruction wording appended after the images — where image models weight instructions most heavily.
| Mode | Behaviour |
|---|---|
| prompt first (no face copy) (default) | Images inform mood, lighting, palette, wardrobe and setting only. Faces and identities are not reproduced; the written prompt wins any conflict. |
| balanced | Images guide style, composition and subject matter. A likeness is kept only if the prompt explicitly asks. |
| match subject (copy likeness) | Deliberately preserves the person's face and identity, applying the prompt as pose/wardrobe/lighting changes. |
| off | No added instruction — raw model behaviour. |
Same prompt ("a woman in her fifties with grey hair in a kitchen"), same seed, same reference photo
of a man: prompt first produced the woman as described while borrowing the reference's warm
palette and wardrobe, and match subject kept the man's face and overrode the prompt.
This is instruction steering, not a hard constraint — it is reliable in practice but not a
guarantee. The directive is only sent when images is actually connected.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/haristahir1/comfyui-gemini-ownkey
No dependencies for the AI Studio backend — it uses requests, torch, numpy and Pillow,
all of which ComfyUI already has.
For the Vertex backend:
python_embeded\python.exe -m pip install google-auth
Then restart ComfyUI.
Setup — Vertex AI (recommended, works with the $300 trial)
- Install the Google Cloud CLI.
- Log in. Both commands are needed — the second is the one Python reads, and it is easy to miss:
gcloud auth login gcloud auth application-default login - Enable the API on your project:
gcloud services enable aiplatform.googleapis.com --project=YOUR_PROJECT_ID - Copy
config.json.exampletoconfig.jsonand set your project:
Leave{ "vertex": { "service_account_json": "", "project_id": "your-project-id", "location": "global" } }service_account_jsonempty to use your gcloud login. To use a service account instead, give it the Vertex AI User role and put the JSON key path there. - Verify:
python_embeded\python.exe ComfyUI\custom_nodes\comfyui-gemini-ownkey\check_vertex.py - In the node, set
backendto Vertex AI (service account).
Setup — AI Studio
Get a key at aistudio.google.com/app/apikey, then put it
in config.json:
{ "api_key": "AIza..." }
GEMINI_API_KEY / GOOGLE_API_KEY environment variables work too. Verify with:
python_embeded\python.exe ComfyUI\custom_nodes\comfyui-gemini-ownkey\check_key.py --list-only
--list-only costs nothing — it just lists the models your key can see. Drop the flag to run a
real (billed) generation test.
Security
- Prefer
config.jsonover theapi_keywidget. Widget values are saved into workflow JSON and into ComfyUI error reports, so a key typed into the node travels with every workflow you share or paste.config.jsonis gitignored and never leaves your machine. - On the Vertex backend no key is sent at all — leave
api_keyblank. - If your key has ever appeared in a screenshot, a shared workflow, or an error report, rotate it.
Billing notes
- These image models have no free tier. Some billing must be set up either way.
- AI Studio uses prepaid credits and will return
429 RESOURCE_EXHAUSTEDat zero balance. - Vertex bills the Cloud project, where trial credits do apply.
- Model ids differ between the two: AI Studio uses
gemini-3-pro-image-preview, Vertex serves the same model asgemini-3-pro-image. The node translates this for you. seedis an int32 on Google's side; the widget is capped accordingly.
Troubleshooting
| Error | Cause |
|---|---|
| 429 prepayment credits depleted | AI Studio balance is zero — top up, or switch to Vertex |
| 403 SERVICE_DISABLED | run the gcloud services enable step |
| 403 PERMISSION_DENIED | service account is missing the Vertex AI User role |
| 404 on a Vertex model | try "location": "us-central1" instead of "global" |
| Vertex mode needs credentials | you ran gcloud auth login but not gcloud auth application-default login |
check_key.py and check_vertex.py diagnose each backend independently and never print your
credentials — run those first when something breaks.
License
MIT — see LICENSE.