{
  "openapi": "3.1.0",
  "info": {
    "title": "Describe (image -> text) API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/mj/submit/describe": {
      "post": {
        "summary": "Describe (image -> text)",
        "operationId": "describe",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "base64",
                  "link"
                ],
                "properties": {
                  "botType": {
                    "type": "string",
                    "description": "Bot type to use. `MID_JOURNEY` for Midjourney (default), `NIJI_JOURNEY` for Niji.",
                    "enum": [
                      "NIJI_JOURNEY",
                      "MID_JOURNEY"
                    ]
                  },
                  "base64": {
                    "type": "string",
                    "description": "Base64-encoded image to describe. Use a data URI such as `data:image/png;base64,xxx`. Provide either `base64` or `link`.",
                    "default": "data:image/png;base64,<your-image-base64>"
                  },
                  "state": {
                    "type": "string",
                    "description": "Custom state string. Returned as-is in the task result and webhook callback for your own tracking."
                  },
                  "link": {
                    "type": "string",
                    "description": "URL of the image to describe. Provide either `link` or `base64`.",
                    "default": "https://your-image-host/source.png"
                  }
                },
                "default": {
                  "base64": "data:image/png;base64,<your-image-base64>",
                  "link": "https://your-image-host/source.png"
                }
              },
              "examples": {
                "Default": {
                  "summary": "Default",
                  "value": {
                    "botType": "MID_JOURNEY",
                    "base64": "data:image/png;base64,xxx"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "description",
                    "properties",
                    "result"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "Submission status code. `1` = submitted successfully (`result` carries the task id). `21` = the action opened a confirmation modal; continue with `/mj/submit/modal` using the returned task id. `4` = parameter error; `description` explains the cause."
                    },
                    "description": {
                      "type": "string"
                    },
                    "properties": {
                      "type": "object",
                      "properties": {}
                    },
                    "result": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/mj/submit/describe \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"botType\": \"MID_JOURNEY\",\n    \"base64\": \"data:image/jpeg;base64,<base64-encoded-jpeg>\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import base64\nimport os\nimport requests\n\nwith open(\"cat.jpg\", \"rb\") as f:\n    image_b64 = base64.b64encode(f.read()).decode()\n\nresponse = requests.post(\n    \"https://api.cometapi.com/mj/submit/describe\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n        \"botType\": \"MID_JOURNEY\",\n        \"base64\": \"data:image/jpeg;base64,\" + image_b64,\n    },\n)\n\ntask = response.json()\nprint(task[\"code\"], task.get(\"result\"))  # poll the task; extracted prompts arrive in promptEn\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "import { readFile } from \"node:fs/promises\";\n\nconst imageB64 = (await readFile(\"cat.jpg\")).toString(\"base64\");\n\nconst response = await fetch(\"https://api.cometapi.com/mj/submit/describe\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n        botType: \"MID_JOURNEY\",\n        base64: `data:image/jpeg;base64,${imageB64}`,\n    }),\n});\n\nconst task = await response.json();\nconsole.log(task.code, task.result); // poll the task; extracted prompts arrive in promptEn\n"
          }
        ],
        "description": ". The extracted prompt suggestions arrive in the task's `promptEn` field when you fetch the finished task."
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
