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.
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, Flux 2 Klein, Agnes Image 2.1 Flash and Agnes Video 2.0); every other model always requires welcome or purchased credits. Third-party integrations should always use the API Token above.

Base URL

Request Format

All request bodies must be sent as JSON with the Content-Type: application/json header.

Response Format

All responses return JSON. Successful responses include a success: true field:
Error responses include an error field:

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: allow up to 6 minutes for image models and up to 12 minutes for video. A job that overruns comes back as failed and the credits are refunded in full — the output is discarded, so a late result never arrives. Short of that, the opposite applies: if your client stops polling early, the job still completes and is still charged. Poll until status is terminal (completed / failed), and treat the wall-clock values above only as a backstop. The slowest cases are Seedance 2.0 and Veo 3.1 at high resolution / long duration. Per-model typical times are listed on the Models page.

Caching

Some GET endpoints return cached responses: Model list changes — a new model, a retired one, a changed default — can therefore take up to an hour to become visible. Plan your own refresh cadence accordingly.

Credits

Each generation deducts credits from your account. Image models charge per image (the amount can vary with resolution and quality); video models are billed per second or per generation, depending on the model. See the Models page for the full per-model pricing table.

Error Responses

For POST /api/generate/v2, error bodies include extra fields useful for debugging, and most carry a machine-readable code alongside the human-readable error: Errors without a code (such as an unsupported aspect ratio) should be handled by status code and error text.

Endpoints

Generate Image

POST /api/generate/v2

List Models

GET /api/models

Get Image

GET /api/images/:id

API Tokens

Create & revoke in account settings