Extensions/LLMPromptEnhancerComfyUI
ComfyUI Extension

LLMPromptEnhancerComfyUI

A ComfyUI extension with 1 custom node.

By khurshedgulov·Created 4 days ago·Updated about 21 hours ago· 0
khurshedgulov/LLMPromptEnhancerComfyUI
Nodes1
On cloudLocal install
CategoryLLM
Stars0
Updatedabout 21 hours ago
Readme

LLM Prompt Enhancer for ComfyUI

A ComfyUI custom node that sends your prompt to an LLM API and returns an enhanced version, for use as a prompt-enhancement step ahead of image/video generation nodes.

Supports five providers:

  • claude — Anthropic's Claude API (default model claude-opus-5)
  • openai — OpenAI's API (default model gpt-6-sol)
  • kimi — Moonshot AI's Kimi API, OpenAI-compatible (default model kimi-k3, endpoint https://api.moonshot.ai/v1)
  • deepseek — DeepSeek's API (OpenAI-compatible, default model deepseek-chat)
  • local — any OpenAI-compatible local server, e.g. LM Studio or Ollama (default endpoint http://localhost:1234/v1, LM Studio's default — override base_url for Ollama's http://localhost:11434/v1 or anything else)

openai, kimi, deepseek, and local all go through the same OpenAI-compatible call path; claude uses the Anthropic SDK directly.

Model naming across all providers rotates over time — if a default 404s, check the provider's own model list/docs and set model explicitly.

Installation

  1. Clone or copy this folder into ComfyUI/custom_nodes/.

  2. Install dependencies into the exact Python environment ComfyUI itself runs with — not just any pip install, since that easily targets the wrong Python and the node will fail to import with ModuleNotFoundError: No module named 'anthropic'.

    • Portable/embedded ComfyUI: use python_embeded\python.exe -m pip install -r requirements.txt.

    • ComfyUI Desktop: the runtime venv lives per-install at ComfyUI-Installs\<version>\ComfyUI\.venv\Scripts\python.exe — e.g.:

      "C:\Users\<you>\AppData\Local\Comfy-Desktop\ComfyUI-Installs\<version>\ComfyUI\.venv\Scripts\python.exe" -m pip install -r requirements.txt
      

      Don't confuse this with the standalone-env folder one level up (ComfyUI-Installs\<version>\standalone-env\) — that's a separate shared toolchain, not the runtime. To confirm which interpreter your install actually uses, check Python executable: near the top of the most recent log in ComfyUI-Installs\<version>\logs\.

    • Manual venv install: activate your venv first, then pip install -r requirements.txt.

  3. Provide an API key, either way:

    • Environment variable (recommended — never touches the workflow file): set one of these before launching ComfyUI.

      | Provider | Env var | Required? | |---|---|---| | claude | ANTHROPIC_API_KEY | yes | | openai | OPENAI_API_KEY | yes | | kimi | KIMI_API_KEY | yes | | deepseek | DEEPSEEK_API_KEY | yes | | local | LOCAL_LLM_API_KEY | usually not — most local servers (LM Studio, Ollama) don't check it |

      You can override which env var a given node instance reads from with the api_key_env input.

    • api_key node field: type the key directly into the node. It's rendered as a masked password field with a show/hide toggle button.

      This is a full override: when non-empty, it's used for this node's call, written into the process's environment variable (os.environ) under the resolved name (ANTHROPIC_API_KEY by default, or whatever api_key_env names), and persisted to disk (see Persistence across restarts below). That means every other reader of that variable for the rest of this ComfyUI process — other nodes, other instances of this node left blank, any other queued workflow — picks up the same key too. If you run multiple keys/accounts side by side, keep api_key blank on the instances that should use their own separate env var, or give each instance its own api_key_env name.

      When the field is empty, its placeholder tells you whether the relevant env var is already set — e.g. using ANTHROPIC_API_KEY from environment or api key (optional) — ANTHROPIC_API_KEY not set. It checks via a small local API route (/llm_prompt_enhancer/env_status) that only ever returns a boolean and the variable's name, never its value, and re-checks whenever you change provider or api_key_env.

      The field itself is automatically scrubbed (blanked) whenever ComfyUI serializes the graph — that covers Save, Save As, Export Workflow, and workflow metadata embedded in saved PNGs. So the workflow JSON never has the key in it — see Persistence across restarts below for how the key still comes back without retyping it.

      • "Export (API Format)" is the one exception. That export goes through the same code path as actually running the workflow (Queue Prompt), which has to keep the real key to work — so a key typed into this field can still end up in an exported API-format JSON file. If you plan to export/share the API-format workflow, use the environment variable, not this field.

Persistence across restarts

A key set via api_key is also saved to api_keys.json in this node's own folder, lightly obfuscated with a key stored alongside it in .secret_key (both files are auto-created, and .gitignore'd so they're never committed). This is not real encryption — anyone with filesystem access to this folder has both files and can decrypt it in a few lines of Python. It exists only to keep the key out of a casually-opened plaintext file, matching the same "some friction, not real security" tradeoff as the masked-but-not-secure api_key field itself.

On every ComfyUI startup, this store is read and used to fill in any of the five env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, KIMI_API_KEY, DEEPSEEK_API_KEY, LOCAL_LLM_API_KEY, or a custom api_key_env name) that isn't already set by a real system environment variable — a real env var you set yourself always takes precedence. So in practice: type a key into api_key once, and it keeps working across restarts even though the field itself shows blank — the placeholder will read using ANTHROPIC_API_KEY from environment to confirm it's still there. To rotate or remove a stored key, either type a new one into api_key (overwrites it) or delete api_keys.json and .secret_key from this folder.

  1. Restart ComfyUI. The node appears in the node menu as LLM Prompt Enhancer (category LLM).

Node inputs

| Input | Notes | |---|---| | prompt | The raw prompt to enhance. | | provider | claude, openai, kimi, deepseek, or local. | | model | Model name. Leave blank to use the provider's default. | | system_prompt | Instructions the LLM follows when rewriting the prompt. A sensible default is prefilled — edit it to change the enhancement style. | | max_tokens | Output token cap. | | api_key (optional) | Masked password field. Full override when set — used directly and written into the process env var for everything else to pick up too. See the note above. | | temperature (optional) | Sampling temperature — applies to openai/kimi/deepseek/local only. Claude's current adaptive-thinking models (e.g. claude-opus-5) reject sampling parameters, so this is ignored for claude. | | effort (optional) | Thinking effort (low…max) — applies to claude only. | | base_url (optional) | Override the API endpoint — applies to openai/kimi/deepseek/local only. | | api_key_env (optional) | Override which environment variable to read the API key from. |

Output: enhanced_prompt (STRING).

Notes

  • The claude branch uses claude-opus-5 by default and enables Anthropic's server-side refusal fallback so a declined request automatically retries on a fallback model.
  • If you point model at an older Claude model (pre-adaptive-thinking), the effort widget may not apply — check that model's API docs.