{
  "openapi": "3.1.0",
  "info": {
    "title": "Ruty API",
    "version": "1.0.0",
    "description": "Image and video generation backed by ReelMind and Yiha. Successful responses preserve the existing code/data/message/timestamp envelope."
  },
  "servers": [
    {
      "url": "https://ruty.ai"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "GenerationRequest": {
        "type": "object",
        "required": [
          "model_id",
          "prompt"
        ],
        "properties": {
          "model_id": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "resolution": {
            "type": "string"
          },
          "aspect_ratio": {
            "type": "string"
          },
          "duration": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              }
            ]
          },
          "num_images": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1
          },
          "image_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "additionalProperties": true,
        "description": "Consult live model default_config for supported parameters and values."
      },
      "Envelope": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer"
          },
          "data": {},
          "message": {
            "type": "string"
          },
          "timestamp": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/v1/catalog": {
      "get": {
        "operationId": "listPublicModels",
        "summary": "Public models and default prices",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "security": []
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "Account-specific model catalog",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        }
      }
    },
    "/v1/prices": {
      "post": {
        "operationId": "calculatePrice",
        "summary": "Calculate generation cost",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "required": [
                  "model_id"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/images": {
      "post": {
        "operationId": "createImage",
        "summary": "Create an image task",
        "responses": {
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          },
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Reuse the same key with an identical payload when retrying the same image request."
          }
        ]
      },
      "get": {
        "operationId": "listImages",
        "summary": "List API-key-scoped image tasks",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ]
      }
    },
    "/v1/images/{task_id}": {
      "get": {
        "operationId": "getImage",
        "summary": "Retrieve an image task",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/images/actions": {
      "post": {
        "operationId": "imageAction",
        "summary": "Run a Midjourney follow-up action",
        "responses": {
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          },
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "required": [
                  "parent_task_id",
                  "action"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/videos": {
      "post": {
        "operationId": "createVideo",
        "summary": "Create a video task",
        "responses": {
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          },
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listVideos",
        "summary": "List API-key-scoped video tasks",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ]
      }
    },
    "/v1/videos/{task_id}": {
      "get": {
        "operationId": "getVideo",
        "summary": "Retrieve a video task",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "default": {
            "description": "Inspect HTTP status and response error details. Do not automatically retry chargeable operations."
          }
        },
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  }
}
