{
  "openapi": "3.1.0",
  "info": {
    "title": "MiniMax Conch Query API",
    "version": "1.0.0",
    "description": "Query a MiniMax video task created through CometAPI and inspect the nested provider payload for file metadata."
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  },
  "paths": {
    "/v1/query/video_generation": {
      "get": {
        "summary": "Query a MiniMax video task",
        "operationId": "minimax_conch_query",
        "description": "Use the task id returned by POST /v1/video_generation. The outer response reports CometAPI task state and the nested data block mirrors the MiniMax provider payload.",
        "parameters": [
          {
            "name": "task_id",
            "in": "query",
            "required": true,
            "description": "Task id returned by the create endpoint.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current task state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "task_id",
                        "action",
                        "status",
                        "progress",
                        "data"
                      ],
                      "properties": {
                        "task_id": {
                          "type": "string"
                        },
                        "action": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "fail_reason": {
                          "type": "string"
                        },
                        "result_url": {
                          "type": "string",
                          "description": "Video download URL available once the task succeeds."
                        },
                        "submit_time": {
                          "type": "integer"
                        },
                        "start_time": {
                          "type": "integer"
                        },
                        "finish_time": {
                          "type": "integer"
                        },
                        "progress": {
                          "type": "string"
                        },
                        "data": {
                          "type": "object",
                          "required": [
                            "file",
                            "task_id",
                            "base_resp"
                          ],
                          "properties": {
                            "file": {
                              "type": "object",
                              "properties": {
                                "bytes": {
                                  "type": "integer"
                                },
                                "file_id": {
                                  "type": "integer"
                                },
                                "purpose": {
                                  "type": "string"
                                },
                                "filename": {
                                  "type": "string"
                                },
                                "created_at": {
                                  "type": "integer"
                                },
                                "download_url": {
                                  "type": "string"
                                }
                              }
                            },
                            "task_id": {
                              "type": "string"
                            },
                            "base_resp": {
                              "type": "object",
                              "properties": {
                                "status_msg": {
                                  "type": "string"
                                },
                                "status_code": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "status": {
                      "type": "string",
                      "description": "Task state: `Queueing`, `Processing`, `Success`, or `Fail`."
                    },
                    "file_id": {
                      "type": "string",
                      "description": "Generated file id when `status` is `Success`. Pass it with `task_id` to `GET /v1/files/retrieve`."
                    },
                    "task_id": {
                      "type": "string",
                      "description": "Task id being queried."
                    },
                    "video_width": {
                      "type": "integer",
                      "description": "Output video width in pixels, populated on success."
                    },
                    "video_height": {
                      "type": "integer",
                      "description": "Output video height in pixels, populated on success."
                    }
                  },
                  "example": {
                    "code": "success",
                    "message": "",
                    "data": {
                      "task_id": "375782873624999",
                      "action": "VIDEO_GENERATION",
                      "status": "NOT_START",
                      "fail_reason": "",
                      "submit_time": 1773297213,
                      "start_time": 0,
                      "finish_time": 0,
                      "progress": "0%",
                      "data": {
                        "file": {
                          "bytes": 0,
                          "file_id": 0,
                          "purpose": "",
                          "filename": "",
                          "created_at": 0,
                          "download_url": ""
                        },
                        "task_id": "375782873624999",
                        "base_resp": {
                          "status_msg": "success",
                          "status_code": 0
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Processing": {
                    "summary": "Task still rendering",
                    "value": {
                      "status": "Processing",
                      "file_id": "",
                      "task_id": "<task_id>",
                      "base_resp": {
                        "status_msg": "success",
                        "status_code": 0
                      },
                      "video_width": 0,
                      "video_height": 0
                    }
                  },
                  "Success": {
                    "summary": "Finished task; pass file_id and task_id to the download endpoint",
                    "value": {
                      "status": "Success",
                      "file_id": "<file_id>",
                      "task_id": "<task_id>",
                      "base_resp": {
                        "status_msg": "success",
                        "status_code": 0
                      },
                      "video_width": 1366,
                      "video_height": 768
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "TASK_ID=\"<task_id>\"\n\ncurl \"https://api.cometapi.com/v1/query/video_generation?task_id=$TASK_ID\" \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\"\n"
          },
          {
            "lang": "Shell",
            "label": "Poll until done",
            "source": "TASK_ID=\"<task_id>\"\n\nwhile true; do\n  STATUS=$(curl -s \"https://api.cometapi.com/v1/query/video_generation?task_id=$TASK_ID\" \\\n    -H \"Authorization: Bearer $COMETAPI_KEY\" | python3 -c \"import json,sys; print(json.load(sys.stdin)['status'])\")\n  echo \"status: $STATUS\"\n  case \"$STATUS\" in Success | Fail) break;; esac\n  sleep 20\ndone\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\ntask_id = \"<task_id>\"\n\nresponse = requests.get(\n    f\"https://api.cometapi.com/v1/query/video_generation?task_id={task_id}\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n)\n\nprint(response.json())\n"
          },
          {
            "lang": "Python",
            "label": "Poll until done",
            "source": "import os\nimport time\nimport requests\n\ntask_id = \"<task_id>\"\nheaders = {\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]}\n\nwhile True:\n    task = requests.get(\n        \"https://api.cometapi.com/v1/query/video_generation\",\n        params={\"task_id\": task_id},\n        headers=headers,\n    ).json()\n    print(task[\"status\"])\n    if task[\"status\"] in (\"Success\", \"Fail\"):\n        break\n    time.sleep(20)\n\nif task[\"status\"] == \"Success\":\n    print(task[\"file_id\"])  # download via GET /v1/files/retrieve\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const taskId = \"<task_id>\";\n\nconst response = await fetch(`https://api.cometapi.com/v1/query/video_generation?task_id=${taskId}`, {\n    headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },\n});\n\nconsole.log(await response.json());\n"
          },
          {
            "lang": "JavaScript",
            "label": "Poll until done",
            "source": "const taskId = \"<task_id>\";\nconst headers = { Authorization: `Bearer ${process.env.COMETAPI_KEY}` };\n\nlet task;\nwhile (true) {\n    task = await (await fetch(\n        `https://api.cometapi.com/v1/query/video_generation?task_id=${taskId}`, { headers }\n    )).json();\n    console.log(task.status);\n    if (task.status === \"Success\" || task.status === \"Fail\") break;\n    await new Promise((resolve) => setTimeout(resolve, 20000));\n}\n\nif (task.status === \"Success\") console.log(task.file_id);\n"
          }
        ]
      }
    }
  }
}