legnext

Installation
SKILL.md

Legnext API Integration

Legnext (https://api.legnext.ai) gives you Midjourney image and video generation through a synchronous REST API: you submit a task, it runs asynchronously, and you collect the result by polling or webhook. This skill is the integration methodology — the API reference lives at https://docs.legnext.ai and is linked from each section below. Read the reference files in references/ on demand; do not load them all up front.

The integration loop

Every generation is three steps:

  1. SubmitPOST /api/v1/diffusion with { "text": "<prompt>", "callback": "<optional webhook>" } and the x-api-key header. Returns a job object with status: "pending" and a job_id. Credits are frozen (reserved) at submit time — see references/task-lifecycle.md.
  2. Wait — either poll GET /api/v1/job/{job_id} until status is completed or failed, or receive a POST to your callback URL when the job finishes. Pick one — see Webhook vs polling below.
  3. Fetch & store — on completed, read output.image_url (primary) and output.image_urls (grid). Download to permanent storage immediately — result URLs expire (see references/task-lifecycle.md).

Auth is a single header on every request: x-api-key: $LEGNEXT_API_KEY. Base URL: https://api.legnext.ai. Task endpoints live under /api/v1/{endpoint}; account under /api/account/.

Decisions to make before writing code

Webhook vs polling

  • Webhook (pass callback on submit): lower latency, no polling cost. Use when you have a publicly reachable HTTPS endpoint. Respond 2xx fast; the canonical result is still GET /api/v1/job/{job_id} — fetch it rather than trusting only the webhook body. Dedupe deliveries by job_id (a callback may arrive more than once).
  • Polling (GET /api/v1/job/{job_id}): use when there is no public endpoint — local dev, CLIs, batch jobs behind NAT. Poll every 5–10s. Most fast-mode images finish in under a minute, but complex/slow jobs can run ~5 minutes; cap your poll loop at ~10–15 min and treat that as a failure/timeout to investigate.
Installs
2
First Seen
1 day ago
legnext — legnext-ai/skills