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 (Nanobanana / Seedream / Midjourney, etc.) and video models (Seedance 2.0, Veo 3.1); the server routes by 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. Length limits vary by model (see Models).
modelId
string
default:"nanobanana-2"
The model to use for generation. Get available models from the List Models endpoint.Image models: nanobanana-2, gemini-3-pro-image-preview, seedream-5.0-lite, seedream-4.5, midjourney-v7, midjourney-niji7, z-image-turbo, rhart-1.5Video models: seedance-2-0, veo-3.1
aspectRatio
string
default:"auto"
The aspect ratio for the generated output.
  • Default auto (recommended): a suitable ratio is picked for you. Video models with auto use that model’s primary ratio.
  • You can also pass an explicit value, which must be one of the ratios supported by the selected model. Common image ratios: 1:1, 3:4, 4:3, 16:9, 9:16, 21:9. Seedance also accepts the special value adaptive (matches the reference image/video dimensions).
resolution
string
default:"2K"
The output resolution. Availability depends on the model.Available values: image models 2K / 3K / 4K; video models 480p / 720p / 1080p (depends on the model — see Models).
referenceImages
string[]
Array of image URLs to use as references. Must be publicly accessible HTTPS URLs.Maximum number of reference images depends on the model (0–5).
niji7Options
object
Advanced parameters for Midjourney Niji 7 model only. Ignored for other models.
FieldTypeDefaultRange
stylizenumber1000–1000
chaosnumber00–100
weirdnumber00–3000
rawbooleanfalse
iwnumber10–2
srefstringURL or text
swnumber1000–1000
svnumber41–4
referenceType
string
default:"content"
For Midjourney V7 / Niji 7 only. How to interpret the reference image.
  • content — use as subject matter reference
  • style — extract visual style only
duration
number
For Seedance 2.0 only. Video duration in seconds, range 4–15, default 5. Veo 3.1 is fixed at 8 seconds and ignores this parameter.
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 or an R2 upload URL).When this field is present, billing uses the “with reference video” tier: 480p 8 credits/sec, 720p 16 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). The server uses this to compute max(referenceVideoDuration + duration, minBillable) for billing. Required when referenceVideo is set — otherwise the server treats it as 0, leading to under-billing (and likely a broken 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": 5,
  "modelId": "nanobanana-2",
  "credits": {
    "daily": 10,
    "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",
  "r2Key": null,
  "error": null
}

Response (Image Completed)

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

Response (Video Completed)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "imageUrl": null,
  "imageUrls": null,
  "videoUrl": "https://images.meigen.art/generations/xxx.mp4",
  "mediaType": "video",
  "r2Key": "generations/xxx.mp4",
  "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 V7 / Niji 7 return 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",
  "r2Key": null,
  "error": "Content policy violation"
}
When a generation fails, credits are automatically refunded.

Examples

Basic generation

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",
    "modelId": "nanobanana-2",
    "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"]
  }'

Niji 7 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-niji7",
    "aspectRatio": "3:4",
    "referenceImages": ["https://example.com/style-ref.jpg"],
    "referenceType": "style",
    "niji7Options": {
      "stylize": 300,
      "sw": 500,
      "sv": 4
    }
  }'

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 = 26 × 5 = 130 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.art/generations/eagle-clip.mp4",
    "referenceVideoDuration": 3
  }'
Pricing: 480p continuation tier 8 credits/sec, billable seconds = max(3 + 5, 9) = 9 sec, total 72 credits.

Auto ratio selection

Omit aspectRatio or pass "auto" explicitly:
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",
    "modelId": "nanobanana-2"
  }'
This request ends up generating a 16:9 image. The actual ratio used is returned in the response’s aspectRatio field.