Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

6.5 KB
Raw Blame
---
title: Using ComfyUI in LobeHub for Image Generation
description: >-
  Learn how to configure and use the ComfyUI service in LobeHub to support
  high-quality image generation and editing with the FLUX model series.
tags:
  - ComfyUI
  - FLUX
  - Text-to-Image
  - Image Editing
  - AI Image Generation
---

# Using ComfyUI in LobeHub

<Image alt={'Using ComfyUI in LobeHub'} cover src={'https://hub-apac-1.lobeobjects.space/docs/e9b811f248a1db2bd1be1af888cf9b9d.png'} />

This guide will walk you through how to use [ComfyUI](https://github.com/comfyanonymous/ComfyUI) in LobeHub for high-quality AI image generation and editing.

To configure this provider in LobeHub, open **App Settings β†’ AI Providers**, select the provider, and turn on its switch.

## Introduction to ComfyUI

ComfyUI is a powerful GUI for Stable Diffusion and Flow Diffusion, offering a node-based workflow interface. LobeHub integrates ComfyUI with full support for the FLUX model series, enabling both text-to-image generation and image editing.

### Key Features

- **Extensive Model Support**: Supports 223 models, including 130 FLUX and 93 SD models
- **Config-Driven Architecture**: Registry system enables intelligent model selection
- **Multi-Format Support**: Compatible with .safetensors and .gguf formats, with various quantization levels
- **Dynamic Precision Options**: Supports default, fp8\_e4m3fn, fp8\_e5m2, and fp8\_e4m3fn\_fast
- **Multiple Authentication Methods**: Supports None, Basic Auth, Bearer Token, and Custom Headers
- **Smart Component Selection**: Automatically selects optimal T5, CLIP, and VAE encoders
- **Enterprise-Grade Optimizations**: Includes NF4, SVDQuant, TorchAO, MFLUX variants

## Quick Start

### Step 1: Configure ComfyUI in LobeHub

#### 1. Open Settings

- Go to the `Settings` panel in LobeHub
- Under `AI Providers`, find the `ComfyUI` section

<Image alt={'ComfyUI Settings Panel'} inStep src={'/blog/assets17870709/3f31bc33-509f-4ad2-ba81-280c2a6ec5fa.webp'} />

#### 2. Set Connection Parameters

**Basic Configuration**:

- **Server Address**: Enter your ComfyUI server address, e.g., `http://localhost:8000`
- **Authentication Type**: Choose the appropriate method (default is None)

### Step 2: Select a Model and Generate Images

#### 1. Choose a FLUX Model

In the chat interface:

- Click the model selection button
- Choose your desired FLUX model from the ComfyUI category

<Image alt={'Select FLUX Model'} inStep src={'/blog/assets17870709/ff7ebacf-27f0-42d7-810b-00314499a084.webp'} />

#### 2. Text-to-Image Generation

**Using FLUX Schnell (Fast Generation)**:

```plaintext
Generate an image: A cute orange cat sitting on a sunny windowsill, warm lighting, detailed fur texture
```

**Using FLUX Dev (High-Quality Generation)**:

```plaintext
Generate high quality image: City skyline at sunset, cyberpunk style, neon lights, 4K high resolution, detailed architecture
```

#### 3. Image Editing

**Using FLUX Kontext-dev for Editing**:

```plaintext
Edit this image: Change the background to a starry night sky, keep the main subject, cosmic atmosphere
```

Then upload the original image you want to edit.

<Callout type={'info'}>
  Image editing requires uploading the original image first, followed by a description of the desired changes.
</Callout>

## Authentication Configuration Guide

ComfyUI supports four authentication methods. Choose the one that best fits your server setup and security needs:

### No Authentication (none)

**Best for**:

- Local development (localhost)
- Trusted internal networks
- Personal single-machine setups

**Configuration**:

```yaml
Authentication Type: None
Server Address: http://localhost:8000
```

### Basic Authentication (basic)

**Best for**:

- Deployments behind Nginx reverse proxy
- Internal team use with basic access control

**Setup**:

1. **Create Username and Password**:

```bash
# Install apache2-utils
sudo apt-get install apache2-utils

# Create user 'admin'
sudo htpasswd -c /etc/nginx/.htpasswd admin
```

2. **LobeHub Configuration**:

```yaml
Authentication Type: Basic
Server Address: https://your-domain.com
Username: admin
Password: your_secure_password
```

### Bearer Token (bearer)

**Best for**:

- API-driven integrations
- Enterprise environments requiring token-based auth

**Generate Token**:

```python
import jwt
import datetime

payload = {
    'user': 'admin',
    'exp': datetime.datetime.utcnow() + datetime.timedelta(days=30)
}

secret_key = "your-secret-key"
token = jwt.encode(payload, secret_key, algorithm='HS256')
print(f"Bearer Token: {token}")
```

**LobeHub Configuration**:

```yaml
Authentication Type: Bearer Token
Server Address: https://your-domain.com
API Key: example-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
```

### Custom Authentication (custom)

**Best for**:

- Integrating with existing enterprise auth systems
- Systems requiring multiple custom headers

**LobeHub Configuration**:

```yaml
Authentication Type: Custom
Server Address: https://your-domain.com
Custom Headers:
{
  "X-API-Key": "your_api_key",
  "X-Client-ID": "LobeHub"
}
```

## Troubleshooting

### 1. How to Install Comfy-Manager

Comfy-Manager is an extension manager for ComfyUI that simplifies installing and managing nodes, models, and extensions.

<details>
  <summary><b>πŸ“¦ Steps to Install Comfy-Manager</b></summary>

  #### Method 1: Manual Installation (Recommended)

  ```bash
  # Navigate to ComfyUI's custom_nodes directory
  cd ComfyUI/custom_nodes

  # Clone the Comfy-Manager repository
  git clone https://github.com/ltdrdata/ComfyUI-Manager.git

  # Restart the ComfyUI server
  # After restarting, you should see a "Manager" button in the UI
  ```

  #### Method 2: One-Click Install Script

  ```bash
  # Run from the ComfyUI root directory
  curl -fsSL https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/install.sh | bash
  ```

  #### Verify Installation

  1. Restart the ComfyUI server
  2. Visit `http://localhost:8000`
  3. You should see a "Manager" button in the bottom-right corner

  #### Using Comfy-Manager

  **Install Models**:

  1. Click the "Manager" button
  2. Select "Install Models"
  3. Search for the desired model (e.g., FLUX, SD3.5)
  4. Click "Install" to download automatically

  **Install Node Extensions**:

  1. Click the "Manager" button
  2. Select "Install Custom Nodes"
  3. Search for nodes (e.g., ControlNet, AnimateDiff)
  4. Click "Install" and restart the server

  **Manage Installed Content**:

  1. Click the "Manager" button
  2. Select "Installed" to view installed extensions
  3. You can update, disable, or uninstall extensions
</details>