Documentation Index
Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
Use this file to discover all available pages before exploring further.
Begrijp het kernconcept
De MidJourney API simuleert Discord-knopinteracties. In tegenstelling tot typische REST API’s werkt deze als een state machine waarbij elke bewerking nieuwe knoppen teruggeeft voor de volgende stap.
De 4 kern-API’s
| API | Doel | Wanneer gebruiken |
|---|
POST /mj/submit/imagine | Tekst-naar-afbeelding-generatie | Startpunt voor alle workflows |
GET /mj/task/\{id\}/fetch | Taskstatus opvragen en knoppen ophalen | Na elke submit (poll tot voltooid) |
POST /mj/submit/action | Op een knop klikken (upscale, vary, zoom, enz.) | Wanneer je een bewerking op een afbeelding wilt uitvoeren |
POST /mj/submit/modal | Extra invoer versturen | Alleen wanneer status MODAL is |
Volledig workflowdiagram
┌─────────────────────────────────────────────────────────────────────────────┐
│ 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 │
└──────────────────┘
Kernconcept: knoppen en customId
Elke succesvolle task geeft een buttons-array terug. Elke knop heeft een customId die je gebruikt om de volgende actie te triggeren.
Voorbeeldresponse van /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": "🔄" }
]
}
customId is geen vaste waarde. Deze verandert voor elke task. Haal deze altijd op uit de buttons-array.
Knoppenreferentie per fase
Na IMAGINE (4-grid afbeelding)
Deze knoppen worden teruggegeven wanneer je eerste afbeeldingsgeneratie is voltooid:
| Button | customId Pattern | Action | Result |
|---|
| U1-U4 | MJ::JOB::upsample::1::xxx | Enkele afbeelding upscalen | Enkele afbeelding in hoge resolutie |
| V1-V4 | MJ::JOB::variation::1::xxx | Variaties genereren | Nieuwe 4-grid |
| 🔄 | MJ::JOB::reroll::0::xxx::SOLO | Alles opnieuw genereren | Nieuwe 4-grid |
Na UPSCALE (enkele afbeelding)
Na het upscalen krijg je toegang tot bewerkingstools:
| Label | Needs Modal? |
|---|
| Upscale (Subtle) / Upscale (2x) | ❌ Nee |
| Upscale (Creative) / Upscale (4x) | ❌ Nee |
| Vary (Subtle) 🪄 | ❌ Nee |
| Vary (Strong) 🪄 | ❌ Nee |
| Vary (Region) 🖌️ | ✅ Ja (masker) |
| Zoom Out 2x / 1.5x 🔍 | ❌ Nee |
| Custom Zoom 🔍 | ✅ Ja (prompt) |
| ⬅️➡️⬆️⬇️ Pan | ❌ Nee |
| Animate 🎞️ | ❌ Nee |
| 🔄 Reroll | ❌ Nee |
Opmerking: Knoplabels en customId-indelingen kunnen variëren afhankelijk van de MJ-versie die in je prompt is opgegeven (bijv. --v 6.1 versus --v 5.2). Lees de knoppen altijd uit het API-response.
De Inpaint-knop (Vary Region) verschijnt alleen na Upscale.
Volledig voorbeeld: Genereren en upscalen
Stap 1: Imagine-verzoek indienen
curl -X POST 'https://api.cometapi.com/mj/submit/imagine' \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H 'Content-Type: application/json' \
-d '{
"botType": "MID_JOURNEY",
"prompt": "a cute cat --v 6.1",
"accountFilter": { "modes": ["FAST"] }
}'
Response:
{ "code": 1, "result": "1768464763141701" }
Stap 2: Taskstatus pollen
curl -X GET 'https://api.cometapi.com/mj/task/1768464763141701/fetch' \
-H "Authorization: Bearer $COMETAPI_KEY"
Response (wanneer voltooid):
{
"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" },
...
]
}
Stap 3: Klik op U1 om te upscalen
curl -X POST 'https://api.cometapi.com/mj/submit/action' \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H 'Content-Type: application/json' \
-d '{
"taskId": "1768464763141701",
"customId": "MJ::JOB::upsample::1::5f20922e-xxx"
}'
Response:
{ "code": 1, "result": "1768464800000000" }
Stap 4: Poll de nieuwe taak en haal het resultaat op
curl -X GET 'https://api.cometapi.com/mj/task/1768464800000000/fetch' \
-H "Authorization: Bearer $COMETAPI_KEY"
Wanneer is Modal vereist?
Wanneer je /mj/submit/action aanroept en de taakstatus MODAL wordt in plaats van SUCCESS, moet je /mj/submit/modal aanroepen om extra invoer te geven.
Bevestigde Modal-bewerkingen
| Operation | Button | What to Submit |
|---|
| Inpaint | Vary (Region) | maskBase64 (PNG-masker) + prompt |
| Custom Zoom | 🔍 Custom Zoom | prompt (bijv. “your prompt —zoom 2”) |
Voorbeeld: Inpaint-flow
# 1. Click Vary (Region) button via Action API
curl -X POST 'https://api.cometapi.com/mj/submit/action' \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H 'Content-Type: application/json' \
-d '{"taskId": "xxx", "customId": "MJ::Inpaint::xxx", "enableRemix": true}'
# 2. Poll and see status = "MODAL"
curl -X GET 'https://api.cometapi.com/mj/task/new_task_id/fetch'
# Response: { "status": "MODAL" }
# 3. Submit mask and prompt via Modal API
curl -X POST 'https://api.cometapi.com/mj/submit/modal' \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H 'Content-Type: application/json' \
-d '{
"taskId": "new_task_id",
"prompt": "replace with golden crown",
"maskBase64": "data:image/png;base64,..."
}'
Snelheidsmodus selecteren
Voeg een snelheidsvoorvoegsel toe aan het pad:
| Modus | Padvoorvoegsel | Voorbeeld |
|---|
| Snel | /mj-fast | /mj-fast/mj/submit/imagine |
| Turbo | /mj-turbo | /mj-turbo/mj/submit/imagine |
| Relax | (standaard) | /mj/submit/imagine |
Andere entry points
Deze API’s zijn onafhankelijke entry points die de imagine → action-flow niet volgen:
| API | Doel |
|---|
POST /mj/submit/blend | Meng 2-5 afbeeldingen tot één |
POST /mj/submit/describe | Genereer een prompt uit een afbeelding |
POST /mj/submit/video | Converteer afbeelding naar video |
POST /mj/submit/edits | Bewerk afbeelding met masker |
Tips voor probleemoplossing
Op basis van het API-ontwerp en de workflow zijn dit veelvoorkomende problemen die je kunt tegenkomen:
| Probleem | Waarschijnlijke oorzaak | Oplossing |
|---|
| Kan de knop Vary (Region) niet vinden | Kijkt naar een 4-grid-afbeelding | Eerst upscalen (klik op U1-U4), controleer daarna de knoppen |
Taakstatus blijft hangen op MODAL | Bewerking vereist extra invoer | Roep /mj/submit/modal aan met de vereiste gegevens |
customId werkt niet | Verouderde of hardcoded waarde gebruikt | Haal altijd een verse customId op uit het antwoord van /mj/task/\{id\}/fetch |
Lege buttons-array | Taak is nog in uitvoering | Wacht op status: "SUCCESS" voordat je buttons benadert |