Skip to main content
POST /api/generate/v2
Submits an image generation request. The image is generated asynchronously — use the status endpoint to poll for completion.

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:"gemini-3-pro-image-preview"
The model to use for generation. Get available models from the List Models endpoint.Available values: nanobanana-2, gemini-3-pro-image-preview, seedream-5.0-lite, seedream-4.5, midjourney-niji7, z-image-turbo, rhart-1.5, veo-3.1
aspectRatio
string
default:"1:1"
The aspect ratio for the generated image. Must be one of the ratios supported by the selected model.Common values: 1:1, 3:4, 4:3, 16:9, 9:16
resolution
string
default:"2K"
The output resolution. Availability depends on the model.Available values: 2K, 3K, 4K, 720p
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
stylizenumber1500–1000
chaosnumber00–100
weirdnumber00–3000
rawbooleantrue
iwnumber1.50–3
srefstringURL or text
swnumber1000–1000
svnumber41–4
referenceType
string
default:"content"
For Niji 7 only. How to interpret the reference image.
  • content — use as subject matter reference
  • style — extract visual style only

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": "gemini-3-pro-image-preview",
  "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,
  "videoUrl": null,
  "mediaType": "image",
  "r2Key": null,
  "error": null
}

Response (Completed)

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

Response (Failed)

{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "failed",
  "imageUrl": 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
    }
  }'