Midjourney-Style Interface
CoreRouter provides a set of Midjourney-style asynchronous task interfaces. After submitting a task, it typically returns a task ID first, then you use the query interface to get progress, image addresses, and button operations.
These interfaces are not OpenAI Chat Completions interfaces and cannot use messages, input, or regular chat model request formats.
Interface Information
| Configuration | Value |
|---|---|
| Base URL | https://api.corerouter.cloud |
| API Key | Use Authorization: Bearer sk-... |
| Submission Path | /mj/submit/... |
| Query Path | /mj/task/{id}/fetch |
| Model Selection | Mapped by operation type to corresponding Midjourney model and channel |
Some deployments provide additional paths in the form /{mode}/mj/.... Only use this prefix when the service explicitly provides it; don't add or remove prefixes yourself.
Generate Images
/mj/submit/imagine automatically processes as an Imagine operation, prompt is required:
export COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"
curl https://api.corerouter.cloud/mj/submit/imagine \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"prompt": "A futuristic city floating in a sea of clouds, cinematic, rich details"
}'Successful response typically looks like:
{
"code": 1,
"description": "Submission successful",
"result": "task-id-from-upstream"
}result is the task ID used for subsequent queries. Different channels' code, description, and properties may vary; clients shouldn't rely solely on fixed Chinese descriptions to determine success.
Query Task
curl https://api.corerouter.cloud/mj/task/task-id-from-upstream/fetch \
-H "Authorization: Bearer $COREROUTER_API_KEY"Query results typically include:
| Field | Description |
|---|---|
id | Task ID |
status | Task status, e.g., SUCCESS |
progress | Progress, e.g., 50% |
imageUrl | Image address; whether rewritten to gateway proxy address depends on service configuration |
buttons | Buttons to continue operations like upscale, variant, etc. |
failReason | Failure reason |
Poll every few seconds; don't make high-frequency requests while task is incomplete.
Execute Operations Based on Buttons
Using customId
If buttons in query results contain customId, you can directly submit to /mj/submit/action:
curl https://api.corerouter.cloud/mj/submit/action \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"customId": "MJ::JOB::upsample::2::task-id-from-upstream"
}'Button customId must use the actual value returned in query results; don't manually guess task ID combination formats.
Using Regular Transform Parameters
/mj/submit/change requires task ID, action, and index:
curl https://api.corerouter.cloud/mj/submit/change \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"taskId": "task-id-from-upstream",
"action": "UPSCALE",
"index": 2
}'index is typically 1 to 4; specific available operations are determined by buttons returned from the channel.
If the client uses simplified format, you can also call /mj/submit/simple-change:
curl https://api.corerouter.cloud/mj/submit/simple-change \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"content": "task-id-from-upstream u2"
}'Simplified format supports u1 through u4, v1 through v4, and r for regenerate.
Other Operations
| Endpoint | Main Use | Common Fields |
|---|---|---|
/mj/submit/describe | Reverse engineer prompt from image | base64Array |
/mj/submit/blend | Multi-image blending | base64Array |
/mj/submit/edits | Image editing | base64Array, maskBase64, prompt |
/mj/submit/shorten | Shorten prompt | prompt |
/mj/submit/modal | Modal edit or extended operations | taskId, maskBase64, etc., depends on channel |
/mj/submit/video | Convert image task to video or video operation | taskId, action |
/mj/submit/upload-discord-images | Upload image to upstream | base64Array |
/mj/insight-face/swap | Face swap | sourceBase64, targetBase64 |
Image encoding, quantity, prompt parameters, and available actions for these operations are determined by the upstream channel. Fields in documentation are common fields the gateway can recognize, not a substitute for specific channel parameter descriptions.
Batch Query and Image Proxy
Batch query:
curl https://api.corerouter.cloud/mj/task/list-by-condition \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"ids": ["task-id-1", "task-id-2"]
}'If service configuration enables image proxy, you can use:
curl -L https://api.corerouter.cloud/mj/image/task-id-from-upstream \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
--output result.jpgIf image proxy is unavailable, use the imageUrl from task query results. Image addresses may be affected by upstream validity period, domain access, and server-side SSRF protection policies.
Compatibility Boundaries and Billing
- Only service instances configured with corresponding Midjourney channels, operations, and model pricing can use these interfaces.
- Midjourney operations are typically billed per request; when submission fails, balance insufficient, or channel unavailable, don't treat response as successful task.
- Whether
notifyHookworks depends on server-side notification configuration; can't treat it as a guaranteed callback capability. - Some service configurations remove
accountFilterornotifyHook; clients should rely on final task status. - Task IDs, button
customId, andimageUrlshould all use actual interface return values; don't construct them yourself.
Common Issues
Returns prompt_is_required
/mj/submit/imagine missing non-empty prompt. Confirm you're sending JSON and field name is not message or input.
Returns task_not_found
Confirm task ID comes from submission response's result or query result, and using the same API Key and account.
Returns quota_not_enough
Account quota insufficient, or fixed price for this operation is not configured. Check console balance and model configuration for the operation.
No Image All Along
Midjourney is an asynchronous task. First poll /mj/task/{id}/fetch, confirm status is SUCCESS, then use imageUrl or image proxy address.
