API Doc-ElkAPI
  1. Best Practices
API Doc-ElkAPI
  • Quick Start
    • Quick Start
    • Must-read for beginners
    • ElkAPI Announcement
  • API Reference
    • Error status code description
    • OpenAI Format
      • Veo3-chat format
      • seedance
      • response
      • generate video
      • image
      • Image Editing (gpt-image-1)
      • embed
      • Realtime
      • Get model list
      • Response ID to obtain results
      • Hunyuan3D
    • Anthropic Format
      • Anthropic Claude
    • Midjourney Image Generation
      • Quick teaching-complete process in one go
      • Task Query
        • pagination query
        • Specify ID to obtain task
      • Submit Imagine task
      • Submit video task
      • Submit editing task
      • Submit Action Task
      • Submit Blend task
      • Submit Describe task
      • Submit Modal
    • Image Generation
      • ideogram(images)
        • Official documentation (updated in real time)
        • Generate 3.0 (illustrated in the text)
        • Reframe 3.0 (Refactoring)
        • Replace Background 3.0
        • Remix 3.0 (Mixed Graph)
        • Edit 3.0 (Edit)
        • Generate (text and image)
        • Remix (mixed image)
        • Upscale (enlarged high-definition)
        • Describe
        • Edit
      • Flux(images)
        • Create Task - General
        • generate image
        • Fine tuning (temporarily unavailable)
        • query task
        • Generate image (replica format)
      • Replicate(image)
        • Create Task - General
        • Create task - float kontext pro, max
        • Create task-black forest labs/flux-1.1-pro
        • Create task-black forest labs/flux-1.1-pro ultra
        • query task
        • Create task
      • Recraft(images)
        • Generate Image
        • Vectorize Image
        • Remove Background
        • Clarity Upscale
        • Create style
        • Generative Upscale
    • Music Generation
      • Suno
        • Set suno version
        • Suno API Scenario Application Guide
        • Generate lyrics
        • Generate music
        • Upload music
        • Song Splicing
        • Full track acoustic separation
        • Single track acoustic separation
        • Create a new Persona
        • Query a single task
        • Generate MP4 MV video
        • Retrieve WAV format files
        • Timing: Lyrics, audio timeline
        • Batch query task
        • Create music using persona_id
      • Udio (not available yet)
        • Generate music
        • Query a single task
    • Video Generation
      • veo3
        • veo3-chat format
        • Submit video generation task
        • Check the video generation status
      • Dream Test
        • seedance
      • runway(video)
        • Official format
          • Generate videos from images
          • Get detailed task information
        • Reverse format
          • Generate (text)
          • Generate (refer to image)
          • Video2video video to video style redrawing
          • Act one emoji transfer
          • Feed - Get Task
      • kling (video)
        • Callback Protocol
        • image expansion
        • generate image
        • text-to-video
        • image-to-video
        • Video extension
        • Virtual try on
        • lip-sync
        • video effects
        • Query task (single)
      • luma (video)
        • Official API format
          • generate video
          • Single query task
      • MiniMax Conch (video)
        • Official Documentation
        • video generation
        • query task
        • File Download
      • PIKA(video)
        • Universal version
          • generate video
          • Query video tasks
        • Generate (reference video/extended video)
        • Generate (refer to image)
        • Generate (text)
        • feed
      • sora
        • Reverse format
          • Create video
          • Generate Video
          • Query video tasks
    • Audio
      • Text to audio conversion
      • audio to text
      • Create translation
  • Integration Guide
    • Best Practices
      • Claude code access instructions
      • ElkAPI Account Balance Query API Usage Instructions
      • Retry logic documentation using ElkAPI and OpenAI's official API
      • Midjorney Calling Best Practices
      • Runway Call Best Practices
    • Application Integration Guide
  • Pricing and Billing
    • About Price
    • About Grouping
  • Help Center
    • Help Center
    • Interface stability
    • Common Misconceptions
    • Use confusion
    • Privacy Policy
    • Terms of Service
  1. Best Practices

Midjorney Calling Best Practices

HOST: https://api.elkapi.com
All requests must include their own key in the header:
headers = {"Authorization": "sk-hjbazhiawxxxxxxxxxx"}

1. Submit an Imagine (drawing) task#

API Information#

API Address: https://api.elkapi.com/mj/submit/imagine
Request Method: POST
Request Data Type: application/json
Response Data Type: /

Request Example#

{
"base64Array": [],
"notifyHook": "",
"prompt": "Cat",
"state": ""
}

Request Parameters#

Parameter NameParameter DescriptionRequest TypeRequiredData Type
idTask IDpathnostring

Response status#

Status codeDescription
200OK
201Created
401Unauthorized
403Forbidden
404Not Found

Response parameters#

Parameter nameParameter descriptionType
codeStatus code: 1 (Submission successful), 21 (Already exists), 22 (Queued), 4 (Internal program error)integer (int32)
descriptionDescriptionstring
propertiesExtension fieldsobject
resultTask IDstring

Response example#

{
"code": 1,
"description": "Submission successful",
"properties": {},
"result": 1320098173412546
}

2. Executing an Action#

API Information#

API Address: https://api.elkapi.com/mj/submit/action
Request Method: POST
Request Data Type: application/json
Response Data Type: /
API Description: All associated button actions: UPSCALE; VARIATION; REROLL; ZOOM, etc.

3. Drawing Changes#

API Information#

API Address: https://api.elkapi.com/mj/submit/change
Request Method: POST
Request Data Type: application/json
Response Data Type: /

Request Example#

{
"action": "UPSCALE",
"index": 1,
"notifyHook": "",
"state": "",
"taskId": "1320098173412546"
}

Request Parameters#

Parameter NameParameter DescriptionRequiredData Type
actionUPSCALE (upscale); VARIATION (transform); REROLL (regenerate)Yesstring
indexSequence number (1-4), required when action is UPSCALE and VARIATIONNointeger (int32)
notifyHookCallback address, if left blank, uses the global notifyHookNostring
stateCustom ParametersNostring
taskIdTask IDYesstring

Response Status#

Status CodeDescription
200OK
201Created
401Unauthorized
403Forbidden
404Not Found

Response Parameters#

Parameter NameParameter DescriptionType
codeStatus Code: 1 (Submission Successful), 21 (Already Exists), 22 (Queued), other (Error)integer (int32)
descriptionDescriptionstring
propertiesExtension Fieldsobject
resultTask IDstring

Response Example#

{
"code": 1,
"description": "Submission Successful",
"properties": {},
"result": 1320098173412546
}

4. Submit Modal (Partial Redraw, Zoom)#

API Information#

API Address: https://api.elkapi.com/mj/submit/modal
Request Method: POST
Request Data Type: application/json
Response Data Type: /
API Description: For midjourney pop-up operations, you must submit the corresponding data.

Request Example#

{
"maskBase64": "",
"prompt": "",
"taskId": "14001934816969359"
}

Request Parameters#

Parameter NameParameter DescriptionRequiredData Type
maskBase64Base64 mask for partial redrawNostring
promptPromptNostring
taskIdTask IDyesstring

Response Status#

Status CodeDescription
200OK
201Created
401Unauthorized
403Forbidden
404Not Found

Response Parameters#

Parameter NameParameter DescriptionType
codeStatus Code: 1 (Submission Successful), 21 (Already Exists), 22 (Queued), other (Error)integer (int32)
descriptionDescriptionstring
propertiesExtension Fieldsobject
resultTask IDstring

Response Example#

{
"code": 1,
"description": "Submission Successful",
"properties": {},
"result": 1320098173412546
}

5. Get a task by specifying its ID#

API Information#

API Address: https://api.elkapi.com/mj/task/{id}/fetch
Request Method: GET
Request Data Type: application/x-www-form-urlencoded
Response Data Type: /

Request Parameters#

Parameter NameParameter DescriptionRequest TypeRequiredData Type
idTask IDpathnostring

Response Status#

Status CodeDescription
200OK
401Unauthorized
403Forbidden
404Not Found

Response Parameters#

Parameter NameParameter DescriptionType
actionAvailable values: UPSCALE, VARIATION, REROLL, DESCRIBE, BLENDstring
descriptionTask descriptionstring
failReasonFailure reasonstring
finishTimeEnd timeinteger (int64)
idTask IDstring
imageUrlImage URLstring
progressTask progressstring
promptPrompt wordstring
promptEnPrompt word (English)string
startTimeStart execution timeinteger (int64)
stateCustom parameterstring
statusTask status, available values: SUBMITTED, IN_PROGRESS, FAILURE, SUCCESSstring
submitTimeSubmission timeinteger (int64)

Response Example#

{
"id": "1712310326047513", 
"action": "UPSCALE", 
"customId": "", 
"botType": "", 
"prompt": "a lovely Japanese countryside --niji 6 --ar 16:9", 
"promptEn": "a lovely Japanese countryside --niji 6 --ar 16:9", 
"description": "Submit success", 
"state": "", 
"submitTime": 1712310326047, 
"startTime": 1712310328336, 
"finishTime": 1712310329602, 
"imageUrl": "https://api.elkapi.com/mj/image/1712310326047513", 
"status": "SUCCESS", 
"progress": "100%", 
"failReason": "", 
"buttons": [
{
"customId": "MJ::JOB::upsample_v6_2x_subtle::1::125fd761-3d07-4252-8513-8a07dce51ce7::SOLO",
"emoji": "upscale_1",
"label": "Upscale (Subtle)",
"type": 2,
"style": 2
},
// ... other button configurations
],
"maskBase64": "",
"properties": {
"finalPrompt": "a lovely Japan countryside --niji 6 --ar 16:9",
"finalZhPrompt": ""
}
}
Previous
Retry logic documentation using ElkAPI and OpenAI's official API
Next
Runway Call Best Practices
Built with