Skip to main content
The MeiGen API lets you generate images and videos programmatically.
Prefer natural language? If you use Claude Code, Cursor, or OpenClaw, try the MCP Server for AI-native image generation without writing HTTP code.

Authentication

API requests require a Bearer token. There are two authentication methods: Use an API key that starts with meigen_sk_. Create one from your account settings under API Keys.
Authorization: Bearer meigen_sk_YOUR_API_KEY
API tokens can only use purchased credits. Daily free credits are not available for API calls. Ensure your account has purchased credits before making API requests.

Session Token

For meigen.ai’s own browser integration, a logged-in session access token is accepted. Daily free credits cover basic models only (currently Z Image Turbo); premium models always require welcome or purchased credits. Third-party integrations should always use the API Token above.

Base URL

https://www.meigen.ai/api

Request Format

All request bodies must be sent as JSON with the Content-Type: application/json header.
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", "modelId": "gpt-image-2"}'

Response Format

All responses return JSON. Successful responses include a success: true field:
{
  "success": true,
  "generationId": "abc-123",
  "status": "processing"
}
Error responses include an error field:
{
  "error": "Error description"
}

Asynchronous Generation

Image generation is asynchronous. The flow is:
  1. Submit a generation request → POST /api/generate/v2
  2. Poll the status endpoint → GET /api/generate/v2/status/:id
  3. Read the resulting imageUrl / imageUrls / videoUrl directly from the status response once status === "completed".

Polling Best Practices

  • Recommended interval: 3 seconds between status checks
  • Stop when: status is completed or failed
  • Timeout: 5 minutes for image models, 10 minutes for video. Per-model typical times are listed on the Models page.

Rate Limits

POST /api/generate/v2 is limited to 12 requests per minute per user. Exceeding the limit returns 429 Too Many Requests with these response headers:
  • Retry-After: 60
  • X-RateLimit-Limit: 12
  • X-RateLimit-Remaining: 0
When you hit 429, respect Retry-After and apply exponential backoff for repeated failures.

Caching

Some GET endpoints return cached responses:
EndpointCache Duration
GET /api/models5 minutes
GET /api/images/:id1 hour
POST endpointsNo caching

Credits

Each generation deducts credits from your account. Image models charge a flat amount per image; Seedance 2.0 is billed per second. See the Models page for the full per-model pricing table.

Error Responses

Status CodeMeaning
400Bad request — invalid parameters
401Unauthorized — invalid or missing token
402Payment required — insufficient credits
404Not found
429Rate limited — wait and retry
500Server error
For POST /api/generate/v2, the 400 / 402 bodies include extra fields useful for debugging:
// 400 — unsupported aspect ratio
{
  "success": false,
  "error": "Aspect ratio 32:9 not supported by this model",
  "supportedRatios": ["1:1", "3:2", "2:3", "16:9", "9:16", "4:3", "3:4", "5:4", "4:5", "21:9", "9:21"]
}

// 402 — not enough credits
{
  "success": false,
  "error": "Insufficient credits",
  "required": 10,
  "available": 4
}

Endpoints

Generate Image

POST /api/generate/v2

List Models

GET /api/models

Get Image

GET /api/images/:id

Manage Tokens

POST/GET/DELETE /api/tokens