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>"
}
'
{
  "code": 400,
  "message": "Invalid request parameters",
  "raw_message": "Invalid request parameters",
  "detail": null
}

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 with status “pending”. The task will be processed asynchronously.
{
    "job_id": "789320d3-4b20-46d3-a804-6165a079176a",
    "model": "midjourney",
    "task_type": "diffusion",
    "status": "pending",
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "",
            "secret": ""
        }
    },
    "input": null,
    "output": {
        "image_url": "",
        "image_urls": null,
        "seed": ""
    },
    "meta": {
        "created_at": "2025-12-17T11:08:36Z",
        "started_at": "0001-01-01T00:00:00Z",
        "ended_at": "0001-01-01T00:00:00Z",
        "usage": {
            "type": "point",
            "frozen": 80,
            "consume": 0
        }
    },
    "detail": null,
    "logs": [],
    "error": {
        "code": 0,
        "raw_message": "",
        "message": "",
        "detail": null
    }
}
Use the job_id to check task status and retrieve the generated images when the task is completed.

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

Task created successfully