Skip to main content
POST /api/generate/v2
Submits a generation request. The output is generated asynchronously — use the status endpoint to poll for completion. The same endpoint serves both image models (GPT Image 2, Nanobanana, Seedream, Midjourney, etc.) and video models (Seedance 2.0, Veo 3.1) — select via modelId.

Request

Headers

HeaderValue
AuthorizationBearer meigen_sk_YOUR_API_KEY
Content-Typeapplication/json

Body Parameters

prompt
string
required
The text description of the image to generate.
modelId
string
The model to use for generation. If omitted, the platform default is used (may change over time). Get available models from the List Models endpoint.Image models: gpt-image-2, gemini-3-pro-image-preview, nanobanana-2, seedream-5.0-lite, seedream-4.5, midjourney-v8.1, flux2-klein, z-image-turboVideo models: seedance-2-0, happyhorse-1.0, veo-3.1
rhart-1.5 (GPT image 1.5) was retired on 2026-04-22 — use gpt-image-2 instead. midjourney-v7 was replaced by midjourney-v8.1 on 2026-05-09 (legacy midjourney-v7 requests still accepted for backward compatibility).
aspectRatio
string
default:"auto"
The aspect ratio for the generated output.
  • Default auto (recommended): a suitable ratio is picked for you.
  • Or pass an explicit value — must be one of the ratios returned in supported_ratios from the List Models endpoint. Common image ratios: 1:1, 3:4, 4:3, 16:9, 9:16, 21:9, 5:4, 4:5.
  • Seedance also accepts adaptive, which matches the dimensions of referenceImages or referenceVideo. Only use adaptive when at least one of those is provided; behavior without a reference is undefined.
The final ratio used is returned in the status endpoint’s aspectRatio field.
resolution
string
The output resolution. Availability depends on the model. If omitted, the selected model’s default is used.Available values depend on the model: image models support 1K / 2K / 3K / 4K; video models support 480p / 720p / 1080p. See Models for each model’s supported resolutions and defaults.
quality
string
default:"low"
GPT Image 2.0 only. Accepts low / medium / high. Other models ignore this parameter.
referenceImages
string[]
Array of image URLs to use as references. Must be publicly accessible HTTPS URLs.Maximum count is per-model — see max_reference_images from List Models. Z Image Turbo accepts 0; Midjourney V8.1 / Happyhorse 1.0 accept 1; most others accept up to 5.
niji7Options
object
Advanced parameters for Midjourney V8.1. Ignored for other models. (Field name preserved for backward compatibility.)
FieldTypeDefaultRangeNotes
stylizenumber1000–1000
chaosnumber50–100
rawbooleanfalse
iwnumber10–2
srefstringURL or text
swnumber1000–1000
qualitystring41 or 4Defaults to High (4× compute, no extra cost)
referenceType
string
default:"content"
For Midjourney V8.1 only. How to interpret the reference image.
  • content — use as subject matter reference
  • style — extract visual style only
duration
number
Video duration in seconds. Seedance 2.0: 4–15 (default 5). Happyhorse 1.0: 3–15 (default 5). Veo 3.1: 4, 6, or 8 (default 4) — only these three values are accepted.
tier
string
Quality tier for models with multiple tiers. Currently supported by Seedance 2.0 and Veo 3.1: fast (default) or pro. Pro renders at higher fidelity for a higher price — see Models for the full pricing matrix.
referenceVideo
string
For Seedance 2.0 only. Reference video URL for “video continuation” mode. Must be a publicly accessible HTTPS URL (typically a previous generation result URL from the videoUrl field).When this field is present, billing uses the “with reference video” tier: 480p 8 credits/sec, 720p 14 credits/sec, 1080p 14 credits/sec, with the minimum-billable-seconds floor applied (see Models).
referenceVideoDuration
number
For Seedance 2.0 + reference-video continuation only. Duration of the reference video itself (seconds). Used together with duration to determine billable seconds (see the pricing table in Models). Required when referenceVideo is set — if omitted, it is treated as 0, which can lead to unexpectedly low charges and a misconfigured continuation.

Response

success
boolean
Whether the request was accepted.
generationId
string
The unique ID of the generation request. Use this to poll for status.
status
string
Initial status, always "processing".
creditsUsed
number
The number of credits deducted for this generation.
modelId
string
The model used for this generation.
credits
object
Updated credit balances after deduction.
FieldTypeDescription
dailynumberRemaining daily free credits
purchasednumberRemaining purchased credits
unlimitedbooleanWhether user has unlimited credits
{
  "success": true,
  "generationId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "processing",
  "creditsUsed": 10,
  "modelId": "gpt-image-2",
  "credits": {
    "daily": 2,
    "purchased": 50,
    "unlimited": false
  }
}

Check Generation Status

GET /api/generate/v2/status/:generationId
Poll this endpoint to check if your image is ready.

Response (Processing)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "processing",
  "imageUrl": null,
  "imageUrls": null,
  "videoUrl": null,
  "mediaType": "image",
  "error": null,
  "aspectRatio": "16:9"
}

Response (Image Completed)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "imageUrl": "https://images.meigen.ai/generations/xxx.png",
  "imageUrls": ["https://images.meigen.ai/generations/xxx.png"],
  "videoUrl": null,
  "mediaType": "image",
  "error": null,
  "aspectRatio": "16:9"
}

Response (Video Completed)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "imageUrl": null,
  "imageUrls": null,
  "videoUrl": "https://images.meigen.ai/generations/xxx.mp4",
  "mediaType": "video",
  "error": null,
  "aspectRatio": "16:9"
}
  • aspectRatio is the final ratio applied to this generation (if you passed auto, this is the value that was actually used).
  • mediaType is image or video. For video generations imageUrl/imageUrls are null, and vice versa.
  • Midjourney V8.1 returns 4 candidate images per generation. imageUrls contains all candidates; imageUrl always points to the first one. Other image models return a single image.

Response (Failed)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "failed",
  "imageUrl": null,
  "imageUrls": null,
  "videoUrl": null,
  "mediaType": "image",
  "error": "Content policy violation",
  "aspectRatio": "16:9"
}
When a generation fails, credits are automatically refunded.

Examples

Basic generation

Omit modelId to use the default (gpt-image-2):
curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A minimalist logo of a mountain, vector style, blue gradient",
    "aspectRatio": "1:1"
  }'

With reference image

curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Similar style landscape but with autumn colors",
    "modelId": "seedream-5.0-lite",
    "aspectRatio": "16:9",
    "referenceImages": ["https://example.com/reference.jpg"]
  }'

Midjourney V8.1 with style reference

curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a warrior princess in an enchanted forest",
    "modelId": "midjourney-v8.1",
    "aspectRatio": "3:4",
    "referenceImages": ["https://example.com/style-ref.jpg"],
    "referenceType": "style",
    "niji7Options": {
      "stylize": 300,
      "sw": 500
    }
  }'

Seedance video (text-to-video)

curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A majestic eagle soaring over a misty mountain valley at sunrise, cinematic camera movement",
    "modelId": "seedance-2-0",
    "aspectRatio": "16:9",
    "resolution": "720p",
    "duration": 5
  }'
Pricing: 720p × 5 sec = 20 × 5 = 100 credits.

Seedance video continuation (with reference video)

curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Continue the scene as the eagle dives toward a river below",
    "modelId": "seedance-2-0",
    "aspectRatio": "adaptive",
    "resolution": "480p",
    "duration": 5,
    "referenceVideo": "https://images.meigen.ai/generations/eagle-clip.mp4",
    "referenceVideoDuration": 3
  }'
Pricing: 480p With-reference-video rate 8 credits/sec, billable seconds = max(3 + 5, 9) = 9 sec, total 72 credits. Output video length = duration = 5 seconds.

Auto ratio selection

Omit aspectRatio or pass "auto" to let MeiGen pick a suitable ratio:
curl -X POST https://www.meigen.ai/api/generate/v2 \
  -H "Authorization: Bearer meigen_sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Blog hero banner image, abstract gradient background with code snippets"
  }'
The actual ratio used is returned as aspectRatio on the status endpoint.