Saltar al contenido principal

Endpoints

MétodoEndpointDescripción
POST/api/v1/generateTask/midjourneyCrear tarea de generación
GET/api/v1/statusTask/midjourneyConsultar estado de la tarea

Autenticación

Todas las solicitudes requieren una clave API en el header:
Authorization: Bearer YOUR_API_KEY

Cuerpo de la solicitud

{
  "request_type": "async",
  "callback_url": "https://...",
  "provider": "auto",
  "input": {
    "mode": "text-to-image",
    "version": "v7",
    "speed": "fast",
    "prompt": "..."
  }
}

Parámetros

Common Parameters

request_type
string
predeterminado:"async"
async (polling) or callback (webhook)
callback_url
string
Callback URL, required when request_type=callback (conditional)
provider
string
predeterminado:"auto"
Routing strategy: auto, value, or official

Input Parameters

All modes require the input object with mode-specific parameters. Universal Input Parameters:
mode
string
requerido
Operation mode: text-to-image, image-to-image, vary, or upscale
version
string
predeterminado:"v6.1"
Model version (see version guide below). Options: ‘v6’, ‘v6.1’, ‘v7’, ‘niji 6’, ‘niji 7’
speed
string
predeterminado:"fast"
Generation speed: ‘fast’ or ‘turbo’
Optional Enhancement Parameters:
enableTranslation
boolean
predeterminado:"false"
Auto-translate prompts to English for better results. English prompts typically perform better in Midjourney.
aspect
string
predeterminado:"1:1"
Image aspect ratio. Options: 1:1 (square), 4:3 (classic), 2:3 (portrait), 16:9 (widescreen), 9:16 (mobile). Full list: 1:1, 1:2, 2:1, 2:3, 3:2, 3:4, 4:3, 5:6, 6:5, 9:16, 16:9
chaos
integer
predeterminado:"0"
Variation level (0-100). Low (0-30): consistent results. Medium (30-70): balanced variety. High (70-100): diverse, unexpected results.
stylize
integer
predeterminado:"100"
Artistic vs realistic balance (0-1000). Low (0-250): realistic, literal. Medium (250-750): balanced. High (750-1000): highly artistic.
weird
integer
predeterminado:"0"
Surreal/unconventional effects (0-3000). Low (10-300): subtle quirks. Medium (300-1000): noticeable unusual elements. High (1000-3000): extreme surrealism.

Model Version Guide

Available Versions: v6, v6.1, v7, niji 6, niji 7 (Default: v6.1) v7 (Latest, April 2025)
  • Best overall quality with breakthrough improvements in text/image understanding
  • Exceptional accuracy in human anatomy, hand details, and object textures
  • Includes Sketch Mode for rapid iteration and enhanced image reference capabilities
  • Recommended for: Professional work requiring highest quality and detail
v6.1 (Default, July 2024)
  • ~25% faster than v6 with more coherent results
  • Precise details and textures with excellent balance of speed and quality
  • Recommended for: General use and production workflows
v6 (December 2023)
  • Improved prompt accuracy for longer inputs and enhanced coherence
  • Advanced image prompting and remix capabilities
  • Recommended for: Projects requiring specific v6 characteristics
niji 7 (Latest for Anime)
  • Professional anime creation with precise character control and rich stylization
  • Dramatic lighting, flexible style adjustment from photorealistic to highly stylized
  • Superior multi-character consistency and aesthetic quality
  • Recommended for: Anime, manga, and illustration projects
niji 6 (June 2024)
  • Specialized for Eastern/anime aesthetics with improved Japanese text rendering
  • Better anime eye structure and detail rendering
  • Recommended for: Anime-style illustrations with Japanese text

Mode: text-to-image (Text-to-Image Generation)

Generate images from text descriptions.
mode
string
requerido
Set to ‘text-to-image’
prompt
string
requerido
Text description, 1-2000 characters
version
string
requerido
Model version: ‘v6.1’, ‘v7’, ‘niji 6’, or ‘niji 7’
speed
string
requerido
Generation speed: ‘fast’ or ‘turbo’
Note: text-to-image mode also supports optional enhancement parameters (aspect, chaos, stylize, weird, enableTranslation) listed above.

Mode: image-to-image (Image-to-Image Generation)

Generate new images based on reference images. Use descriptive language in prompts rather than editing instructions. Best Practice: Describe the desired result, not the editing action.
  • ✅ Good: “a dog lying in a park”
  • ❌ Bad: “change the background to a park”
mode
string
requerido
Set to ‘image-to-image’
prompt
string
requerido
Descriptive text of desired result (not editing instructions). Use descriptive language: ‘a dog in a park’ instead of ‘change background to park’
image_urls
string[]
requerido
Array of reference image URLs. More images = less control over output. Recommended: 1-2 images for better results
version
string
requerido
Model version: ‘v6.1’, ‘v7’, ‘niji 6’, or ‘niji 7’
speed
string
requerido
Generation speed: ‘fast’ or ‘turbo’

Mode: upload-paint (Inpainting / Region Editing)

Edit specific regions of an image by painting a mask. Requires precise mask definition.
mode
string
requerido
Set to ‘upload-paint’
prompt
string
requerido
Text description for the masked region
image_urls
string[]
requerido
Array with 1 image URL (the source image to edit)
version
string
requerido
Model version: ‘v6.1’, ‘v7’, ‘niji 6’, or ‘niji 7’
speed
string
requerido
Generation speed: ‘fast’ or ‘turbo’
mask
object
requerido
Inpainting region (choose one method: areas or url)
canvas
object
requerido
Canvas dimensions
imgPos
object
requerido
Image position and size on canvas

Mode: vary (Create Variations)

Generate similar but varied versions of a previous result.
mode
string
requerido
Set to ‘vary’
taskId
string
requerido
Previous task ID
imageIndex
integer
requerido
Image index from previous result (0-3)
type
integer
requerido
Variation strength: 0=Subtle variation, 1=Strong variation
prompt
string
Optional text guidance for the variation

Mode: upscale (High-Resolution Upscaling)

Upscale a previous result to higher resolution.
mode
string
requerido
Set to ‘upscale’
taskId
string
requerido
Previous task ID
imageIndex
integer
requerido
Image index from previous result (0-3)
type
integer
requerido
Upscale type: 0=Standard HD, 1=Creative HD, 2=2x HD, 3=4x HD

Available Modes

Currently Available:
  • text-to-image — Text-to-image generation
  • image-to-image — Image-to-image generation with reference images
  • upload-paint — Inpaint specific regions (requires mask)
  • vary — Create variations with similar style
  • upscale — High-resolution upscaling
Additional Capabilities (Contact us to enable):
  • Outpaint — Extend image boundaries
  • Retexture — Apply new textures to images
  • Remove Background — Background removal
  • Reroll — Re-execute generation task

Examples

Text-to-Image

curl -X POST "https://api.apixo.ai/api/v1/generateTask/midjourney" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/callback",
    "provider": "value",
    "input": {
      "mode": "text-to-image",
      "prompt": "一个温馨的赛博朋克咖啡馆,霓虹灯光,电影级照明",
      "version": "v7",
      "speed": "fast",
      "aspect": "16:9",
      "enableTranslation": true,
      "stylize": 500,
      "chaos": 20
    }
  }'

Image-to-Image

curl -X POST "https://api.apixo.ai/api/v1/generateTask/midjourney" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "provider": "official",
    "input": {
      "mode": "image-to-image",
      "prompt": "a dog lying in a beautiful park with green grass and trees",
      "image_urls": ["https://example.com/dog-at-home.jpg"],
      "version": "v7",
      "speed": "fast"
    }
  }'

Upload-Paint (Inpainting)

curl -X POST "https://api.apixo.ai/api/v1/generateTask/midjourney" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "provider": "official",
    "input": {
      "mode": "upload-paint",
      "prompt": "add a modern coffee machine in the center",
      "image_urls": ["https://example.com/cafe.jpg"],
      "version": "v7",
      "speed": "fast",
      "mask": {
        "areas": [{
          "width": 512,
          "height": 512,
          "points": [10,10,10,100,100,100,100,10]
        }]
      },
      "canvas": {
        "width": 1024,
        "height": 1024
      },
      "imgPos": {
        "width": 512,
        "height": 512,
        "x": 256,
        "y": 256
      }
    }
  }'

Vary (Create Variation)

curl -X POST "https://api.apixo.ai/api/v1/generateTask/midjourney" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "vary",
      "taskId": "task_previous_midjourney",
      "imageIndex": 0,
      "type": 1,
      "prompt": "add more vibrant colors"
    }
  }'

Upscale

curl -X POST "https://api.apixo.ai/api/v1/generateTask/midjourney" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "upscale",
      "taskId": "task_previous_midjourney",
      "imageIndex": 2,
      "type": 1
    }
  }'

Respuesta

POST /api/v1/generateTask/midjourney

Devuelve taskId en éxito para consultas de estado posteriores. Éxito:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Error:
{
  "code": 400,
  "message": "Insufficient credits",
  "data": null
}

GET /api/v1/statusTask/midjourney

Consulta el estado de ejecución y resultados de la tarea vía taskId.
curl -X GET "https://api.apixo.ai/api/v1/statusTask/midjourney?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Éxito:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/img1.png\",\"https://r2.apixo.ai/img2.png\",\"https://r2.apixo.ai/img3.png\",\"https://r2.apixo.ai/img4.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Fallido:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines"
  }
}

Campos de respuesta de estado

taskId
string
Identificador único de la tarea.
state
string
Estado actual: pending, processing, success, or failed.
resultJson
string
JSON string containing resultUrls array. Only present on success. Parse with JSON.parse().
failCode
string
Error code. Only present when state is failed. See Códigos de error.
failMsg
string
Human-readable error message. Only present when state is failed.
createTime
integer
Task creation timestamp (Unix milliseconds).
completeTime
integer
Task completion timestamp (Unix milliseconds).
costTime
integer
Processing duration in milliseconds.

Códigos de error

CódigoDescripción
400Parámetros inválidos o error de solicitud
401Clave API inválida o faltante
429Límite de tasa excedido
Fail CodeDescripción
CONTENT_VIOLATIONContent violates safety guidelines
INVALID_IMAGE_URLCannot access provided image URL
INVALID_TASK_IDInvalid previous task ID

Límites de tasa

LímiteValor
Requests10000 / minute
Concurrent tasks1000
Superar los límites devuelve error 429. Espera y reintenta.

Consejos

  • Prompt translation: Enable enableTranslation: true for non-English prompts. English typically yields better results in Midjourney.
  • Aspect ratio: Choose based on use case:
    • 1:1 - Social media posts, avatars
    • 4:3 - Classic photography, presentations
    • 16:9 - Widescreen, videos, banners
    • 9:16 - Mobile stories, vertical videos
  • Chaos parameter: Control result diversity:
    • 0-30 - Consistent, predictable results (recommended for production)
    • 30-70 - Balanced variety with creative exploration
    • 70-100 - Maximum diversity, experimental outputs
  • Stylize parameter: Balance realism vs artistry:
    • 0-250 - Literal interpretation, realistic
    • 250-750 - Balanced (default: 100)
    • 750-1000 - Highly artistic, creative interpretation
  • Weird parameter: Add surreal/unconventional elements:
    • 10-300 - Subtle unusual touches
    • 300-1000 - Noticeable non-traditional elements
    • 1000-3000 - Extreme surrealism and abstraction
  • Generation time:
    • fast mode: ~30-45 seconds, generates 4 images
    • turbo mode: ~15-25 seconds, faster
    • Submit task, wait 20 seconds, then poll every 3 seconds
  • Callback mode: Use callback mode to avoid frequent polling.
  • Image expiration: Result URLs are valid for 15 days. Download promptly.
  • Content moderation: Prompts must comply with safety guidelines.
  • Version selection: See the Model Version Guide above for detailed recommendations on choosing the right version for your use case
  • Recommended workflow:
    1. Use text-to-image to generate initial 4 images
    2. Select preferred image (0-3), use upscale for high-resolution output
    3. Or use vary to create more variations
    4. Iterate until desired result
  • Image-to-image mode:
    • Use descriptive language in prompts: describe what you want to see, not editing actions
    • Example: “a dog in a park” instead of “change background to park”
    • More reference images = less control over output. Use 1-2 images for best results
  • Upload-paint mode (inpainting):
    • mask.areas: Define polygon regions with width, height, and points array. Points are in clockwise order as [x1,y1,x2,y2,…] from top-left origin
    • mask.url: Black/white mask image with same dimensions as original (white = regenerate region). Supports base64 encoding
    • imgPos: Specifies image position and size on canvas
  • Upscale types:
    • Type 0: Standard HD
    • Type 1: Creative HD (adds creative details)
    • Type 2: 2x HD resolution
    • Type 3: 4x HD resolution
  • Image formats: image_urls supports JPG, PNG, WebP, max 10MB per image.

Result URLs expire after 15 days. Download and store important outputs promptly. For high-concurrency scenarios, use callback mode to avoid frequent polling.

Relacionado