{
  "openapi": "3.1.0",
  "info": {
    "title": "Image Recognize API",
    "version": "1.0.0",
    "description": "Run Kling image-recognition checks and receive recognition flags synchronously."
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/kling/v1/videos/image-recognize": {
      "post": {
        "summary": "Run Kling image recognition",
        "operationId": "image_recognize",
        "description": "Submit one image and receive recognition flags such as head, face, cloth, or object segmentation presence.",
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": false,
            "description": "Optional content type header.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "description": "Image to analyze. Accepts an image URL or raw Base64 string (no `data:` prefix). Supported formats: JPG, JPEG, PNG. Max 10 MB, minimum 300 px per side, aspect ratio between 1:2.5 and 2.5:1."
                  }
                },
                "default": {
                  "image": "https://your-image-host/portrait.jpg"
                }
              },
              "examples": {
                "Example 1": {
                  "summary": "Example 1",
                  "value": {
                    "image": "https://your-image-host/portrait.jpg"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recognition result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "task_result"
                      ],
                      "properties": {
                        "task_result": {
                          "type": "object",
                          "required": [
                            "images"
                          ],
                          "properties": {
                            "images": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  },
                                  "is_contain": {
                                    "type": "boolean"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "example": {
                    "code": 0,
                    "message": "SUCCEED",
                    "data": {
                      "task_result": {
                        "images": [
                          {
                            "type": "head_seg",
                            "is_contain": true
                          },
                          {
                            "type": "face_seg",
                            "is_contain": true
                          },
                          {
                            "type": "cloth_seg",
                            "is_contain": true
                          },
                          {
                            "type": "object_seg",
                            "is_contain": true
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/kling/v1/videos/image-recognize \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n      \"image\": \"https://your-image-host/portrait.jpg\"\n    }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/kling/v1/videos/image-recognize\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n            \"image\": \"https://your-image-host/portrait.jpg\"\n    },\n)\n\nresult = response.json()\nprint(result[\"code\"], result.get(\"data\", {}).get(\"task_id\"))  # the route responds with the result payload directly\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\"https://api.cometapi.com/kling/v1/videos/image-recognize\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n            \"image\": \"https://your-image-host/portrait.jpg\"\n        }),\n});\n\nconst result = await response.json();\nconsole.log(result.code, result.data?.task_id); // the route responds with the result payload directly\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
