Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A616567126 GPT WEB JAVA SdController

From Leeroopedia
Knowledge Sources
Domains Image_Generation, Stable_Diffusion
Last Updated 2026-10-13 00:00 GMT

Overview

Concrete tool for managing Stable Diffusion image generation requests via Redis queue, polling progress, and listing available models/LoRAs/samplers from the SD WebUI API, provided by the Spring Web framework.

Description

The SdController class is the REST controller for Stable Diffusion operations. Endpoints:

  • /sd/create — Validates request, checks for duplicates, adds to Redis queue, returns queue position
  • /sd/getQueue — Returns queue position (state=1) or generation progress (state=2) from SD WebUI /sdapi/v1/progress
  • /sd/getModel — Lists SD models from database
  • /sd/getLora — Lists SD LoRAs from database
  • /sd/getSamplers — Queries SD WebUI /sdapi/v1/samplers
  • /sd/pngInfo — Extracts generation parameters from a PNG image via SD WebUI /sdapi/v1/png-info

Usage

Import this controller when you need to:

  • Accept Stable Diffusion image generation requests
  • Queue requests in Redis for sequential processing
  • Poll generation progress and preview images
  • List available models, LoRAs, and samplers

Code Reference

Source Location

  • Repository: GPT-WEB-JAVA
  • File: src/main/java/com/intelligent/bot/api/stablediffusion/SdController.java

Signature

@RestController
@RequestMapping("/sd")
public class SdController {
    public synchronized B<GetQueueRes> createImage(@Validated @RequestBody SdCreateReq req);
    public B<GetQueueRes> getQueue(@Validated @RequestBody SdCreateReq req);
    public B<List<SdModel>> getModel();
    public B<List<SdLora>> getLora();
    public B<List<String>> getSamplers();
    public B<SdCreateReq> pngInfo(@Validated @RequestBody SdPngInfoReq req);
}

Import

import com.intelligent.bot.api.stablediffusion.SdController;

I/O Contract

Inputs

Name Type Required Description
req (create) SdCreateReq Yes prompt, negativePrompt, steps, samplerIndex, cfgScale, width, height, seed, model, loraList, initImages
req (pngInfo) SdPngInfoReq Yes image (base64)

Outputs

Name Type Description
createImage returns B<GetQueueRes> Queue position or generation progress
getQueue returns B<GetQueueRes> state=1 (queuing, position/size) or state=2 (generating, progress/preview)
pngInfo returns B<SdCreateReq> Reconstructed request from PNG metadata

Usage Examples

Creating an Image

// POST /sd/create
// Body: {"prompt": "a cat", "steps": 20, "samplerIndex": "Euler a", "cfgScale": 7, "width": 512, "height": 512}
// 1. Check isOpenSd feature flag
// 2. Set userId from JWT
// 3. Check for duplicate request via getPosition()
// 4. Add to Redis queue via queueUtil.addUserToQueue()
// 5. Return getQueue(req) with current position

Polling Progress

// POST /sd/getQueue with same request body
// If position == 0 (head of queue):
//   state=2, query SD /sdapi/v1/progress for current_image and progress
// If position > 0:
//   state=1, return position and queue size

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment