{
  "openapi": "3.1.0",
  "info": {
    "title": "Blend (image -> image) API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/mj/submit/blend": {
      "post": {
        "summary": "Blend (image -> image)",
        "operationId": "blend",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "base64Array"
                ],
                "properties": {
                  "base64Array": {
                    "type": "array",
                    "description": "Two or more base64-encoded images to blend. Each item should be a data URI such as `data:image/png;base64,xxx`.",
                    "items": {
                      "type": "string"
                    },
                    "default": [
                      "data:image/png;base64,<your-image-base64>"
                    ]
                  },
                  "dimensions": {
                    "type": "string",
                    "description": "Output aspect ratio.",
                    "enum": [
                      "PORTRAIT",
                      "SQUARE",
                      "LANDSCAPE"
                    ]
                  },
                  "notifyHook": {
                    "type": "string",
                    "description": "Webhook URL to receive task status updates. Falls back to your account-level webhook if omitted."
                  },
                  "state": {
                    "type": "string",
                    "description": "Custom state string. Returned as-is in the task result and webhook callback for your own tracking."
                  },
                  "botType": {
                    "type": "string",
                    "description": "Bot type to use. `MID_JOURNEY` for Midjourney (default), `NIJI_JOURNEY` for Niji.",
                    "enum": [
                      "MID_JOURNEY",
                      "NIJI_JOURNEY"
                    ]
                  }
                },
                "default": {
                  "base64Array": [
                    "data:image/png;base64,<your-image-base64>"
                  ]
                }
              },
              "examples": {
                "Default": {
                  "summary": "Default",
                  "value": {
                    "botType": "MID_JOURNEY",
                    "base64Array": [
                      "data:image/png;base64,xxx1",
                      "data:image/png;base64,xxx2"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "description",
                    "properties",
                    "result"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "Status code"
                    },
                    "description": {
                      "type": "string",
                      "description": "Human-readable description message corresponding to the status code"
                    },
                    "properties": {
                      "type": "object",
                      "description": "Additional properties or metadata",
                      "properties": {}
                    },
                    "result": {
                      "type": "integer",
                      "description": "Returned task ID"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/mj/submit/blend \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"botType\": \"MID_JOURNEY\",\n    \"base64Array\": [\n      \"data:image/jpeg;base64,<base64-encoded-first-image>\",\n      \"data:image/jpeg;base64,<base64-encoded-second-image>\"\n    ],\n    \"dimensions\": \"SQUARE\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import base64\nimport os\nimport requests\n\ndef to_data_uri(path):\n    with open(path, \"rb\") as f:\n        return \"data:image/jpeg;base64,\" + base64.b64encode(f.read()).decode()\n\nresponse = requests.post(\n    \"https://api.cometapi.com/mj/submit/blend\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n        \"botType\": \"MID_JOURNEY\",\n        \"base64Array\": [to_data_uri(\"first.jpg\"), to_data_uri(\"second.jpg\")],\n        \"dimensions\": \"SQUARE\",\n    },\n)\n\ntask = response.json()\nprint(task[\"code\"], task.get(\"result\"))\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "import { readFile } from \"node:fs/promises\";\n\nasync function toDataUri(path) {\n    return `data:image/jpeg;base64,${(await readFile(path)).toString(\"base64\")}`;\n}\n\nconst response = await fetch(\"https://api.cometapi.com/mj/submit/blend\", {\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        base64Array: [await toDataUri(\"first.jpg\"), await toDataUri(\"second.jpg\")],\n        dimensions: \"SQUARE\",\n    }),\n});\n\nconst task = await response.json();\nconsole.log(task.code, task.result);\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
