Skip to main content
The MeiGen API allows you to generate images programmatically. All endpoints are available at https://www.meigen.ai/api/.
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 browser-based integrations, you can use a Supabase session access token. This method uses both daily and purchased credits.

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": "gemini-3-pro-image-preview"}'

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. Retrieve the completed image → GET /api/images/:id

Polling Best Practices

  • Recommended interval: 3 seconds between status checks
  • Stop when: status is completed or failed
  • Timeout: consider giving up after 5 minutes for image models, 10 minutes for video

Typical Generation Times

ModelTypical Time
Z Image Turbo~5 seconds
Nanobanana 2, Seedream~15 seconds
Nanobanana Pro~15 seconds
GPT image1.5~20 seconds
Midjourney V7 / Niji 7~60 seconds
Seedance 2.0 (video)~1–3 minutes
Veo 3.1 (video)2–6 minutes

Rate Limits

API requests are subject to rate limiting. If you receive a 429 Too Many Requests response:
  • Wait 10–30 seconds before retrying
  • Implement exponential backoff for repeated failures
  • Specific rate limits may vary based on server load

Caching

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

Credits

Each generation consumes credits based on the model used. Check the Models page for per-model pricing.
ModelCredits
Z Image Turbo2
GPT image1.52
Nanobanana 25
Seedream 5.0 Lite5
Seedream 4.55
Nanobanana Pro10
Midjourney V715
Niji 715
Seedance 2.0Per-second (see Models)
Veo 3.120

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

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