Pre-built Templates
Comfy UI
7min
the comfy ui serverless template can be used to run comfy stable diffusion models on vast gpu instances this page documents required environment variables and endpoints to get started a full {{pyworker}} and client implementation can be found here environment variables hf token (string) huggingface api token with read permissions, used to download gated models read more about huggingface tokens here comfy model (string) text2image model being used options "sd3" , "flux" endpoints / prompt/ t he comfyui defined endpoint to generate an image after receving a gpu worker address from the /route/ endpoint, a /prompt/ endpoint would have the following structure inputs for both "sd3" and "flux" payload prompt (string) the model prompt used to generate the image width (int) width in pixels of the resulting generated image height (int) height in pixels of the resulting generated image steps (int) number of diffusion steps taken during image generation the assumed default is 28 seed (int) the value used to initialize the random noise pattern in the diffusion model used for reproducability auth data signature (string) a cryptographic string that authenticates the url, cost, and reqnum fields in the response, proving they originated from the server clients can use this signature, along with the server's public key, to verify that these specific details have not been tampered with cost (float) the estimated compute resources for the request the units of this cost are defined by the {{pyworker}} endpoint (string) name of the endpoint reqnum (int) the request number corresponding to this worker instance note that workers expect to receive requests in approximately the same order as these reqnums , but some flexibility is allowed due to potential out of order requests caused by concurrency or small delays on the proxy server url (string) the address of the worker instance to send the request to { "payload" { "prompt" "a majestic lion with a flowing mane, fantasy art style", "width" 1024, "height" 1024, "steps" 28, "seed" 55512345 }, "auth data" { "signature" "mock signature from routing service abc123", "cost" 100, "endpoint" "comfyui flux default", "reqnum" "req 789xyz", "url" "http //127 0 0 1 8188/" //this is the base url of the worker, 'prompt/' is appended to the end } } outputs prompt id (string) a unique identifier assigned by the comfyui instance for this specific workflow execution or prompt number (int) a sequential number assigned by the comfyui instance to this prompt this number reflects the order in which prompts are received or processed by the worker node errors (object) an object that contains details about any errors that occurred within specific nodes during the workflow execution outputs (object) an object containing the outputs generated by specific nodes in the comfyui workflow the keys of this object are the string identifiers of the nodes that produced output { "prompt id" "f9e0a3c2 0b7a 4f8e 8c1d 5a7b9e2f3c0a", "number" 7, "node errors" {}, "outputs" { "9" { "images" \[ { "filename" "comfyui 00007 png", "subfolder" "", "type" "output" } ] } } } /custom workflow/ allows a client to send a complete, user defined comfyui workflow (in json format) to the server for execution it includes the payload and auth data objects, but modified according to the user's design the workflow is a direct comfyui graph here is an example, similar to the sd3 workflow { "payload" { "custom fields" { "steps" 20, "width" 512, "height" 512 }, "workflow" { "3" { "inputs" { "seed" 156680208700286, "steps" 20, "cfg" 8, "sampler name" "euler", "scheduler" "normal", "denoise" 1, "model" \["4", 0], "positive" \["6", 0], "negative" \["7", 0], "latent image" \["5", 0] }, "class type" "ksampler" }, "4" { "inputs" { "ckpt name" "sd3 medium incl clips t5xxlfp16 safetensors" }, "class type" "checkpointloadersimple" }, "5" { "inputs" { "width" 512, "height" 512, "batch size" 1 }, "class type" "emptylatentimage" }, "6" { "inputs" { "text" "a futuristic cityscape at dusk, neon lights, flying vehicles", "clip" \["4", 1] }, "class type" "cliptextencode" }, "7" { "inputs" { "text" "blurry, low quality, ugly", "clip" \["4", 1] }, "class type" "cliptextencode" }, "8" { "inputs" { "samples" \["3", 0], "vae" \["4", 2] }, "class type" "vaedecode" }, "9" { "inputs" { "filename prefix" "customworkflowoutput", "images" \["8", 0] }, "class type" "saveimage" } } }, "auth data" { "signature" "mock signature for custom workflow def456", "cost" 150, "endpoint" "comfyui sd3 custom", "reqnum" "req 101112jkl", "url" "http //127 0 0 1 8188/" } }