Mager API

Create generation task

POST/api/v1/generation-tasks

Submit a generation task with a model slug from GET /api/v1/models. The input object is dynamic per model and must follow that model input_schema. Pass template_id from GET /api/v1/templates to start from a ready-to-use preset.

Authorization

MagerApiKey
x-mager-api-key<token>

Mager API key

In: header

Header Parameters

x-mager-api-key*string

Mager API key

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/v1/generation-tasks" \  -H "x-mager-api-key: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "image-generator",    "model_tier": "max",    "input": {      "prompt": "Studio product photo of a cold matcha latte bottle",      "aspectRatio": "1:1",      "style": "clean commercial lighting"    },    "callback_url": "https://client.example.com/webhooks/mager",    "output_count": 1  }'
{  "status": 201,  "message": "Success",  "data": {    "task_id": "cmagr01hxyz123",    "status": "running",    "model": "image-generator",    "template_id": null,    "callback_url": "https://client.example.com/webhooks/mager",    "created_at": "2026-07-03T06:00:00.000Z",    "updated_at": "2026-07-03T06:00:00.000Z",    "completed_at": null,    "error": null,    "billing": {      "base_moods": 10,      "charged_moods": 15,      "extra_moods_charged": 5    },    "result": [],    "webhooks": [      {        "id": "delivery_01hxyz",        "status": "PENDING",        "attempts": 0,        "max_attempts": 3,        "last_attempt_at": null,        "next_retry_at": null,        "delivered_at": null,        "last_status_code": null,        "last_error": null      }    ]  }}