ComfyUI Java Integration: 3 Open-Source Solutions from Lightweight SDK to Full-Stack Product

This article reviews three open-source Java solutions for integrating ComfyUI AI image generation: a lightweight SDK (ComfyUiApiJava), an API aggregation layer (comfy-flow-api) with Spring Boot 3, and a full-stack enterprise platform (comfyui-openrouter-ai) with user management, credits, and WebSocket progress, helping developers choose by complexity and needs.

Coder Trainee
Coder Trainee
Coder Trainee
ComfyUI Java Integration: 3 Open-Source Solutions from Lightweight SDK to Full-Stack Product

This final article in the ComfyUI series presents three production-ready open-source Java projects that bridge ComfyUI's node-based AI image generation with Java backends, covering a spectrum from minimal SDK to complete product foundation.

1. ComfyUiApiJava — Lightweight SDK

Use Case

Ideal when you only need to call ComfyUI APIs from an existing Java project without adding a heavy framework.

Description

A zero-dependency Java library that simplifies ComfyUI API calls. It supports workflow configuration via a builder pattern or YAML files.

Code Example

// Builder pattern usage
ComfyUiClient client = ComfyUiClient.builder()
    .baseUrl("http://127.0.0.1:8188")
    .build();

Why Choose It

Lightweight, non-invasive, no architecture changes required

Treats ComfyUI as a local AI engine

Limitations

It is purely an SDK — no user system, task queue, or storage management. For those, see the next two solutions.

2. comfy-flow-api — API Aggregation Layer

Use Case

Suitable for exposing ComfyUI as a standard RESTful service, e.g., for a WeChat Mini Program.

Description

Built on Spring Boot 3 and JDK 17, it packages several core capabilities:

Core Capabilities

API Wrapping — Exposes ComfyUI APIs as friendlier REST endpoints

Workflow Configuration — Defines multiple workflows via comfyui.json and invokes them by name

Dynamic Parameter Replacement — Supports runtime substitution of seed, prompt, image, localDate, etc.

Multi-Server Load Balancing — Configures multiple ComfyUI addresses via comfy.ips WeChat Mini Program Integration — Includes built-in authorization support

Storage Extension — Defaults to local disk; provides extension interfaces for Alibaba Cloud OSS and S3

Configuration Examples

# application.properties
comfy.ips=127.0.0.1
file.storage.type=disk
file.storage.disk=/path/to/static/
// comfyui.json workflow config
{
  "name": "动漫风格转换",
  "path": "/comfyui/workflow-api.json"
}

Deployment

# Package
./mvnw package -Dquarkus.package.type=uber-jar

# Run
java -jar target/comfy-flow-api-runner.jar

Why Choose It

Ready to run after configuring ComfyUI addresses and workflow JSON

Handles load balancing and dynamic parameters out of the box

Good fit for MVP products or providing a standard API to frontends

Limitations

The included UI is Quarkus dev-ui — basic, suitable for debugging, not for end users.

3. comfyui-openrouter-ai — Full-Stack Enterprise Solution

Use Case

Targeted at building a complete product with user accounts, credit system, multiple workflows, and multi-node load balancing.

Backend Stack

Spring Boot 3 multi-module architecture with:

Sa-Token for authentication and authorization

MyBatis-Plus, MySQL 8+, Redis 6+

WebSocket for real-time task progress push

Multi-ComfyUI server load balancing

Frontend Stack

Vue 3 + Vite + TypeScript + Element Plus.

Core Capabilities

Workflow Form Rendering — Converts ComfyUI workflow parameters into visual forms

Task Management — Submit, cancel, retry with timeout and retry policies

Multi-Server Support — Configures multiple ComfyUI endpoints with automatic task distribution

User Credit System — Freezes credits on submit, consumes on completion

WebSocket Real-Time Push — Streams task progress to the frontend

OSS Storage — Supports Alibaba Cloud OSS and similar object stores

Deployment Requirements

JDK 21+, MySQL 8+, Redis 6+, Maven 3.9+. Requires solid DevOps capability.

Why Choose It

Open-source, feature-complete, can serve directly as a product base

Modular design allows trimming unused modules

Fits independent developers or small teams with full-stack capacity

Comparison Quick Reference

Positioning

ComfyUiApiJava: Lightweight SDK

comfy-flow-api: API Aggregation Layer

comfyui-openrouter-ai: Full-Stack Product

Complexity

ComfyUiApiJava: Low

comfy-flow-api: Medium

comfyui-openrouter-ai: High

User System

ComfyUiApiJava: None

comfy-flow-api: Basic

comfyui-openrouter-ai: Comprehensive

Credit System

ComfyUiApiJava: None

comfy-flow-api: None

comfyui-openrouter-ai: Yes

Multi-Server Load Balancing

ComfyUiApiJava: None

comfy-flow-api: Yes

comfyui-openrouter-ai: Yes

WebSocket Push

ComfyUiApiJava: None

comfy-flow-api: None

comfyui-openrouter-ai: Yes

Frontend UI

ComfyUiApiJava: None

comfy-flow-api: Basic debug UI

comfyui-openrouter-ai: Complete Vue 3 frontend

Typical Scenario

ComfyUiApiJava: Internal project integration

comfy-flow-api: Providing API services

comfyui-openrouter-ai: Full product deployment

After years of community evolution, ComfyUI-Java integration has moved from "can it be done?" to "how to do it well." These three open-source options span the granularity from SDK to full-stack product, letting you pick based on actual needs and team capacity.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaSDKBackend Integrationspring-bootopen sourceAI image generationFull-StackComfyUI
Coder Trainee
Written by

Coder Trainee

Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.