PyCode Max
Run Python Inside Your ComfyUI Graph (Carefully)
- img_in_1
- img_in_2
- mask_in
- latent_in
- positive
- negative
- model
- clip
- vae
- audio_in
- video_in
- custom_in_1
- custom_in_2
- trigger
- txt_out_1
- txt_out_2
- txt_out_3
- txt_out_4
- int_out_1
- int_out_2
- float_out_1
- float_out_2
- img_out_1
- img_out_2
- mask_out
- latent_out
- positive
- negative
- model
- clip
- vae
- audio_out
- video_out
- custom_out_1
- custom_out_2
- Console
PyCode Max is the reason the whole Orion4D_MetaNode pack exists. Every other node in the suite is a convenience; this one is the engine. It drops a Python interpreter into the middle of your workflow - you write code, it runs against the actual tensors, strings, models, and latents flowing through your graph, and the result feeds right back into the pipeline.
Concretely: any connected input lands in an IN dict, your script reads it, writes results to OUT, and those become the node's outputs. IN["img_in_1"] is a PIL image of whatever you plugged in; IN["model"] is the actual model object. OUT["txt_out_1"] = "hello" and it appears on the wire. You also get STATE, a per-node dict that persists between runs (so you can keep a counter or a cache alive), and torch, np, Image, json, math, os, time are all pre-imported for you.
The inputs. source picks between text_input (type code in the box) and file (run a .py from the pack's pyscripts/ folder - examples like Ollama_vision.py and read_png_metadata.py ship with it). Universal inputs cover txt, int, float, image, mask, latent, conditioning, model, clip, vae, audio, video, plus two wildcard custom_in slots and a trigger. timeout_sec (5–600, default 120) guards against infinite loops, and clear_state wipes the persistent STATE.
The helpers are the hidden value. The execution scope injects llm and gpu dictionaries. llm["generate"](prompt, model="qwen2.5-vl:7b", images=IN["img_in_1"]) talks to a local Ollama server - vision included, so you can describe an image mid-workflow and pipe the caption into a prompt. gpu["torch_vram"]() and gpu["vram"]() read VRAM from inside your script (the latter needs pip install nvidia-ml-py). This is the local-LLM-in-the-graph pattern the community has been converging on, minus the boilerplate.
Now the honest part. This node executes arbitrary Python with full user-level access. The author got real pushback on Reddit about exactly that, and the design response is sound: text_input mode is locked by default. You must edit config.json in the pack folder and set "developer_mode": true before typed code will run. That's deliberate - loading a shared workflow with a PyCodeMax node is, with dev mode on, equivalent to running a script from the internet. Keep it off unless you wrote the code, and if you must run untrusted workflows, run ComfyUI in a container. This is the same class of risk that produced the LLMVISION incident, and it's worth taking seriously.
Install. ComfyUI Manager → search "Orion4D_MetaNode", or git clone https://github.com/orion4d/Orion4D_MetaNode into custom_nodes/, then restart. No heavy deps for the core; nvidia-ml-py is optional and only powers the gpu["vram"]() helper.
Troubleshooting. Getting the "text_input is blocked" error is expected behavior, not a bug - flip developer_mode if you mean it. A file-source script that wasn't in pyscripts/ when ComfyUI started is refused until you restart (or enable dev mode). Console output, timing, and script doc-comments all show up in the node's built-in Console output. And if a run hangs, your timeout_sec is the fuse.
It's the most powerful node in the pack, and the most dangerous. Use it like a loaded tool.
Inputs (27)
| Name | Type | Default | Description |
|---|---|---|---|
| source | COMBO | 2 options: text_input, file | |
| code | STRING | # Your Python code is here, important: enable developer mode in config.json and set it to "true" | — |
| script_file | COMBO | 6 options: None, clipping_BiRefNet.py, Ollama_vision.py, read_png_metadata.py, Ollama_txt-v1.py, Latent_Megapixel_Builder.py | |
| timeout_sec | INT | 1205–600 | — |
| clear_state | BOOLEAN | false | — |
| txt_in_1opt | STRING | — | |
| txt_in_2opt | STRING | — | |
| txt_in_3opt | STRING | — | |
| txt_in_4opt | STRING | — | |
| int_in_1opt | INT | 0 | — |
| int_in_2opt | INT | 0 | — |
| float_in_1opt | FLOAT | 0.00 | — |
| float_in_2opt | FLOAT | 0.00 | — |
| img_in_1opt | IMAGE | — | |
| img_in_2opt | IMAGE | — | |
| mask_inopt | MASK | — | |
| latent_inopt | LATENT | — | |
| positiveopt | CONDITIONING | — | |
| negativeopt | CONDITIONING | — | |
| modelopt | MODEL | — | |
| clipopt | CLIP | — | |
| vaeopt | VAE | — | |
| audio_inopt | * | — | |
| video_inopt | * | — | |
| custom_in_1opt | * | — | |
| custom_in_2opt | * | — | |
| triggeropt | * | — |
Outputs (22)
| Name | Type | Description |
|---|---|---|
| txt_out_1 | STRING | — |
| txt_out_2 | STRING | — |
| txt_out_3 | STRING | — |
| txt_out_4 | STRING | — |
| int_out_1 | INT | — |
| int_out_2 | INT | — |
| float_out_1 | FLOAT | — |
| float_out_2 | FLOAT | — |
| img_out_1 | IMAGE | — |
| img_out_2 | IMAGE | — |
| mask_out | MASK | — |
| latent_out | LATENT | — |
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| model | MODEL | — |
| clip | CLIP | — |
| vae | VAE | — |
| audio_out | * | — |
| video_out | * | — |
| custom_out_1 | * | — |
| custom_out_2 | * | — |
| Console | STRING | — |