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

Base URL

Before choosing a model, call List Models. The following example requires gpt-image-2.5 to be active. GPT Image 2 remains available under its own ID and pricing when returned by that endpoint.

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
  • While status is processing, the response includes expectedWaitSeconds (estimated remaining wait for this model and resolution) and pollHintSeconds (how many more seconds to keep polling — 0 means you can stop). Use these instead of a fixed timeout: actual time varies by model, resolution, and duration. Per-model typical times are listed on the Models page.
  • If your client stops polling early, the job still completes and is still charged — always poll until status reaches a terminal state.

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: Any other error — including all 5xx responses — means the service is temporarily unavailable. Retry later; the credits for a failed generation are automatically refunded. 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