API Doc-CometAPI
HomeDashBoardModel Marketplace
HomeDashBoardModel Marketplace
Discord_Support
  1. Midjourney
  • How to Use CometAPI?
  • šŸš€ Overview
    • Quick Start
    • Important Guidelines
    • Release Notes
    • Quickly request CometAPI via ApiDog
    • Models
  • šŸ’¬ Text Models
    • Chat Completions
    • Responses
    • Anthropic Messages
    • Gemini Generating Content
    • Embeddings
  • šŸ–¼ļø Image Models
    • OpenAI
      • gpt-4o-image generates image
      • Images
      • Image Editing (gpt-image-1)
    • Gemini
      • Guide to calling gemini-3-pro-image (Nano Banana)
      • Gemini generates image
    • Midjourney
      • Midjourney API Quick Start
      • Task Fetching API
        • List by Condition
        • Fetch Single Task (most recommended)
      • Imagine
        POST
      • Submit Video
        POST
      • Submit Editor
        POST
      • Action (UPSCALE; VARIATION; REROLL; ZOOM, etc.)
        POST
      • Blend (image -> image)
        POST
      • Describe (image -> text)
        POST
      • Modal (Area Redesign & Zoom)
        POST
    • Replicate(image)
      • Create Predictions - General
      • replicate query
    • seededit/seedream
      • bytedance-image-generation(seedream)
      • bytedance-Image Editing (seededit)
    • bria
      • Generate Image
      • Generate Vector Graphics - Base (Beta)
      • Image Editing
      • Query Status
    • Flux(images)
      • flux generate image
      • flux query
    • Hunyuan3D
      POST
  • šŸ“ŗ Video Models
    • sora-2
      • official
        • Create video
        • Remix video
        • Retrieve video
        • Retrieve video content
      • self-developed
        • Create video
        • Retrieve video
    • veo3
      • self-developed
        • Veo3 Async Generation
        • Veo3 Retrive
    • kling (video)
      • callback_url
      • Multimodal Video Editing
        • Initialize Video for Editing
        • Add Video Selection
        • Delete Video Selection
        • Clear Video Selection
        • Preview Selected Video Area
        • Create Task
      • Text to Video
      • Image to Video
      • Multi-Image To Video
      • Video Extension
      • Avatar
      • Lip-Sync
      • [Counterpart] Creating Tasks
      • Video Effects
      • Text to Audio
      • Video to Audio
      • TTS
      • Image Generation
      • Multi-Image to Image
      • Image Expansion
      • Image Recognize
      • Virtual Try-On
      • Individual queries
    • runway(video)
      • official format
        • runway images raw video
        • Generate a video from a video
        • Generate an image from text
        • Upscale a video
        • Control a character
        • runway to get task details
      • Reverse Format
        • generate(text)
        • generate(Reference images)
        • Video to Video Style Redraw
        • Act-one Expression Migration
        • feed-get task
    • bytedance
      • bytedance-video
      • bytedance-video get
    • MiniMax Conch(video)
      • MiniMax Conch Official Documentation
      • MiniMax Conch Generation
      • MiniMax Conch Query
      • MiniMax Conch Download
    • openai-format
  • šŸ”Š Audio Models
    • Realtime
    • Create speech
    • Create transcription
    • Create translation
  • 🧩 Integration Guides
    • CodeX
    • LiteLLM
    • Dify
    • Make
    • n8n
    • Lobe-Chat
    • COZE
    • Zapier
    • Activepieces
    • LlamaIndex
    • Continue
    • FlowiseAI
    • Chatbox
    • CherryStudio
    • AnythingLLM
    • LangChain
    • BuildShip
    • gptme
    • Immersive Translation
    • Cline
    • Eudic Translation
    • ChatHub
    • OpenAI Translator
    • ChatAll Translation
    • Pot Translation
    • Zotero
    • NEXT CHAT (ChatGPT Next Web)
    • Obsidian's Text Generator Plugin
    • librechat
    • utools-ChatGPT Friend
    • avante.nvim
    • Open WebUI
    • GPT Academic Optimization (gpt_academic)
    • OpenManus
    • IntelliJ Translation Plugin
    • FastGPT
    • n8n Local Deployment
  • āš ļø Errors
    • Error Codes & Handling
  • šŸ“ Code Examples
    • Text-to-Image Generation
    • Image-to-image generation URL upload
    • Regular Post Text Conversation
    • OpenAI Official Library Usage Example
    • Streamed Output
    • Json Fixed Format Output Code Display
    • Embedding code example
    • o1-preview Model Code Example
    • LangChain Usage Example (Successful Test Date: 2024-11-25)
    • Openai dall-e-3 & flux series drawing model
    • gpt, claude, gemini multimodal network image parsing example
    • Multimodal PDF File Parsing Examples for GPT, Claude, and Gemini
    • Code example
  • šŸ„šŸ¼ā€ā™€ļø Best Practices
    • Retry Logic Documentation for CometAPI and OpenAI Official API
    • Runway Best Practices
    • Gemini CLI Installation and Usage Guide
    • Codex Usage Guide
    • CometAPI Account Balance Query API Usage Instructions
    • Midjourney Best Practices
    • Claude Code Installation and Usage Guide
  • šŸ’³ Pricing & Billing
    • About Pricing
  • šŸ¤šŸ¼ Support
    • Help Center
    • Interface Stability
    • Privacy policy
    • Terms of service
    • Common Misconceptions
    • Confusion about use
HomeDashBoardModel Marketplace
HomeDashBoardModel Marketplace
Discord_Support
  1. Midjourney

Midjourney API Quick Start

šŸŽÆ Understand the Core Concept#

The MidJourney API simulates Discord button interactions. Unlike typical REST APIs, it works as a state machine where each operation returns new buttons for the next step.

The 4 Core APIs#

APIPurposeWhen to Use
POST /mj/submit/imagineText-to-image generationStarting point for all workflows
GET /mj/task/{id}/fetchQuery task status & get buttonsAfter every submit (poll until done)
POST /mj/submit/actionClick a button (upscale, vary, zoom, etc.)When you want to operate on an image
POST /mj/submit/modalSubmit additional inputOnly when status is MODAL

šŸ“Š Complete Workflow Diagram#

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│                         MIDJOURNEY API WORKFLOW                             │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │  POST /submit/   │  ← Step 1: Submit prompt, get task_id
  │     imagine      │
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
           │ Returns: { "result": "task_id_1" }
           ā–¼
  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │ GET /task/{id}/  │  ← Step 2: Poll until status = "SUCCESS"
  │      fetch       │
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
           │ Returns: imageUrl + buttons[] (U1,U2,U3,U4,V1,V2,V3,V4,šŸ”„)
           ā–¼
  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │  POST /submit/   │  ← Step 3: Click a button using customId
  │     action       │
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
           │ Returns: { "result": "task_id_2" }
           ā–¼
  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │ GET /task/{id}/  │  ← Step 4: Poll the new task
  │      fetch       │
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
           │
           ā”œā”€ā”€ā”€ status = "SUCCESS" → Done! Get imageUrl
           │
           └─── status = "MODAL" → Need additional input (see Step 5)
                      │
                      ā–¼
           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
           │  POST /submit/   │  ← Step 5: Submit mask/prompt for special operations
           │      modal       │
           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                    │ Returns: { "result": "task_id_3" }
                    ā–¼
           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
           │ GET /task/{id}/  │  ← Step 6: Poll until SUCCESS
           │      fetch       │
           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

šŸ”‘ Key Concept: Buttons & customId#

Every successful task returns a buttons array. Each button has a customId that you use to trigger the next action.
Example response from /mj/task/{id}/fetch:
{
  "status": "SUCCESS",
  "imageUrl": "https://api.cometapi.com/mj/image/xxx",
  "buttons": [
    { "customId": "MJ::JOB::upsample::1::abc123", "label": "U1" },
    { "customId": "MJ::JOB::upsample::2::abc123", "label": "U2" },
    { "customId": "MJ::JOB::variation::1::abc123", "label": "V1" },
    { "customId": "MJ::JOB::reroll::0::abc123", "emoji": "šŸ”„" }
  ]
}
āš ļø Important: customId is NOT a fixed value. It changes for every task. Always get it from the buttons array.

šŸ“‹ Button Reference by Stage#

After IMAGINE (4-grid image)#

These buttons are returned when your initial image generation completes:
ButtoncustomId PatternActionResult
U1-U4MJ::JOB::upsample::1::xxxUpscale single imageHigh-res single image
V1-V4MJ::JOB::variation::1::xxxGenerate variationsNew 4-grid
šŸ”„MJ::JOB::reroll::0::xxx::SOLORegenerate allNew 4-grid

After UPSCALE (single image)#

After upscaling, you get access to editing tools:
LabelNeeds Modal?
Upscale (Subtle) / Upscale (2x)āŒ No
Upscale (Creative) / Upscale (4x)āŒ No
Vary (Subtle) šŸŖ„āŒ No
Vary (Strong) šŸŖ„āŒ No
Vary (Region) šŸ–Œļøāœ… Yes (mask)
Zoom Out 2x / 1.5x šŸ”āŒ No
Custom Zoom šŸ”āœ… Yes (prompt)
ā¬…ļøāž”ļøā¬†ļøā¬‡ļø PanāŒ No
Animate šŸŽžļøāŒ No
šŸ”„ RerollāŒ No
Note: Button labels and customId formats may vary depending on the MJ version specified in your prompt (e.g., --v 6.1 vs --v 5.2). Always read buttons from the API response.
āš ļø Inpaint (Vary Region) button only appears after Upscale!

⚔ Complete Example: Generate & Upscale#

Step 1: Submit Imagine Request#

Response:
{ "code": 1, "result": "1768464763141701" }

Step 2: Poll Task Status#

Response (when complete):
{
  "status": "SUCCESS",
  "imageUrl": "https://api.cometapi.com/mj/image/1768464763141701",
  "buttons": [
    { "customId": "MJ::JOB::upsample::1::5f20922e-xxx", "label": "U1" },
    { "customId": "MJ::JOB::upsample::2::5f20922e-xxx", "label": "U2" },
    ...
  ]
}

Step 3: Click U1 to Upscale#

Response:
{ "code": 1, "result": "1768464800000000" }

Step 4: Poll New Task & Get Result#


āš ļø When is Modal Required?#

When you call /mj/submit/action and the task status becomes MODAL instead of SUCCESS, you must call /mj/submit/modal to provide additional input.

Confirmed Modal Operations#

OperationButtonWhat to Submit
InpaintVary (Region)maskBase64 (PNG mask) + prompt
Custom ZoomšŸ” Custom Zoomprompt (e.g., "your prompt --zoom 2")
Example: Inpaint Flow

šŸš€ Speed Mode Selection#

Add speed prefix to the path:
ModePath PrefixExample
Fast/mj-fast/mj-fast/mj/submit/imagine
Turbo/mj-turbo/mj-turbo/mj/submit/imagine
Relax(default)/mj/submit/imagine

šŸ”— Other Entry Points#

These APIs are independent entry points that don't follow the imagine → action flow:
APIPurpose
POST /mj/submit/blendBlend 2-5 images into one
POST /mj/submit/describeGenerate prompt from image
POST /mj/submit/videoConvert image to video
POST /mj/submit/editsEdit image with mask

ā“ Troubleshooting Tips#

Based on the API design and workflow, here are common issues you may encounter:
ProblemLikely CauseSolution
Can't find Vary (Region) buttonLooking at 4-grid imageUpscale first (click U1-U4), then check buttons
Task status stuck at MODALOperation requires additional inputCall /mj/submit/modal with required data
customId not workingUsing outdated or hardcoded valueAlways get fresh customId from /mj/task/{id}/fetch response
Empty buttons arrayTask still in progressWait for status: "SUCCESS" before accessing buttons
Modified atĀ 2026-01-16 08:44:15
Previous
Gemini generates image
Next
List by Condition
Built with