Authentication
API requests require a Bearer token. There are two authentication methods:API Token (Recommended)
Use an API key that starts withmeigen_sk_. Create one from your account settings under API Keys.
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
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 theContent-Type: application/json header.
Response Format
All responses return JSON. Successful responses include asuccess: true field:
error field:
Asynchronous Generation
Image generation is asynchronous. The flow is:- Submit a generation request →
POST /api/generate/v2 - Poll the status endpoint →
GET /api/generate/v2/status/:id - Read the resulting
imageUrl/imageUrls/videoUrldirectly from the status response oncestatus === "completed".
Polling Best Practices
- Recommended interval: 3 seconds between status checks
- Stop when:
statusiscompletedorfailed - While
statusisprocessing, the response includesexpectedWaitSeconds(estimated remaining wait for this model and resolution) andpollHintSeconds(how many more seconds to keep polling —0means 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
statusreaches 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