{
  "openapi": "3.1.0",
  "info": {
    "title": "Runware API - Media Storage",
    "version": "1.0.0",
    "description": "Manage media in your Runware account."
  },
  "servers": [
    {
      "url": "https://api.runware.ai/v1",
      "description": "Runware REST API"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Runware API Key (e.g., Bearer <your-key>)"
      }
    },
    "schemas": {
      "AuthenticationTask": {
        "title": "Authentication",
        "description": "Authenticates a connection using an API key. Can be sent as the first element of the request array as an alternative to using the Authorization header.",
        "type": "object",
        "x-response-schema": "https://schemas.runware.ai/responses/utilities/authentication.json",
        "properties": {
          "taskType": {
            "$id": "https://schemas.runware.ai/requests/parameters/api/task-type.json",
            "title": "Task Type",
            "description": "Identifier for the type of task being performed",
            "type": "string",
            "const": "authentication"
          },
          "apiKey": {
            "$id": "https://schemas.runware.ai/requests/parameters/authentication/api-key.json",
            "title": "API Key",
            "description": "Your Runware API key.",
            "type": "string"
          },
          "connectionSessionUUID": {
            "$id": "https://schemas.runware.ai/requests/parameters/authentication/connection-session-uuid.json",
            "title": "Connection Session UUID",
            "description": "Optional session UUID to resume a previous connection and receive any buffered results.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "taskType",
          "apiKey"
        ],
        "additionalProperties": false
      },
      "RequestBody": {
        "type": "array",
        "items": {
          "title": "Media Storage",
          "description": "Manage media in your Runware account.",
          "type": "object",
          "properties": {
            "taskType": {
              "title": "Task Type",
              "description": "Identifier for the type of task being performed",
              "type": "string",
              "const": "mediaStorage"
            },
            "taskUUID": {
              "title": "Task UUID",
              "description": "UUID v4 identifier for tracking tasks and matching async responses. Must be unique per task.",
              "type": "string",
              "format": "uuid"
            },
            "operation": {
              "title": "Operation",
              "description": "The media storage operation to perform.",
              "type": "string",
              "oneOf": [
                {
                  "const": "upload",
                  "description": "Store new media and return its UUID and URL."
                },
                {
                  "const": "delete",
                  "description": "Permanently remove previously stored media by its UUID."
                }
              ]
            },
            "media": {
              "title": "Media",
              "description": "For upload, the media as a publicly accessible URL, data URI, or base64 string. For delete, the mediaUUID of the media to remove.",
              "type": "string"
            }
          },
          "required": [
            "taskType",
            "taskUUID",
            "operation",
            "media"
          ],
          "additionalProperties": false
        },
        "description": "You must always POST an array of task objects."
      },
      "ResponseBody": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "title": "Media Storage Response",
              "oneOf": [
                {
                  "title": "Upload Result",
                  "type": "object",
                  "properties": {
                    "taskType": {
                      "title": "Task Type",
                      "description": "Identifier for the type of task this response belongs to.",
                      "type": "string",
                      "const": "mediaStorage"
                    },
                    "taskUUID": {
                      "title": "Task UUID",
                      "description": "UUID v4 identifier echoed from the original request, used to match async responses to their tasks.",
                      "type": "string",
                      "format": "uuid"
                    },
                    "operation": {
                      "title": "Operation",
                      "description": "The media storage operation that produced this response.",
                      "type": "string",
                      "const": "upload"
                    },
                    "mediaUUID": {
                      "title": "Media UUID",
                      "description": "UUID of the stored media.",
                      "type": "string",
                      "format": "uuid"
                    },
                    "mediaURL": {
                      "title": "Media URL",
                      "description": "URL where the stored media is accessible.",
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "taskType",
                    "taskUUID",
                    "operation",
                    "mediaUUID",
                    "mediaURL"
                  ],
                  "additionalProperties": false
                },
                {
                  "title": "Delete Result",
                  "type": "object",
                  "properties": {
                    "taskType": {
                      "title": "Task Type",
                      "description": "Identifier for the type of task this response belongs to.",
                      "type": "string",
                      "const": "mediaStorage"
                    },
                    "taskUUID": {
                      "title": "Task UUID",
                      "description": "UUID v4 identifier echoed from the original request, used to match async responses to their tasks.",
                      "type": "string",
                      "format": "uuid"
                    },
                    "operation": {
                      "title": "Operation",
                      "description": "The media storage operation that produced this response.",
                      "type": "string",
                      "const": "delete"
                    },
                    "mediaUUID": {
                      "title": "Media UUID",
                      "description": "UUID of the stored media.",
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "taskType",
                    "taskUUID",
                    "operation",
                    "mediaUUID"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          }
        }
      },
      "ErrorResponse": {
        "title": "Error Response",
        "description": "Standard error response returned by the Runware API.",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code",
                "message"
              ],
              "additionalProperties": true,
              "properties": {
                "code": {
                  "type": "string",
                  "description": "A short identifier for the error (e.g., invalidApiKey, timeoutProvider)."
                },
                "message": {
                  "type": "string",
                  "description": "A human-readable explanation of what went wrong."
                },
                "parameter": {
                  "type": "string",
                  "description": "The request parameter related to the error, if applicable."
                },
                "taskType": {
                  "type": "string",
                  "description": "The task type of the request that failed."
                },
                "taskUUID": {
                  "type": "string",
                  "description": "The unique identifier of the failed request."
                },
                "documentation": {
                  "type": "string",
                  "description": "A link to relevant documentation."
                }
              }
            }
          }
        },
        "required": [
          "errors"
        ],
        "additionalProperties": false
      }
    }
  },
  "paths": {
    "/": {
      "post": {
        "summary": "Run Media Storage",
        "description": "Manage media in your Runware account.",
        "operationId": "run_media_storage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseBody"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — Missing or invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — No valid API key provided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required — Insufficient account balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — The API key lacks permissions for this request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests — Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error — Something went wrong on Runware's end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable — Temporarily unavailable (maintenance or capacity).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}