comfy-ts
An efficient way to create, run, maintain and operate your ComfyUI workflows, for humans and agents.


Write ComfyUI workflows in TypeScript, then run them from code, one command, a terminal, a browser or an agent. Types come from your own ComfyUI: every node and model it has autocompletes, and a wrong graph is a compile error. Run on your GPU, another machine or Comfy Cloud, and get the images, audio and video back in your code or as files. 73 ready workflows cover 43 model families, from SDXL to Wan video and ACE-Step songs.
💬 Questions, help, or something you made with it: come say hi on the Discord.
| you want to | start here |
|---|
| build and run workflows in code, typed down to the model names of your exact machine | the SDK, the codegen |
| tune a workflow with knobs, drafts, a queue and live latent previews in the terminal | the TUI |
| get the same workflows as a form in a browser, a phone included, with an LLM prompt refiner | the web panel |
| generate from the command line, or let an AI agent generate for you | the CLI, for AI agents |
| call your workflows over HTTP from a frontend, curl or n8n | serve |
| run on Comfy Cloud or a rented GPU, with ready workflows for 43 model families | hosts, the model zoo |
| find and install the custom nodes and models a workflow needs, with typed names | ComfyUI-Manager |
| keep client images off the server disk | ephemeral outputs |
move a graph between your code and the ComfyUI canvas, api.json and workflow.json | JSON both ways |
⚡ 60 second start
bun add comfy-ts # or npm / pnpm / yarn
// myFirstWorkflow.ts
import { ComfyTS } from 'comfy-ts'
const comfy = ComfyTS.create()
const host = comfy.host({ id: 'my-gpu', host: '127.0.0.1', port: 8188 })
await host.connect() // fetches the schema, writes your typed SDK
const txt2img = host.defineWorkflow({
id: 'txt2img', // names the saved outputs (and the TUI tree entry)
vars: {},
build: (b) => {
// b is typed: autocomplete on EVERY node of THIS host
const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'SD1.5\\v1-5-pruned-emaonly.ckpt' })
const samples = b.KSampler({
model: ckpt,
positive: b.CLIPTextEncode({ clip: ckpt, text: 'a cozy house in a snowy forest' }),
negative: b.CLIPTextEncode({ clip: ckpt, text: 'blurry, low quality' }),
latent_image: b.EmptyLatentImage({ width: 512, height: 512, batch_size: 1 }),
seed: 42, steps: 20, cfg: 7,
sampler_name: 'euler', scheduler: 'normal', denoise: 1,
})
// streams the image back over the websocket: nothing saved on the server
b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae: ckpt }) })
},
})
const execution = await txt2img.run({ log: true, save: true }) // ▶ [██████░░] 71% · KSampler · 10s
for (const img of execution.images) console.log(img.absPath) // saved outputs
host.disconnect()
$ bun myFirstWorkflow.ts
▶ [████████████████] 100% · SaveImageWebsocket · 12s
.comfy-ts/outputs/txt2img_20260731-142012.png
Drop save: true and the outputs never touch a disk at all: img.buffer holds the bytes in memory (ephemeral outputs).
One tsconfig line activates the generated types:
{ "include": ["src", ".comfy-ts/hosts/**/sdk.d.ts"] }