Skip to main content
POST
/
v1
/
diffusion
Text to Image
curl --request POST \
  --url https://api.legnext.ai/api/v1/diffusion \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "text": "<string>",
  "callback": "<string>"
}
'
Generate high-quality images from text descriptions using the Legnext AI image generation API.

Endpoint

POST https://api.legnext.ai/api/v1/diffusion

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key

Request Body

ParameterTypeRequiredDescription
textstringYesText prompt for image generation (1-8192 characters)
callbackstringNoCallback URL for task completion notifications

Example Request

curl -X POST "https://api.legnext.ai/api/v1/diffusion" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "A beautiful sunset over the snow mountains --v 7 --draft",
    "callback": "https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67"
  }'

Response

Returns a task object containing the task information.
{
    "job_id": "a616de55-6130-4e1f-b8cd-531ed0599353",
    "model": "midjourney",
    "task_type": "diffusion",
    "status": "completed",
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "https://webhook.site/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "secret": ""
        }
    },
    "input": null,
    "output": {
        "image_url": "https://cdn.legnext.ai/temp/1760408558306.png",
        "image_urls": [
            "https://cdn.legnext.ai/mj/a616de55-6130-4e1f-b8cd-531ed0599353_0.png",
            "https://cdn.legnext.ai/mj/a616de55-6130-4e1f-b8cd-531ed0599353_1.png",
            "https://cdn.legnext.ai/mj/a616de55-6130-4e1f-b8cd-531ed0599353_2.png",
            "https://cdn.legnext.ai/mj/a616de55-6130-4e1f-b8cd-531ed0599353_3.png"
        ],
        "seed": "1904983176",
        "available_actions": {
            "edit": [
                0,
                1,
                2,
                3
            ],
            "inpaint": [
                0,
                1,
                2,
                3
            ],
            "outpaint": [
                0,
                1,
                2,
                3
            ],
            "pan": [
                0,
                1,
                2,
                3
            ],
            "remix": [
                0,
                1,
                2,
                3
            ],
            "reroll": true,
            "upscale": [
                0,
                1,
                2,
                3
            ],
            "variation": [
                0,
                1,
                2,
                3
            ]
        }
    },
    "meta": {
        "created_at": "2025-10-14T02:22:04Z",
        "started_at": "2025-10-14T02:22:06Z",
        "ended_at": "2025-10-14T02:22:50Z",
        "usage": {
            "type": "point",
            "frozen": 80,
            "consume": 80
        }
    },
    "detail": null,
    "logs": [],
    "error": {
        "code": 0,
        "raw_message": "",
        "message": "",
        "detail": null
    }
}

Authorizations

x-api-key
string
header
required

API key for authentication

Body

application/json
text
string
required

Text prompt for image generation (1-8192 characters)

Required string length: 1 - 8192
callback
string<uri>

Callback URL for task completion notifications

Response

200

Task created successfully