{
  "name": "Image to Motion Video (Kie.ai)",
  "nodes": [
    {
      "parameters": {},
      "id": "Manual Trigger",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "filePath": "/home/user/input/image.jpg"
      },
      "id": "Read Image",
      "name": "Read Image",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        400,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://api.cloudinary.com/v1_1/YOUR_CLOUD_NAME/image/upload",
        "method": "POST",
        "sendBinaryData": true,
        "binaryPropertyName": "data",
        "options": {
          "bodyContentType": "multipart-form-data"
        },
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "upload_preset",
              "value": "YOUR_UPLOAD_PRESET"
            }
          ]
        }
      },
      "id": "Upload Image",
      "name": "Upload Image",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        600,
        200
      ]
    },
    {
      "parameters": {
        "filePath": "/home/user/input/reference.mp4"
      },
      "id": "Read Video",
      "name": "Read Video",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        400,
        400
      ]
    },
    {
      "parameters": {
        "url": "https://api.cloudinary.com/v1_1/YOUR_CLOUD_NAME/video/upload",
        "method": "POST",
        "sendBinaryData": true,
        "binaryPropertyName": "data",
        "options": {
          "bodyContentType": "multipart-form-data"
        },
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "upload_preset",
              "value": "YOUR_UPLOAD_PRESET"
            }
          ]
        }
      },
      "id": "Upload Video",
      "name": "Upload Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        600,
        400
      ]
    },
    {
      "parameters": {
        "url": "https://api.kie.ai/v1/video/motion",
        "method": "POST",
        "jsonParameters": true,
        "options": {},
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KIE_API_KEY"
            }
          ]
        },
        "bodyParametersJson": "={\n  \"source_image\": $node[\"Upload Image\"].json[\"secure_url\"],\n  \"driving_video\": $node[\"Upload Video\"].json[\"secure_url\"],\n  \"motion_strength\": 0.75,\n  \"lip_sync\": true,\n  \"expression_transfer\": true,\n  \"face_enhance\": true\n}"
      },
      "id": "Call Kie",
      "name": "Call Kie Motion",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "waitTime": 45
      },
      "id": "Wait",
      "name": "Wait 45 Seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1100,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://api.kie.ai/v1/video/status/{{$json[\"job_id\"]}}",
        "method": "GET",
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KIE_API_KEY"
            }
          ]
        }
      },
      "id": "Check Status",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1300,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"status\"]}}",
              "operation": "equal",
              "value2": "completed"
            }
          ]
        }
      },
      "id": "If Complete",
      "name": "If Completed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1500,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{$json[\"result_video_url\"]}}",
        "method": "GET",
        "responseFormat": "file"
      },
      "id": "Download Result",
      "name": "Download Result",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1700,
        200
      ]
    },
    {
      "parameters": {
        "filePath": "/home/user/output/final_video.mp4"
      },
      "id": "Save File",
      "name": "Save Final Video",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [
        1900,
        200
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Read Image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Read Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Image": {
      "main": [
        [
          {
            "node": "Upload Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Video": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image": {
      "main": [
        [
          {
            "node": "Call Kie Motion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        [
          {
            "node": "Call Kie Motion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Kie Motion": {
      "main": [
        [
          {
            "node": "Wait 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 45 Seconds": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "If Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Completed?": {
      "main": [
        [
          {
            "node": "Download Result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Result": {
      "main": [
        [
          {
            "node": "Save Final Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}