KS API 生图
The Node That Hands Your Product Photo to a Cloud Image Model
- product_image
- reference
- image
- output_path
This is the payoff node of the whole Kongshan pipeline. Everything upstream - analyze the product, pick a reference, write the strategy - funnels into KSGeminiGenerate, which sends your product photo to a hosted image model and gets back a brand-new shot with the product preserved but the background, lighting, and composition redone. It's the "make my catalog photo look like a magazine ad" node.
What it is
A pure API-wrapper node. No local GPU, no checkpoint, no sampler. Your image and prompt go over the wire, an image is generated on someone else's server, and the PNG comes back as a ComfyUI tensor plus the absolute path where it was saved. The KB's external-api-nodes essay calls this pattern "an HTTP client with your API key baked in," and that's exactly it - which also means it's the node in this pack you should be most careful with, because it's carrying credentials by design.
Out of the box it defaults to provider gemini, model gemini-2.5-flash-image (from the pack's pipeline.config.json), talking to generativelanguage.googleapis.com with your Gemini_API_KEY_FREE or GEMINI_API_KEY env var. Point the provider at openrouter or another OpenAI-compatible endpoint instead and it switches to the /images/generations API with a b64_json response - same node, different backend.
The inputs that matter
product_image- your source product photo. The node explicitly tells the model to "preserve the source product identity precisely, but replace the entire original background, lighting, shadows, framing, and composition." That instruction is the whole game.final_prompt- usually thefinal_promptoutput ofKSDesignStrategy. The clearer it is, the more controlled the result.reference- an optional KS_REFERENCE object; if it carries an image, that goes into the request too.output_prefix- defaultimage_pipeline/result, relative to ComfyUI'soutput/dir. The node appends a timestamp and.png. It enforces that the path stays inside the output directory - point it elsewhere and it raises, which is a nice safety touch.
Outputs: image (tensor, keep wiring it to preview/save nodes) and output_path (the real saved PNG path, handy if you want to hand the file to a CLI tool).
Installing
Same as every node in this pack:
cd ComfyUI/custom_nodes
git clone https://github.com/kongshan4219/ComfyUI-Kongshan-Nodes
restart ComfyUI, and set Gemini_API_KEY_FREE or GEMINI_API_KEY in your environment (copy .env.example to .env). The provider/api_key/model dropdowns start at default and get populated by the pack's frontend extension when ComfyUI loads.
Where people get burned
- It re-calls the API every single run. The node returns
nanfromIS_CHANGED, which disables ComfyUI's caching. Identical inputs will re-bill you and re-generate. Great for iteration, rude for accidentally queueing a workflow twice. - "Gemini returned no image" - the model answered with text instead of an image (content policy, or a model that can't return inline images through
generateContent). The error includes what the model said, so read it before blaming the node. - Timeout - a single generation can take a while; the request timeout is 600 seconds, so slow first images are normal.
- Billing - this is metered, per-image, on your key.
gemini-2.5-flash-imageis cheap but not free, andGemini_API_KEY_FREEis a different quota fromGEMINI_API_KEY. Pick deliberately.
One thing to keep in mind: this pack is tiny and fresh (0 impressions on every node as of now), and the whole API group is one author's workflow for 1688-style Chinese marketplace product photos. If your catalog is on Alibaba's side of the world, this is your person. If not, the mechanics still work fine - you just have to accept the 1688-flavored defaults.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| product_image | IMAGE | 源商品图。Gemini 模式会把它作为图像输入,要求保留商品身份并重做背景、光线和构图。 | |
| final_prompt | STRING | 最终生图提示词,通常来自“生成设计策略”节点。提示越明确,输出越可控。 | |
| reference | KS_REFERENCE | 可选参考图对象。包含图像时会一起提交给 Gemini;为空时仅依据商品图和提示词生成。 | |
| output_prefix | STRING | image_pipeline/result | 输出文件名前缀,相对于 ComfyUI output 目录。节点会自动追加时间戳和 .png,路径必须留在 output 内。 |
| provider | COMBO | default | 图像生成供应商。default 使用配置文件 image_gen.defaults.provider;gemini 走 generateContent,多数其他供应商走 OpenAI 兼容 images/generations。 |
| api_key | COMBO | default | 图像生成 API 密钥名称。default 使用配置文件默认密钥;不同密钥可能对应免费/付费额度。 |
| model | COMBO | default | 图像生成模型。不同模型会影响画质、提示词遵循度、速度、尺寸能力和费用。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| output_path | STRING | — |