URL Gemini图像编辑丨API
Gemini image editing against the gateway of your choice
- image
- image2
- image3
- image
- raw_response
- status
- debug_info
The stock GeminiEditAPI only talks to Google AI Studio. CustomURLGeminiImageEditAPI is the version that lets you point Gemini's image-editing capability at whatever base URL you like - Google's native endpoint, a Vertex-style setup, or one of the reseller gateways (the pack's own tooltip suggests https://api.apiyi.com as an example) that proxy Gemini image models with easier billing. If you've been burned by the friction of a Google Cloud project, this node is the "paste a gateway key and go" route. The cost tradeoffs - reseller undercutting, region access, looser onboarding - are the ones the KB's external-API essay documents for the whole Nano-Banana-style proxy layer.
It's part of ComfyUI-QING's API category. Mechanically it's a different animal from the OpenAI-style nodes: this one calls Gemini's generateContent REST format directly, not chat completions.
How it works. You give it a base_url (the Gemini-compatible root, e.g. https://api.apiyi.com) and a model ID (the tooltip's example is gemini-3-pro-image-preview). It builds a generateContent request: your prompt becomes the first text part, and the image(s) - up to three via image2/image3 - are attached as independent inlineData parts. Then the Gemini-specific controls kick in: aspect_ratio (ten ratios from 1:1 to 21:9), image_size (1K/2K/4K), and response_modalities (IMAGE or TEXT,IMAGE) map into generationConfig. The key-sending mode is the thing most people get wrong, and it's a dropdown: Authorization Bearer (what gateways usually want), x-goog-api-key (native Gemini style), query key, or none for endpoints with no auth.
The inputs that matter.
prompt- the edit instruction.image- required; the main image to edit.base_urlandmodel- the gateway root and its model ID.api_key_mode- pick Bearer for gateways,x-goog-api-keyfor native Gemini.aspect_ratio,image_size,response_modalities- the output geometry/format controls.timeout_sec(default 300 - image generation is slow).- Optional:
image2/image3,custom_headers_json,extra_body_json,api_key_override.
Outputs: image (IMAGE), raw_response, status, debug_info.
How to install. ComfyUI-QING is a one-pack install - search "ComfyUI-QING" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart after installing. The README's clone URL is typo'd (GAOSHI-QING, missing the H) - use the URL above or Manager.
Troubleshooting. api_key_mode is where almost everyone stumbles: a gateway that expects Authorization: Bearer will 401 if you leave the node in the native x-goog-api-key mode, and vice versa - switch the dropdown before you question the key itself. Second, base_url must be the Gemini-compatible root, not a /v1/chat/completions endpoint - this node doesn't speak OpenAI format. Third, if you get "modalities" errors, check response_modalities against what the gateway supports (TEXT,IMAGE needs a model that returns text alongside the image). And the honest cautions: gateways may run looser moderation than Google's first party, but the model still enforces its own refusals; your images go to a third party; and the "reseller undercutting" price is real but so is the risk of an unknown endpoint handling your prompts - only point this at a gateway you have a reason to trust.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | 图像编辑指令,只作为第一个 text part 发送 | |
| custom_headers_json | STRING | 可选JSON对象,例如 {"X-API-Key":"..."} | |
| extra_body_json | STRING | 可选JSON对象,会合并进请求体顶层 | |
| image | IMAGE | 要编辑的主图像 | |
| base_url | STRING | Gemini兼容服务根地址,如 https://api.apiyi.com | |
| model | STRING | Gemini图像模型ID,如 gemini-3-pro-image-preview | |
| api_key_override | STRING | 仅当前节点生效;留空时读取 CUSTOM_URL_API_KEY 或 QING custom_url_api_key | |
| api_key_mode | COMBO | Authorization Bearer | API密钥发送方式:网关常用Bearer,Gemini原生常用x-goog-api-key或query key |
| aspect_ratio | COMBO | 1:1 | 10 options: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, +4 |
| image_size | COMBO | 1K | 3 options: 1K, 2K, 4K |
| response_modalities | COMBO | IMAGE | generationConfig.responseModalities |
| timeout_sec | INT | 3005–900 | — |
| image2opt | IMAGE | 可选第二张参考图,作为独立 inlineData part 发送 | |
| image3opt | IMAGE | 可选第三张参考图,作为独立 inlineData part 发送 |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| raw_response | STRING | — |
| status | STRING | — |
| debug_info | STRING | — |