# ComfyUI node

The Liquid Inference package adds paid nodes to [ComfyUI](https://github.com/comfyanonymous/ComfyUI). Install it, set a key, and buy images or video from a workflow. The source is [architect-xyz/comfyui-liquid-inference](https://github.com/architect-xyz/comfyui-liquid-inference).

| Node                        | What it does                                                |
| --------------------------- | ----------------------------------------------------------- |
| **Liquid Image (paid API)** | Buys images from a text prompt.                             |
| **Liquid Video (paid API)** | Buys a video from a text prompt.                            |
| **Liquid Video Job**        | Gets the video of an earlier job again, with no new charge. |

A paid node sends the prompt to the exchange. The exchange gives the request to the best offer under your price cap. You pay for the images or the video that you get. Each run of a paid node is a paid request, and the prompt goes to the provider that wins the auction.

## Before you start

- ComfyUI 0.3.45 or newer.
- A workspace with a balance and a `spend` key. See [API keys](https://inference.ai.exchange/docs/keys.md).

## 1. Install the node

In ComfyUI, open **Manager**, then **Custom Nodes Manager**. Search for "Liquid Inference", install it, and restart ComfyUI.

To install by hand, clone the repository into `ComfyUI/custom_nodes/` and restart ComfyUI. The package has no Python dependencies.

## 2. Set the key

Open **Settings**, then **Liquid Inference**, paste the key into **API key**, and select **Save**. The server keeps the key in `user/__liquid_inference/api_key`.

Or set `LIQUID_API_KEY` before you start ComfyUI. The variable has priority over the stored key.

The nodes have no input for the key on purpose. ComfyUI writes each input into the workflow file and into the metadata of each saved image. A key in an input would go to each person who gets your files.

## 3. Buy images

1. Double-click the canvas and search for "Liquid Image".
2. Write a prompt and choose a model.
3. Connect `images` to **Save Image**.
4. Queue the workflow.

## 4. Buy a video

1. Double-click the canvas and search for "Liquid Video".
2. Write a prompt and choose a model.
3. Connect `video` to **Save Video**.
4. Queue the workflow.

Options:

- To start the video from an image, connect the image to `start_image`. Only the models that read an image input can take it.
- Select the content retention rule with `exchange.privacy.retention`. See [ComfyUI](https://inference.ai.exchange/docs/connect-comfyui.md) for the choices and their privacy effects.

### Wait for a video

The node waits until the video is complete, for 30 minutes at most. A stop in ComfyUI stops the wait, not the job, and the exchange charges for the video. To get the video later, paste the job ID into a **Liquid Video Job** node.

## Example workflows

The `example_workflows` folder has five workflows. Open them from **Templates**.

## Cost

The cap applies to each request, not to the workflow. A workflow with three Liquid nodes and a cap of 0.05 can cost up to 0.15 USD for each run.

## Retries

A paid node never sends a purchase again by itself, because a second request could buy the images or the video twice.

- After a video purchase, the node tries a failed status read or download again, because these requests buy nothing.
- If the connection stops before the answer arrives, the node reports that the outcome is unknown and shows an `Idempotency-Key`. Look at your receipts before you run the node again.

## Next steps

- [ComfyUI](https://inference.ai.exchange/docs/connect-comfyui.md): the inputs, the outputs and the error table.
- [Modalities](https://inference.ai.exchange/docs/modalities.md): what images cost.
- [Video generation](https://inference.ai.exchange/docs/video-generation.md): video jobs, lengths and how they are priced.
- [Apps](https://inference.ai.exchange/docs/apps.md): the other plugins and tools.
