Skip to main content

diffusion(text, callback=None)

Create a new text-to-image generation task.
response = client.midjourney.diffusion(
    text="a serene mountain landscape at sunset",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • text (str): Text prompt (1-8192 characters)
  • callback (str, optional): Webhook URL
Returns: TaskResponse with job_id and status

variation(job_id, image_no, type, remix_prompt=None, callback=None)

Create variations of a generated image.
response = client.midjourney.variation(
    job_id="original-job-id",
    image_no=0,
    type=1,  # 0=Subtle, 1=Strong
    remix_prompt="add more clouds",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • type (int): Variation intensity (0=Subtle, 1=Strong)
  • remix_prompt (str, optional): Additional guidance
  • callback (str, optional): Webhook URL

upscale(job_id, image_no, type, callback=None)

Upscale a generated image.
response = client.midjourney.upscale(
    job_id="original-job-id",
    image_no=0,
    type=1,  # 0=Subtle, 1=Creative
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • type (int): Upscaling type (0=Subtle, 1=Creative)
  • callback (str, optional): Webhook URL

reroll(job_id, callback=None)

Regenerate with the same prompt.
response = client.midjourney.reroll(
    job_id="original-job-id",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • callback (str, optional): Webhook URL

blend(img_urls, aspect_ratio, callback=None)

Blend 2-5 images together.
response = client.midjourney.blend(
    img_urls=[
        "https://example.com/image1.png",
        "https://example.com/image2.png"
    ],
    aspect_ratio="1:1",  # "2:3", "1:1", or "3:2"
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • img_urls (list): List of 2-5 image URLs
  • aspect_ratio (str): Image ratio (“2:3”, “1:1”, or “3:2”)
  • callback (str, optional): Webhook URL

describe(img_url, callback=None)

Generate text descriptions from an image.
response = client.midjourney.describe(
    img_url="https://example.com/image.png",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • img_url (str): URL of image to describe
  • callback (str, optional): Webhook URL

shorten(prompt, callback=None)

Optimize and shorten a prompt.
response = client.midjourney.shorten(
    prompt="a very detailed and long prompt text...",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • prompt (str): Prompt text to optimize
  • callback (str, optional): Webhook URL

pan(job_id, image_no, direction, scale, remix_prompt=None, callback=None)

Extend image in a specific direction.
response = client.midjourney.pan(
    job_id="original-job-id",
    image_no=0,
    direction=0,  # 0=Down, 1=Right, 2=Up, 3=Left
    scale=1.5,    # 1.1-3.0
    remix_prompt="add mountains",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • direction (int): Direction to pan (0=Down, 1=Right, 2=Up, 3=Left)
  • scale (float): Expansion scale (1.1-3.0)
  • remix_prompt (str, optional): Additional guidance
  • callback (str, optional): Webhook URL

outpaint(job_id, image_no, scale, remix_prompt=None, callback=None)

Expand image in all directions.
response = client.midjourney.outpaint(
    job_id="original-job-id",
    image_no=0,
    scale=1.3,  # 1.1-2.0
    remix_prompt="add forest background",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • scale (float): Expansion scale (1.1-2.0)
  • remix_prompt (str, optional): Additional guidance
  • callback (str, optional): Webhook URL

inpaint(job_id, image_no, mask, remix_prompt=None, callback=None)

Edit specific regions using a mask.
with open("mask.png", "rb") as f:
    mask_data = f.read()

response = client.midjourney.inpaint(
    job_id="original-job-id",
    image_no=0,
    mask=mask_data,
    remix_prompt="add a rainbow in the sky",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • mask (bytes): Binary mask data (PNG format)
  • remix_prompt (str, optional): Description of edits
  • callback (str, optional): Webhook URL

remix(job_id, image_no, remix_prompt, mode=None, callback=None)

Transform image with a new prompt.
response = client.midjourney.remix(
    job_id="original-job-id",
    image_no=0,
    remix_prompt="turn into a watercolor painting",
    mode=0,  # 0=Strong, 1=Subtle
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • remix_prompt (str): New prompt for transformation
  • mode (int, optional): Remix strength (0=Strong, 1=Subtle)
  • callback (str, optional): Webhook URL

edit(job_id, image_no, canvas, img_pos, remix_prompt, mask=None, callback=None)

Edit with canvas positioning.
from legnext.types import Canvas, CanvasImg, Mask, Polygon

response = client.midjourney.edit(
    job_id="original-job-id",
    image_no=0,
    canvas=Canvas(width=1024, height=1024),
    img_pos=CanvasImg(width=512, height=512, x=256, y=256),
    remix_prompt="change the sky to sunset colors",
    mask=Mask(areas=[
        Polygon(width=1024, height=1024, points=[100, 100, 500, 100, 500, 500, 100, 500])
    ]),
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • canvas (Canvas): Canvas dimensions (width, height)
  • img_pos (CanvasImg): Image positioning on canvas
  • remix_prompt (str): Description of edits
  • mask (Mask, optional): Mask with polygon areas
  • callback (str, optional): Webhook URL

upload_paint(img_url, canvas, img_pos, remix_prompt, mask, callback=None)

Advanced painting on uploaded images.
from legnext.types import Canvas, CanvasImg, Mask

response = client.midjourney.upload_paint(
    img_url="https://example.com/image.png",
    canvas=Canvas(width=1024, height=1024),
    img_pos=CanvasImg(width=768, height=768, x=128, y=128),
    remix_prompt="add magical effects",
    mask=Mask(url="https://example.com/mask.png"),
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • img_url (str): URL of image to paint on
  • canvas (Canvas): Canvas dimensions (width, height)
  • img_pos (CanvasImg): Image positioning on canvas
  • remix_prompt (str): Description of effects
  • mask (Mask): Mask with URL
  • callback (str, optional): Webhook URL

retexture(img_url, remix_prompt, callback=None)

Change textures and surfaces.
response = client.midjourney.retexture(
    img_url="https://example.com/image.png",
    remix_prompt="metallic and shiny surfaces",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • img_url (str): URL of image to retexture
  • remix_prompt (str): Texture description
  • callback (str, optional): Webhook URL

remove_background(img_url, callback=None)

Remove the background from an image.
response = client.midjourney.remove_background(
    img_url="https://example.com/image.png",
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • img_url (str): URL of image to process
  • callback (str, optional): Webhook URL

enhance(job_id, image_no, callback=None)

Enhance image quality (draft to high-res).
response = client.midjourney.enhance(
    job_id="draft-job-id",
    image_no=0,
    callback="https://your-domain.com/webhook"  # Optional
)
Parameters:
  • job_id (str): Original image task ID
  • image_no (int): Image index (0-3)
  • callback (str, optional): Webhook URL

Next Steps