# Agents in Qwen-Image-Edit Rapid-AIO v23

This document describes the agents and components that make up the Qwen image editing system running on A6000 hardware.

## System Overview

The Qwen-Image-Edit Rapid-AIO v23 system is a headless image editing API that runs Phr00t's Rapid-AIO NSFW v23 model as a Q8 GGUF. The system consists of two main components:
1. ComfyUI backend that executes the Qwen models
2. FastAPI service that provides HTTP API endpoints

## Key Agents and Components

### 1. ComfyUI Backend Agent
- **Role**: Core image editing backend that executes the Qwen models
- **Service Name**: `comfyui-backend`
- **Port**: 8188
- **Components**:
  - Qwen model (Qwen-Rapid-NSFW-v23_Q8_0.gguf)
  - Text encoder (qwen_2.5_vl_7b_fp8_scaled.safetensors) 
  - VAE decoder (qwen_image_vae.safetensors)
  - Workflow execution engine

### 2. FastAPI Edit Agent
- **Role**: Provides HTTP API endpoint for image editing requests
- **Service Name**: `comfyui-api`
- **Port**: 8500
- **Functionality**:
  - Accepts image and prompt input via POST request
  - Processes edits using ComfyUI backend
  - Returns edited PNG output

## Communication Flow

1. Client sends POST request to FastAPI Edit Agent (port 8500) with image and prompt
2. FastAPI Edit Agent forwards request to ComfyUI Backend Agent (port 8188)
3. ComfyUI Backend Agent processes the image using Qwen models via workflow
4. Result is returned through FastAPI Edit Agent to client

## Service Management

### Backend Service
- **Service Name**: `comfyui-backend`
- **Port**: 8188
- **Command**: `/home/mike/dev/qwen-image-edit-rapid-aio-nsfw-v23/a6000-comfy/run_comfyui.sh`

### API Service  
- **Service Name**: `comfyui-api`
- **Port**: 8500
- **Command**: `/home/mike/dev/qwen-image-edit-rapid-aio-nsfw-v23/a6000-comfy/start_api.sh`

## Configuration Notes

The system uses the following environment variables:
- COMFY_URL: Set to "http://127.0.0.1:8188" 
- HOST: Set to "0.0.0.0"
- PORT: Set to "8500"
- MAX_AREA: Default 1048576 (1MP output budget)