Nodes/ComfyUI AnyNode: Any Node you ask for/Any Node πŸ„ (Local LLM)
ComfyUI Node

Any Node πŸ„ (Local LLM)

The AnyNode that codes on your own GPU, not an API key

By lks-aiΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 547
Any Node πŸ„ (Local LLM)
  • any
  • any2
  • any
  • control
β—„promptTake the input and multiply by 5β–Ί
β—„modelmistralβ–Ί
β—„serverhttp://localhost:11434β–Ί
β—„api_keyollamaβ–Ί

The name is the pitch: this is the mushroom node that doesn't touch the cloud. No OpenAI key, no Anthropic key, no Gemini key. You describe what you want a node to do in plain English, it forwards your request to whatever LLM server you point it at - almost always Ollama on your own machine - and the LLM writes a Python function that ComfyUI executes right there in the graph. Of the four AnyNode variants this is the one people actually search for, and the most requested feature the pack ever got, per the README.

Mechanically it's simple and kind of magic. You connect any input you like into the node, and it introspects whatever's flowing in - its type, tensor shape, dtype, structure - and stuffs that description into the prompt it sends to an OpenAI-compatible ChatCompletions endpoint at the server address (default http://localhost:11434, which is exactly where Ollama listens). The LLM replies with a generated_function; an AST-based code sanitizer scans it for dangerous constructs; and then the function runs in-process and its return value comes out the any output. Screw up, and the fix is absurdly easy: hit Queue Prompt again and it shows the error to the model and retries with error mitigation. It even keeps the last generated function as the example for the next generation, so successive runs get smarter.

The inputs that matter are few:

  • prompt - the whole game. "Take the input and multiply by 5" is the default, and honestly still the best way to learn it.
  • server - base URL of your local or hosted endpoint. Leave it as localhost unless you know why you're changing it.
  • model - the model name string your server serves (default mistral).
  • api_key - defaults to "ollama", which Ollama accepts and ignores. Set a real key only if you point at a hosted OpenAI-compatible provider like vLLM.

any and any2 are optional wildcard inputs, and there are two outputs: any (the result, wire it anywhere) and control - a metadata dict carrying the generated function, prompt, and run info, which is what feeds the pack's export-to-node tooling.

Install is the standard two-step: search AnyNode in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/lks-ai/anynode, then restart. The requirements.txt looks scary - torch, torchaudio, torchvision, opencv, scikit-learn, chromadb, matplotlib - but nearly all of that is already in your ComfyUI environment, so it mostly resolves as already-satisfied. The real prerequisites are the openai client module and a running LLM server.

Here's the security thing you need to actually hear, because it's the difference between fun and regret. This node executes code that comes back from whatever server you point it at. Point it at localhost and you're safe. Point it at some random hosted endpoint and you are handing a stranger the ability to run Python inside ComfyUI. The README says this louder than any article can: only use addresses you absolutely trust. The built-in sanitizer blocks eval, exec, subprocess, os, file writes and the like, and curated imports mean the function's runtime only exposes an allowlisted set of libraries - but that's a speed bump, not a wall. Oh, and the project's dead: last commit was June 2024. It still works fine with Ollama because the Ollama API hasn't moved, but don't expect updates.

Where people get burned: smaller models write worse code - a 7B model will happily produce something that only looks like working Python, so the local variant leans on that error-mitigation retry loop a lot. The generated code only shows up in the console, which makes debugging opaque. And because any can link to any node, you can absolutely crash ComfyUI if you feed it something enormous. Keep it to single-purpose image transforms - sepia filters, Sobel edges, channel surgery - and it's a genuinely delightful way to prototype a node without knowing how to write one.

Categoryutils

Inputs (6)

NameTypeDefaultDescription
promptSTRINGTake the input and multiply by 5β€”
modelSTRINGmistralβ€”
serverSTRINGhttp://localhost:11434β€”
anyopt*β€”
any2opt*β€”
api_keyoptSTRINGollamaβ€”

Outputs (2)

NameTypeDescription
any*β€”
controlCTRLβ€”