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 MjController

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

Overview

Concrete tool for submitting Midjourney image generation tasks (imagine, upscale, variation, describe, blend) via REST endpoints, provided by the Spring Web framework.

Description

The MjController class is the REST controller for all Midjourney operations. It validates prompts, translates Chinese to English, checks banned words, deducts credits, creates Task entities with Snowflake IDs, and delegates to TaskService for submission to Discord instances.

Key endpoints:

  • /mj/submit — Submit an imagine task (with optional img2img)
  • /mj/submit/uv — Submit upscale/variation/reroll task
  • /mj/describe — Submit image-to-text describe task
  • /mj/blend — Submit image blend task
  • /mj/queue — Query running task queue

Usage

Import this controller when you need to:

  • Accept Midjourney task submissions from clients
  • Validate and translate prompts before submission
  • Create Task entities with proper IDs and notify hooks

Code Reference

Source Location

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

Signature

@RestController
@RequestMapping("/mj")
public class MjController {
    @PostMapping("/submit")
    public B<Task> submit(@RequestBody SubmitReq req);

    @PostMapping("/submit/uv")
    public B<Task> submitUV(@RequestBody UVSubmitReq req);

    @PostMapping("/describe")
    public B<Task> describe(@RequestBody DescribeReq req);

    @PostMapping("/blend")
    public B<Task> blend(@RequestBody SubmitBlendReq req);

    @GetMapping("/queue")
    public List<Task> queue();

    private Task newTask();
    private String translatePrompt(String prompt);
}

Import

import com.intelligent.bot.api.midjourney.MjController;

I/O Contract

Inputs

Name Type Required Description
req (submit) SubmitReq Yes prompt, plotMode (1/2/3), imgList, no, version, style, ar, q, stylize, chaos
req (uv) UVSubmitReq Yes id, taskAction, index
req (describe) DescribeReq Yes base64 image data
req (blend) SubmitBlendReq Yes base64Array (2-5 images), dimensions

Outputs

Name Type Description
submit returns B<Task> Task entity with ID, nonce, status
queue returns List<Task> All running tasks across instances

Usage Examples

Submitting an Imagine Task

// POST /mj/submit
// Body: {"prompt": "一只小狗", "plotMode": 1}
// Controller flow:
// 1. Check isOpenMj feature flag
// 2. Validate and moderate prompt
// 3. Translate to English via baiDuService
// 4. Check banned words
// 5. Determine cost (MJ_NUMBER / MJ_NUMBER_FAST / MJ_NUMBER_TURBO)
// 6. Deduct credits
// 7. Create task with IDUtil.getNextId() and SnowFlake nonce
// 8. Delegate to taskService.submitImagine(task, imgList)

Submitting an Upscale Task

// POST /mj/submit/uv
// Body: {"id": 12345, "taskAction": "UPSCALE", "index": 1}
// Controller verifies the original task exists and is SUCCESS
// Then delegates to taskService.submitUpscale()

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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