NOTE: The previous *_template.py files are now deprecated and broken due to an update with Open-WebUI. Use the two new files in this repository for Txt2Img and Img2Img functionalities.
open-webui-tools is a repository that provides tools for integrating ComfyUI workflows with Open-WebUI. These tools let you generate images from text prompts (Txt2Img) or enhance existing images (Img2Img) using customizable, JSON-defined ComfyUI workflows. All configuration settings (such as API key, server address, and workflow URL) are now administered via the admin-controlled Valves.
- Txt2Img Tool: Generate images from text prompts using a customizable ComfyUI workflow.
- Img2Img Tool: Enhance or modify existing images with additional instructions.
-
Clone the Repository:
git clone https://github.com/pwillia7/open-webui-tools.git
-
Navigate to the Repository Directory:
cd open-webui-tools
-
Open Open-WebUI:
- Launch Open-WebUI in your web browser.
-
Navigate to Workspace:
- Click on the Workspace tab in the Open-WebUI interface.
-
Access Tools:
- Select the Tools section within the Workspace.
-
Create a New Tool:
- Click on Create New Tool.
- Name Your Tool: For example, "Txt2Img Generator" or "Img2Img Enhancer".
- Paste the Tool Code:
- Open the corresponding Python file from this repository (e.g.,
txt2img.py
orimg2img.py
). - Copy the entire file content and paste it into the tool creation interface in Open-WebUI.
- Open the corresponding Python file from this repository (e.g.,
- Save the Tool: Click Save to add it to your workspace.
Both tools contain a workflow_template
field that is populated by fetching a JSON workflow from a URL. This URL should point to a gist (or another publicly accessible location) that contains your ComfyUI workflow JSON.
- Placeholder:
%%PROMPT%%
- Setup Steps:
- Create or update a gist that contains your ComfyUI workflow JSON.
- Make sure your workflow JSON includes the
%%PROMPT%%
placeholder where the text prompt will be injected. - In the tool’s admin settings, set the Workflow_URL to your gist URL.
- Example Flux Workflow
- Placeholders:
%%B64IMAGE%%
(for the input image) and optionally%%PROMPT%%
(if additional text instructions are used). - Setup Steps:
- Create or update a gist with your ComfyUI workflow JSON.
- Ensure the JSON includes the
%%B64IMAGE%%
placeholder (and%%PROMPT%%
if desired). - In the tool’s admin settings, set the Workflow_URL to point to this gist.
- Example Enhance! Workflow
Both tools require you to set an API key and the ComfyUI server address. These settings are defined in the admin-only Valves. To configure them:
- Access Tool Settings:
- In your Open-WebUI workspace, click the gear icon next to the tool.
- Enter Settings:
- Api_Key: Enter your ComfyUI API key.
- ComfyUI_Server: Enter your ComfyUI server address (without the protocol, e.g.,
ptkwilliams.ddns.net:8443
). - Workflow_URL: Enter the URL of your gist containing the workflow JSON.
- debug_mode: Optionally enable debug mode for extra logging.
- Save Your Settings.
Invoke the Txt2Img tool with your desired text prompt. The tool replaces the %%PROMPT%%
placeholder in your JSON workflow with your prompt, submits it to ComfyUI, and displays the generated images within Open-WebUI.
For image enhancement, provide the URL of the source image along with an optional text prompt. The tool replaces %%B64IMAGE%%
(and %%PROMPT%%
if applicable) in your workflow JSON, submits the request, and retrieves the enhanced images.