Skip to main content
中文 · Connection setup · Five Skills HTTP API Use MeiGen as a callable step inside an existing agent, Skill, script or application. The caller owns the creative plan, prompts, model/provider choices, output count, approved budget, scheduling and presentation. Optional MeiGen creative assistants can help develop a brief; they are not required before calling tools. Discovery can support any workflow. A resolved upstream plan does not need another approval for every frame, clip or batch. Requires local meigen@2.0.0 or later (npx -y meigen@2.0.0), or the updated remote endpoint https://www.meigen.ai/api/mcp. npm 1.4.0 does not implement this contract. Release order is backend deployment, npm publication, then public installation guides; until 2.0.0 is published, validate a locally built package. Reconnect and inspect the installed schemas for requestId, wait and request lookup. Backend rollbacks must preserve recovery endpoints and the durable POST contract; users do not need to withdraw already installed npm packages.

Ordinary task contract

The recoverable cloud-task contract above is for MeiGen. Optional local OpenAI-compatible/ComfyUI providers may expose different asynchronous support; inspect their tool schema and returned errors rather than assuming a MeiGen receipt exists for those jobs. Preserve explicitly supplied model/provider and generation settings. list_models is available whenever a workflow needs current capabilities or prices; video requires a model. Read structuredContent, not a human-readable sentence or a local filename, to advance a workflow. Ordinary results share these fields when available:
  • success, status: processing, completed, failed, error or unknown.
  • requestId, generationId, actual mediaType, optional original requestedMediaType, modelId, deduped.
  • urls (always an array), plus imageUrl or videoUrl when returned.
  • creditsUsed, creditsStatus; a refund is confirmed only by the returned ledger state.
  • pollAfterSeconds, observationEnded; nextAction can carry type, tool, arguments, afterSeconds, message.
  • error: code, message, retryable, and optional httpStatus, retryAfterSeconds, required, available.
  • Local npm may also return provider, savedPath, downloadWarning (generation succeeded but local saving failed) and receiptWarning (private durable storage unavailable; keep request IDs and exact inputs in the caller).
A submitted job is not a completed artifact. unknown is an observation/recovery state, not permission to generate a replacement. Ordinary tasks use check_generation; the five dedicated Skills use their own check_skill, original Skill/request ID and exact retryParameters. Skill receipts require the original API key; ordinary request lookup supports another active API key of the same owning account. Do not transfer Web-session free-credit jobs into API-token billing.

Minimal call

With an authenticated connected MCP client, this complete step has no external plan variables. Persist input before calling; the UUID below is for this one example only. Use a new UUID for a different intended image, and reuse the saved one when resuming.

Example: N scripts → N frames → N videos

The upstream workflow first resolves the scripts, image/video settings, requested output count, maximum approved budget and any replacement policy. It can use list_models for current choices. No fixed model, price, duration or quality is assumed here.
  1. Create and durably save one frame UUID and one video UUID per script, alongside the exact inputs. Do this once when creating the workflow, not on every run or retry.
  2. Before a new submission, reserve its expected charge against the remaining approved budget, including all other in-flight reservations. Use the selected live model/tier/duration/reference pricing; reconcile actual creditsUsed and confirmed refunds as results arrive. An unknown charge stays reserved until resolved.
  3. Submit independent frame steps with bounded concurrency. Persist each response immediately. After a frame completes, preserve its selected URL in that script’s video input before submitting the video step. This maintains a stable dependency even if the frame model returns multiple candidates.
  4. Poll/recover accepted steps by their existing handles. A host restart reloads the saved plan and checks pending steps; it does not recreate UUIDs or re-upload unchanged references.
  5. Return completed clips and any failed/unresolved steps to the caller. The caller decides intermediate previews, visual inspection, downloads, final presentation and whether an authorized replacement is appropriate.
The following JavaScript shows MCP calls from an existing caller. script, settings and persisted IDs come from that caller’s durable plan; client is its connected MCP client. These are call examples, not a scheduler or a new API SDK.
Local npm has four shared API submission slots. Polling and downloading do not occupy these slots; this does not cap the number of accepted jobs still running remotely. Its ComfyUI executor runs one job at a time. The caller should bound both submissions and outstanding paid work. Respect actual backend rate limits and Retry-After; there is no universal ten-image workflow cap or blanket ban on parallel video jobs. The budget is a caller-managed limit, not an atomic server-enforced batch cap. Estimates can change; stop for a newly required price/resize decision outside existing authorization. Independent steps can partially succeed, and a failure does not roll back completed frames or clips. Local wait: true retries transient status-query errors within bounds: stop after three consecutive errors and reset the count on a valid status. Honor a larger Retry-After; queries and backoff share the total observation budget. Cancellation and terminal errors stop immediately. This retries queries only, never generation POSTs, and does not prove cancellation, failure or refund.

Resume without creating duplicate jobs

For ordinary tasks, remote attemptId remains a legacy compatibility handle. Prefer UUID requestId in new integrations. Older receipts may lack the normalized input data needed to verify all past parameter mismatches; do not assume the new protection can retroactively validate every old task. Legacy key rotation: when an old attemptId submission lost its response, recover it using the original key before revoking that key. The old handle incorporates the key; a new key cannot reconstruct an unrecorded old identity. Keep a returned generationId when available, and do not automatically resubmit an unresolved legacy attempt with a new key.