{
  "openapi": "3.1.0",
  "info": {
    "title": "MakeInfluencer REST API",
    "version": "1.0.0",
    "description": "Generate AI influencer images, edits, video, motion control, and lip-sync output using the same MakeInfluencer credits as the dashboard.",
    "contact": {
      "name": "MakeInfluencer",
      "email": "hello@makeinfluencer.ai"
    }
  },
  "externalDocs": {
    "description": "MakeInfluencer API documentation",
    "url": "https://www.makeinfluencer.ai/developers"
  },
  "servers": [
    {
      "url": "https://www.makeinfluencer.ai/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "Training"
    },
    {
      "name": "Models"
    },
    {
      "name": "Generations"
    },
    {
      "name": "Assets"
    }
  ],
  "paths": {
    "/account": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Account"
        ],
        "summary": "Get account and credits",
        "description": "Returns the account attached to the key and its live MakeInfluencer credit balance.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Get account and credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/influencers": {
      "get": {
        "operationId": "listInfluencers",
        "tags": [
          "Account"
        ],
        "summary": "List AI influencers",
        "description": "Returns the account's reusable AI influencers and whether each one is trained and ready for influencerId image generation.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "List AI influencers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/training/jobs": {
      "post": {
        "operationId": "createTrainingJob",
        "tags": [
          "Training"
        ],
        "summary": "Train an AI influencer",
        "description": "Creates a private influencer, charges the server-defined training cost once, and queues character-sheet preparation and LoRA training. Idempotency-Key is required.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A unique key for safely replaying the same logical generation request.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrainingJobRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Training queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrainingJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/training/jobs/{trainingId}": {
      "get": {
        "operationId": "getTrainingJob",
        "tags": [
          "Training"
        ],
        "summary": "Get training status",
        "description": "Returns an owned training job. Successful jobs include the reusable influencerId and trained LoRA URL.",
        "parameters": [
          {
            "name": "trainingId",
            "in": "path",
            "required": true,
            "description": "The training ID returned by POST /training/jobs.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get training status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrainingJob"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/models": {
      "get": {
        "operationId": "listModels",
        "tags": [
          "Models"
        ],
        "summary": "List models",
        "description": "Returns every available image, editing, video, motion-control, and lip-sync model with its exact fields, defaults, limits, options, and capabilities.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "List models",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/models/{modelId}": {
      "get": {
        "operationId": "getModel",
        "tags": [
          "Models"
        ],
        "summary": "Get one model",
        "description": "Returns one model contract. This is the safest way to build dynamic forms or validate a workflow before generating.",
        "parameters": [
          {
            "name": "modelId",
            "in": "path",
            "required": true,
            "description": "An id returned by GET /models.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get one model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/models/{modelId}/preview-credits": {
      "post": {
        "operationId": "previewCredits",
        "tags": [
          "Models"
        ],
        "summary": "Preview credits",
        "description": "Validates the model input and returns its exact credit quote without reserving or spending credits.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preview credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditPreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/models/{modelId}/generations": {
      "post": {
        "operationId": "createGeneration",
        "tags": [
          "Generations"
        ],
        "summary": "Create an image or video",
        "description": "Queues a generation and returns HTTP 202 with one or more ids plus the charged credit cost. Pass an Idempotency-Key when requests may be retried.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A unique key for safely replaying the same logical generation request.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Generation queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueuedGeneration"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/generations/video/{generationId}": {
      "get": {
        "operationId": "getVideoGeneration",
        "tags": [
          "Generations"
        ],
        "summary": "Poll a video",
        "description": "Returns an owned video's status. Stop polling when terminal is true. On success, ready is true and url contains the output unless it was safety-blocked.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Poll a video",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerationStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/generations/image/{generationId}": {
      "get": {
        "operationId": "getImageGeneration",
        "tags": [
          "Generations"
        ],
        "summary": "Poll an image",
        "description": "Returns an owned image generation. Stop polling when terminal is true. On success, ready is true and urls contains the generated outputs.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Poll an image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerationStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/generations": {
      "get": {
        "operationId": "listGenerations",
        "tags": [
          "Generations"
        ],
        "summary": "List generation history",
        "description": "Returns the authenticated account's recent image or video generations, newest first, with their current status and output URLs.",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": true,
            "description": "The generation history to list.",
            "schema": {
              "type": "string",
              "enum": [
                "image",
                "video"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–50 recent generations.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List generation history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerationHistory"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/assets/presign": {
      "post": {
        "operationId": "presignAsset",
        "tags": [
          "Assets"
        ],
        "summary": "Create an upload URL",
        "description": "Returns a two-minute presigned PUT URL for an image, video, or audio file up to 8 MB. Upload the bytes with the returned Content-Type header, then use assetUrl in generation requests.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssetUploadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Create an upload URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssetUpload"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mi_ API key"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "API key is missing, invalid, or revoked.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationError": {
        "description": "The request or model input is invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InsufficientCredits": {
        "description": "The shared MakeInfluencer credit balance is too low.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The model or owned generation was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "IdempotencyConflict": {
        "description": "The idempotency key was used with a different payload.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The account rate limit was exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      },
      "Account": {
        "type": "object",
        "required": [
          "plan",
          "subscribed",
          "credits",
          "purchaseUrl"
        ],
        "properties": {
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "plan": {
            "type": "string"
          },
          "subscribed": {
            "type": "boolean"
          },
          "credits": {
            "type": "number"
          },
          "purchaseUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Field": {
        "type": "object",
        "required": [
          "name",
          "type",
          "required"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "helpText": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "default": {},
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "maxItems": {
            "type": "integer"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Model": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "label",
          "vendor",
          "description",
          "fields"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "label": {
            "type": "string"
          },
          "vendor": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "inferenceTime": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "useCases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "capabilities": {
            "type": "object"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Field"
            }
          }
        }
      },
      "ModelsResponse": {
        "type": "object",
        "required": [
          "models"
        ],
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        }
      },
      "ModelResponse": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "$ref": "#/components/schemas/Model"
          }
        }
      },
      "GenerationRequest": {
        "type": "object",
        "required": [
          "input"
        ],
        "additionalProperties": false,
        "properties": {
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "copies": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1
          },
          "influencerId": {
            "type": "string",
            "format": "uuid"
          },
          "generationId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "CreditPreview": {
        "type": "object",
        "required": [
          "modelId",
          "credits"
        ],
        "properties": {
          "modelId": {
            "type": "string"
          },
          "credits": {
            "type": "object",
            "required": [
              "cost",
              "description"
            ],
            "properties": {
              "cost": {
                "type": "number"
              },
              "description": {
                "type": "string"
              }
            }
          }
        }
      },
      "QueuedGeneration": {
        "type": "object",
        "required": [
          "status",
          "kind",
          "modelId",
          "ids",
          "creditsCost"
        ],
        "properties": {
          "status": {
            "type": "string",
            "const": "queued"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "modelId": {
            "type": "string"
          },
          "ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "taskId": {
            "type": "string"
          },
          "creditsCost": {
            "type": "number"
          }
        }
      },
      "GenerationStatus": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "status",
          "ready",
          "terminal",
          "refunded"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "modelId": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "ready": {
            "type": "boolean"
          },
          "terminal": {
            "type": "boolean"
          },
          "refunded": {
            "type": "boolean"
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "creditsCost": {
            "type": [
              "number",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "GenerationHistory": {
        "type": "object",
        "required": [
          "kind",
          "generations"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "generations": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "AssetUploadRequest": {
        "type": "object",
        "required": [
          "mimeType",
          "sizeBytes"
        ],
        "additionalProperties": false,
        "properties": {
          "mimeType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 8388608
          }
        }
      },
      "TrainingJobRequest": {
        "type": "object",
        "required": [
          "name",
          "style",
          "gender",
          "assetUrls",
          "consentAcknowledged"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "username": {
            "type": "string",
            "minLength": 3,
            "maxLength": 30,
            "pattern": "^[a-zA-Z0-9_]+$"
          },
          "style": {
            "type": "string",
            "enum": [
              "realistic",
              "anime"
            ]
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female"
            ]
          },
          "assetUrls": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "consentAcknowledged": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "TrainingJob": {
        "type": "object",
        "required": [
          "trainingId",
          "influencerId",
          "status",
          "ready",
          "terminal",
          "refunded",
          "creditsCost",
          "loraUrl"
        ],
        "properties": {
          "trainingId": {
            "type": "string",
            "format": "uuid"
          },
          "influencerId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "ready": {
            "type": "boolean"
          },
          "terminal": {
            "type": "boolean"
          },
          "refunded": {
            "type": "boolean"
          },
          "creditsCost": {
            "type": "number"
          },
          "loraUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          }
        }
      },
      "AssetUpload": {
        "type": "object",
        "required": [
          "uploadUrl",
          "assetUrl",
          "expiresInSeconds",
          "method",
          "headers",
          "browserUploadUrl"
        ],
        "properties": {
          "uploadUrl": {
            "type": "string",
            "format": "uri"
          },
          "assetUrl": {
            "type": "string",
            "format": "uri"
          },
          "expiresInSeconds": {
            "type": "integer"
          },
          "method": {
            "type": "string",
            "const": "PUT"
          },
          "headers": {
            "type": "object"
          },
          "browserUploadUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  }
}