JM Gemini Reverse Engineering
Gemini image generation without an API key — the cookie hack
- image1
- image2
- image3
- image4
- image5
- image6
- image7
- image8
- image9
- image10
- image
The name is not a metaphor. JMGeminiReverseGenerator is reverse engineering, in the literal sense: instead of calling Google's paid Gemini API with an API key like the pack's Image Generator does, it impersonates the gemini.google.com website using cookies stolen from your own logged-in browser session. No key, no per-image billing - you're just using whatever free access your Google account already has.
That makes it the "free" option in this pack, and the most fragile. Every layer of the stack can break - cookies expire, Google rotates tokens, the web endpoint changes shape - and the author's own docs assume you can follow F12 → Network → find the StreamGenerate request → copy the Cookie header, which is not beginner territory. But for the model choices alone (gemini-3.0-flash, gemini-3.0-pro, gemini-3.0-flash-thinking) it's a genuinely useful way to poke Gemini's newer chat models from inside a workflow.
How it works
First run: paste a full cookie string into the cookies_raw input. It should come from the request headers of any request on gemini.google.com after you've sent a message in the web app. The node parses out __Secure-1PSID and __Secure-1PSIDTS, then fetches the page to auto-extract SNlM0e (the auth token) and PUSH_ID (used for image uploads), and saves everything to config/gemini_cookies.json in the pack folder. After that first run you can leave cookies_raw empty - it loads from the config file.
Then it's basically a chat-completions call in OpenAI format against the web backend. If you've attached images (up to 10), they're base64-encoded as PNG and dropped into the message. The reply comes back with markdown-style image references like ; the node finds those, pulls the matching file from its media cache, saves it to ComfyUI/output/, and returns it as an IMAGE tensor.
One honest heads-up: it returns the first generated image, so if Gemini gives you a text response instead - filtered, or it decided your prompt didn't warrant a picture - you get an error showing the first 500 characters of the reply. That's your debugging breadcrumb.
The inputs
- prompt (required) - what you want generated.
- model (required) -
gemini-3.0-flash(default),gemini-3.0-pro, orgemini-3.0-flash-thinking. - seed (required) - the tooltip is honest: it's only used for ComfyUI re-execution and is never passed to Gemini. Decorative, like in the pack's other nodes.
- cookies_raw (optional) - the paste-once cookie string described above.
- image1..image10 (optional) - for image inputs.
Output: a single image (IMAGE) tensor, wired into Preview/Save as usual.
Installing
Same shared pack install as the rest of the family:
cd ComfyUI/custom_nodes
git clone https://github.com/synthetai/ComfyUI-JM-Gemini-API
cd ComfyUI-JM-Gemini-API
pip install -r requirements.txt
Restart ComfyUI, or search "ComfyUI-JM-Gemini-API" in ComfyUI Manager. No model files, no VRAM cost.
The big caveats
- It's a terms-of-service gray zone. You're driving a website endpoint you didn't pay for, with your account's credentials, from automation. Google notices and kills sessions. Expect it to break; treat it as a toy, not a production pipeline.
- Your cookies are your account. The config file literally contains your Google session tokens. The author's docs scream this too: don't share
config/gemini_cookies.json, don't commit it anywhere public, and be ready to log out/in and re-paste when it expires (usually after a few weeks). - "Config is invalid" -
SNlM0eorPUSH_IDdidn't auto-fetch. The manual-config route (copyingSNlM0efrom page source andpush-idfrom a Network request) is documented inconfig/README_Cookie配置说明.mdinside the pack, but it's tedious.
If the fiddliness scares you, the pack's normal Image Generator costs money but just works. This node is for when you want Gemini's newer models and you're willing to babysit a browser cookie in exchange.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| model | COMBO | gemini-3.0-flash | 3 options: gemini-3.0-flash, gemini-3.0-pro, gemini-3.0-flash-thinking |
| seed | INT | 00–18446744073709550000 | 用于 ComfyUI 重新执行,不传给 Gemini |
| cookies_rawopt | STRING | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — | |
| image7opt | IMAGE | — | |
| image8opt | IMAGE | — | |
| image9opt | IMAGE | — | |
| image10opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |