legnext
Installation
SKILL.md
Legnext API Integration
Legnext (https://api.legnext.ai) gives you Midjourney image and video generation through an asynchronous REST API: you submit a task, it runs out of band, and you collect the result by polling or callback. This skill is the integration methodology — exact fields and responses live in the generated reference at https://docs.legnext.ai. Read the files in references/ only when their topic is needed.
The integration loop
Every generation is three steps:
- Submit —
POST /api/v1/diffusionwith{ "text": "<prompt>", "callback": "<optional webhook>" }and thex-api-keyheader. Returns a job object withstatus: "pending"and ajob_id. Credits are frozen (reserved) at submit time — seereferences/task-lifecycle.md. - Wait — either poll
GET /api/v1/job/{job_id}untilstatusiscompletedorfailed, or receive a POST to yourcallbackURL when the job finishes. Persistjob_idbefore waiting. - Fetch & store — on
completed, readoutput.image_url(primary) andoutput.image_urls(grid). Download to permanent storage immediately — result URLs expire (seereferences/task-lifecycle.md).
Use x-api-key: $LEGNEXT_API_KEY on submit and account requests. GET /api/v1/job/{job_id} is the exception: it is unauthenticated and its UUID is a capability token. Keep it server-side and out of browser URLs, analytics, and public logs. Base URL: https://api.legnext.ai.
Decisions to make before writing code
Webhook vs polling
- Webhook (pass
callbackon submit): lower latency, no polling cost. Respond2xxfast; fetch the canonical result withGET /api/v1/job/{job_id}rather than trusting only the callback body. Dedupe byjob_idand keep polling as recovery. Task callbacks do not currently provide a public signing secret, so use an unguessable endpoint path and validate the method, content type, and body shape. - Polling (
GET /api/v1/job/{job_id}): use when there is no public endpoint — local dev, CLIs, or batch jobs behind NAT. Use a non-zero interval and a bounded client wait. A client timeout does not cancel the task; persist the state and let a worker resume the samejob_id.