Gemini API 加载器
The Gemini node that runs on your own key, not Comfy credits
- api_instance
Your key, your Gemini
If you've wandered into ComfyUI's official "Gemini" node and bounced off the Comfy Cloud login and credit requirement, this is the node that fixes it. GeminiApiLoader doesn't care about Comfy accounts at all - you paste a Google API key in and it builds the connection every other Gemini node in this pack hangs off of.
It's the power outlet, not the appliance. No network call happens here, nothing is generated, no tokens are spent. It just constructs an httpx client pointed at Google's Generative Language API and hands you a GEMINI_API_INSTANCE to plug into GeminiChat, GeminiFileUploader, and friends. The pack is a converted, cleaned-up version of the author's llm-api-backup repo, and it shows - the plumbing is straightforward.
The author is spawner1145, same dev behind a well-used Wan2.1 extension for Stable Diffusion (someone even shipped an English localization of it). Fair warning before you dive in: the UI strings and README are in Chinese, because the pack's audience skews that way. It won't stop you - the field labels are obvious enough.
The fields that matter
api_key- your key from AI Studio. TheYOUR_GEMINI_KEYplaceholder is not a key; leave it in and the node throws at load time ("API Key 不能为空").model- defaultgemini-2.0-flash-001. It's a free-text string, so any model id works. The pack also adds a small web panel to the loader that can fetch the live model list from your key.base_url- the officialgenerativelanguage.googleapis.comendpoint. Leave it unless you're routing through a relay.proxy_http/proxy_https- for anyone behind the GFW or a corporate proxy. The tooltip example,http://127.0.0.1:7890, is the classic Clash port. Only set these if you actually need them; a dead proxy breaks requests that would otherwise work.timeout- 180s default, up to 600. Bump it if you use thinking models, which can chew through that budget.channel_group- named presets stored in the pack'sgemini.yaml. Set this and it overrides the inline key and base_url, handy if you juggle several keys.
One detail worth knowing: the loader caches its client keyed by a hash of your config. Change nothing and every Chat node downstream reuses a single connection; change the key or model and it rebuilds. Cheap and correct.
Install
Easiest via ComfyUI Manager - search "comfyui-aichat" and install. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/comfyui-aichat
Restart ComfyUI. ComfyUI auto-installs the requirements on first load - just httpx, openai, and PyYAML. No model files, no downloads. All you need is a key from aistudio.google.com, which has a free tier.
Where people get burned
- The key lives in the workflow JSON in plain text. Export or share a workflow with your key in it and you've handed someone a free Gemini account. Strip it before sharing, and don't run ComfyUI exposed to the internet - the ecosystem already saw a malicious LLM node turn into a federal case.
- A wrong model string gives you a confusing API error, not a friendly one. Double-check the exact model id.
- Long thinking responses can outlive the timeout. When in doubt, raise it.
Wire api_instance into GeminiChat and you're actually talking to a model - that's the next step.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | YOUR_GEMINI_KEY | — |
| model | STRING | gemini-2.0-flash-001 | — |
| base_url | STRING | https://generativelanguage.googleapis.com | — |
| proxy_httpopt | STRING | http://127.0.0.1:7890 | |
| proxy_httpsopt | STRING | http://127.0.0.1:7890 | |
| timeoutopt | FLOAT | 18010–600 | — |
| channel_groupopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| api_instance | GEMINI_API_INSTANCE | — |