{
  "openapi": "3.1.0",
  "info": {
    "title": "Renoise AI API",
    "version": "1.0.0",
    "description": "Renoise AI is an agent-ready AI video generation platform for e-commerce, marketing, ads, and creator storytelling. API access uses Renoise API keys over the X-API-Key header."
  },
  "servers": [
    {
      "url": "https://renoise.ai/api/public/v1",
      "description": "Production API"
    }
  ],
  "tags": [
    { "name": "Tasks", "description": "Create and inspect AI video or image generation tasks." },
    { "name": "Materials", "description": "Upload and manage reusable brand, product, and character assets." },
    { "name": "Templates", "description": "Browse reusable e-commerce and marketing video templates." },
    { "name": "Credits", "description": "Inspect credit balance and usage." }
  ],
  "paths": {
    "/tasks": {
      "get": {
        "tags": ["Tasks"],
        "operationId": "listTasks",
        "summary": "List generation tasks",
        "security": [{ "apiKeyAuth": [] }],
        "responses": { "200": { "description": "Task list", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TaskListResponse" } } } } }
      },
      "post": {
        "tags": ["Tasks"],
        "operationId": "createTask",
        "summary": "Create an AI video or image generation task",
        "security": [{ "apiKeyAuth": [] }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateTaskRequest" } } } },
        "responses": { "200": { "description": "Created task", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } }, "401": { "$ref": "#/components/responses/Unauthorized" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/tasks/{id}": {
      "get": {
        "tags": ["Tasks"],
        "operationId": "getTask",
        "summary": "Get a task by id",
        "security": [{ "apiKeyAuth": [] }],
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": { "200": { "description": "Task detail", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } }, "404": { "$ref": "#/components/responses/NotFound" } }
      }
    },
    "/tasks/{id}/result": {
      "get": {
        "tags": ["Tasks"],
        "operationId": "getTaskResult",
        "summary": "Get structured task result and downloadable asset URLs",
        "security": [{ "apiKeyAuth": [] }],
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": { "200": { "description": "Task result", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } } }
      }
    },
    "/materials": {
      "get": { "tags": ["Materials"], "operationId": "listMaterials", "summary": "List uploaded materials", "security": [{ "apiKeyAuth": [] }], "responses": { "200": { "description": "Material list" } } },
      "post": { "tags": ["Materials"], "operationId": "createMaterial", "summary": "Create an uploaded material record", "security": [{ "apiKeyAuth": [] }], "responses": { "200": { "description": "Created material" } } }
    },
    "/templates": {
      "get": { "tags": ["Templates"], "operationId": "listTemplates", "summary": "List video templates for ads, product demos, and marketing", "security": [{ "apiKeyAuth": [] }], "responses": { "200": { "description": "Template list" } } }
    },
    "/credit": {
      "get": { "tags": ["Credits"], "operationId": "getCreditBalance", "summary": "Get credit balance", "security": [{ "apiKeyAuth": [] }], "responses": { "200": { "description": "Credit balance" } } }
    }
  },
  "components": {
    "securitySchemes": { "apiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key", "description": "Renoise API key for authenticated API access." } },
    "responses": {
      "Unauthorized": { "description": "API key is missing, invalid, or revoked." },
      "NotFound": { "description": "The requested resource was not found." },
      "RateLimited": { "description": "Rate limit exceeded. Retry after the time indicated by Retry-After." }
    },
    "schemas": {
      "CreateTaskRequest": { "type": "object", "required": ["prompt"], "properties": { "prompt": { "type": "string" }, "type": { "type": "string", "enum": ["video", "image"], "default": "video" }, "model": { "type": "string", "example": "seedance-2.0" }, "materialIds": { "type": "array", "items": { "type": "integer" } } } },
      "Task": { "type": "object", "properties": { "id": { "type": "integer" }, "prompt": { "type": "string" }, "type": { "type": "string" }, "status": { "type": "string", "enum": ["pending", "running", "completed", "failed"] }, "resultUrl": { "type": "string", "format": "uri" }, "createdAt": { "type": "string" } } },
      "TaskListResponse": { "type": "object", "properties": { "tasks": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } } } }
    }
  }
}
