{
  "name": "crAIzy chAIns · Meal Motion (RERUN)",
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "⚙️ Rerun-Konfiguration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "💾 Kühlschrank speichern",
            "type": "main",
            "index": 0
          },
          {
            "node": "Bild → Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "🧩 ComfyUI-Graph (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "⚙️ Rerun-Konfiguration": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bild → Base64": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GenKI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "🧩 ComfyUI-Graph (FLUX DEV)": {
      "main": [
        [
          {
            "node": "ComfyUI FLUX DEV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ComfyUI FLUX DEV": {
      "main": [
        [
          {
            "node": "⏳ warten (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "⏳ warten (FLUX DEV)": {
      "main": [
        [
          {
            "node": "ComfyUI Status (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ComfyUI Status (FLUX DEV)": {
      "main": [
        [
          {
            "node": "🔎 Ergebnis? (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔎 Ergebnis? (FLUX DEV)": {
      "main": [
        [
          {
            "node": "fertig? (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bild laden": {
      "main": [
        [
          {
            "node": "🖼️ Bild ok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🖼️ Bild ok?": {
      "main": [
        [
          {
            "node": "💾 Bild speichern",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fertig? (FLUX DEV)": {
      "main": [
        [
          {
            "node": "Bild laden",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "⏳ warten (FLUX DEV)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧩 ComfyUI-Graph (Wan 2.2 i2v)": {
      "main": [
        [
          {
            "node": "ComfyUI Wan 2.2 i2v",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ComfyUI Wan 2.2 i2v": {
      "main": [
        [
          {
            "node": "⏳ warten (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "⏳ warten (Wan 2.2 i2v)": {
      "main": [
        [
          {
            "node": "ComfyUI Status (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ComfyUI Status (Wan 2.2 i2v)": {
      "main": [
        [
          {
            "node": "🔎 Ergebnis? (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔎 Ergebnis? (Wan 2.2 i2v)": {
      "main": [
        [
          {
            "node": "fertig? (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video laden": {
      "main": [
        [
          {
            "node": "🖼️ Video ok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🖼️ Video ok?": {
      "main": [
        [
          {
            "node": "💾 Video speichern",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fertig? (Wan 2.2 i2v)": {
      "main": [
        [
          {
            "node": "Video laden",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "⏳ warten (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "💾 Bild speichern": {
      "main": [
        [
          {
            "node": "Startbild hochladen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Startbild hochladen": {
      "main": [
        [
          {
            "node": "🧩 ComfyUI-Graph (Wan 2.2 i2v)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "💾 Video speichern": {
      "main": [
        [
          {
            "node": "📋 meta.json bauen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📋 meta.json bauen": {
      "main": [
        [
          {
            "node": "💾 meta speichern",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [],
  "active": false,
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -192,
        160
      ],
      "id": "e2f78bd3-4a84-419b-9184-34b4f62e321f",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "url": "={{ $('⚙️ Rerun-Konfiguration').first().json.kuehlschrank_url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "craizy-chains-rerun/1.0 (https://craizy.studio; hello@craizy.studio)"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        16,
        -16
      ],
      "id": "c11a2e85-455a-422c-915f-39e554eb31bf",
      "name": "HTTP Request",
      "notes": "🔁 RERUN: frei lizenziertes Kühlschrankfoto (Panamitsu, CC BY-SA 4.0) statt Stockfoto.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Du bist ein professioneller Food-Content-Produzent. Erstelle einen englischen Bild-Prompt für das Gericht: {{ $json.choices[0].message.content }}.\n\nAnforderungen:\n1. Antworte NUR mit einem JSON-Objekt im Format: {\"prompt\": \"DEIN_TEXT\"}\n2. Der \"DEIN_TEXT\" muss in einer einzigen Zeile stehen (KEINE Umbrüche).\n3. Verwende im Text KEINE Anführungszeichen (z.B. statt \"4k\" schreibe 4k).\n4. Stil: Cinematic close-up, 4k, steam rising, focus on sizzling textures.\n5. Keine Einleitung, kein Labern, nur das JSON.\n",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        688,
        -16
      ],
      "id": "0e34e1bb-d50a-43f6-99d1-1ead82d5f615",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"prompt\": \"Extreme close-up of sizzling wagyu beef on a cast iron skillet, intense marbling melting, aromatic steam rising in slow motion, cinematic 4k lighting, vibrant textures, shallow depth of field.\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        848,
        128
      ],
      "id": "27e0407e-2c1a-4884-a074-16743390023d",
      "name": "Structured Output Parser",
      "notes": "🔧 Repariert: Schema-Beispiel = Format aus dem Prompt ({\"prompt\": …}).",
      "notesInFlow": true
    },
    {
      "parameters": {
        "content": "Foto Kühlschrank",
        "height": 80,
        "width": 176
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -160
      ],
      "typeVersion": 1,
      "id": "c0e4f507-6585-46f4-9b11-cbf7c93bc37f",
      "name": "Sticky Note1"
    },
    {
      "id": "9dee088a-986a-4c31-b10b-dc6d673f5cbd",
      "name": "Analyze image",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        224,
        -16
      ],
      "notes": "🔁 RERUN: Ollama gemma3 → Vision-Modell über GenKI-Gateway. Prompt = n8n-Standard („What's in this image?“), wie im Original.",
      "notesInFlow": true,
      "parameters": {
        "method": "POST",
        "url": "https://api-genki.udk.digital/v1/chat/completions",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: $('⚙️ Rerun-Konfiguration').first().json.model_vision, max_tokens: 2000, messages: [ { role: 'user', content: [ { type: 'image_url', image_url: { url: 'data:image/jpeg;base64,' + $json.image_b64 } }, { type: 'text', text: `What's in this image?` } ] } ] }) }}",
        "options": {
          "timeout": 300000
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "fbe2a9a3-1219-4931-ad4f-85aeec130dc8",
      "name": "Message a model",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        -16
      ],
      "notes": "🔁 RERUN: Ollama gemma3 → GenKI-Gateway. Prompt unverändert.",
      "notesInFlow": true,
      "parameters": {
        "method": "POST",
        "url": "https://api-genki.udk.digital/v1/chat/completions",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: $('⚙️ Rerun-Konfiguration').first().json.model_small, max_tokens: 2000, messages: [ { role: 'user', content: `Erstelle ein kurzes Rezept aus diesen Zutaten: ${$json.choices[0].message.content}. Gib mir nur den Namen, die Liste und eine kompakte Anleitung. Antworte direkt mit dem Rezept ohne Einleitung.` } ] }) }}",
        "options": {
          "timeout": 300000
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "content": "Hier wird das Kühlschrankbild analysiert ",
        "height": 96,
        "width": 208
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -160
      ],
      "typeVersion": 1,
      "id": "524a34b7-d35f-4958-87b7-c5d13ee67a83",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "Aus den erkannten Produkten im K. Wird hier ein Rezept erstellt ",
        "height": 96,
        "width": 192
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -160
      ],
      "typeVersion": 1,
      "id": "8f0d5450-e679-4a67-928d-1c3d891d1fe3",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "Nun wird aus dem rezept ein Bild Prompt ertsellt ",
        "height": 96,
        "width": 192
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -160
      ],
      "typeVersion": 1,
      "id": "6e8a3d18-e7c2-464a-b75d-e302e15fbcb9",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "Hier wird aus dem Prompt ein Bild von dem Rezept erstellt und dann ensteht aus dem Bild ein Video \n",
        "height": 128,
        "width": 192
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -192
      ],
      "typeVersion": 1,
      "id": "1871cb41-53d7-4572-b6a9-8a1c5c5b2752",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## 🔁 RERUN-FASSUNG (lokal)\nLogik & Prompts wie im Original. Ersetzt: Stockfoto → freies Kühlschrankfoto (Panamitsu, CC BY-SA 4.0), Ollama → GenKI-Gateway, ComfyUI-Community-Nodes → ComfyUI-API der UdK (FLUX DEV, Wan 2.2 i2v), Nextcloud → rerun/_roh/. 🔧 Repariert: Parser-Schema = Prompt-Format; Video-Prompt war noch das ComfyUI-Beispiel.\n\n## 🔗 crAIzy chAIns – Archiv\n\n# Meal Motion\n\n**Team:** Meal Motion\n**Crazy-Level:** 1 – a little loco\n\n> From fridge snapshot to instant food content: Kühlschrankfoto → Zutaten → Rezept → Food-Bild → Food-Video.\n\nEntstanden im Seminar *crAIzy chAIns* (UdK Berlin, WiSe 2025/26). Gebaut als **agentische Rube-Goldberg-Maschine**: nicht effizient, sondern absichtlich verschlungen. Modelle & Prompts sind Stand 2025/26 – **kein Produktiv-Template, sondern ein Spielzeug**.\n\n### Setup-Checkliste\n- **ComfyUI** – Credential „ComfyUI“ → URL deiner ComfyUI-Instanz (Community-Node nötig)\n- **Upload a file** – Credential „Nextcloud“ anlegen und Ordnerpfad anpassen\n- **Ollama Model** – Credential „Ollama“ → Base-URL deines Ollama (z\n- **Analyze image** – Credential „Ollama“ anlegen\n- **ComfyUI Image to Video** – Credential „ComfyUI“ + Image-to-Video-Workflow (z\n\nAlle Stellen sind im Canvas mit **⚙️ SETUP** markiert. Es sind keine Zugangsdaten enthalten.\n\ncraizy.studio",
        "height": 720,
        "width": 680,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1000,
        -232
      ],
      "id": "51580d96-acf1-4978-b5db-e1d845ac2ed3",
      "name": "README crAIzy chAIns"
    },
    {
      "id": "199eb000-665c-4f8b-bdf9-54556f762ef5",
      "name": "⚙️ Rerun-Konfiguration",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -132,
        380
      ],
      "notes": "Hier Modelle, Seed und Ausgabeordner ändern.",
      "notesInFlow": true,
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "14d20903-18ec-4e05-9b6a-174aaa0ce76d",
              "name": "model_main",
              "value": "cc/claude-sonnet-5",
              "type": "string"
            },
            {
              "id": "6b4d4b5c-8482-48cc-b173-94d92c6c7422",
              "name": "model_small",
              "value": "cc/claude-haiku-5-5",
              "type": "string"
            },
            {
              "id": "c87a332d-ec18-40d6-97a1-0a5c7f70899e",
              "name": "model_vision",
              "value": "cc/claude-sonnet-5",
              "type": "string"
            },
            {
              "id": "6ca4d5ef-c689-4883-bd39-aa1387d08042",
              "name": "seed",
              "value": 1881,
              "type": "number"
            },
            {
              "id": "21064535-1452-45a6-afab-a4b6333dc39f",
              "name": "out_dir",
              "value": "/PFAD/ZU/craizy-chains/exponate/05_mealmotion/rerun/_roh",
              "type": "string"
            },
            {
              "id": "0aae36c9-4830-41ba-bc99-5cb6d26f300f",
              "name": "run_id",
              "value": "={{ $now.toFormat('yyyy-MM-dd_HHmm') }}",
              "type": "string"
            },
            {
              "id": "b8294e96-cff1-4aaf-8894-72a06b748a69",
              "name": "kuehlschrank_url",
              "value": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/Fridge_contents.jpg/1280px-Fridge_contents.jpg",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "28d105d7-e89b-485e-80bd-31a504f9c6d8",
      "name": "💾 Kühlschrank speichern",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        16,
        204
      ],
      "parameters": {
        "operation": "write",
        "fileName": "={{ $('⚙️ Rerun-Konfiguration').first().json.out_dir }}/mealmotion_{{ $('⚙️ Rerun-Konfiguration').first().json.run_id }}_kuehlschrank.jpg",
        "dataPropertyName": "data",
        "options": {}
      }
    },
    {
      "id": "afeabb3a-d652-41fa-9581-8e414a86b144",
      "name": "Bild → Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        164,
        184
      ],
      "parameters": {
        "operation": "binaryToPropery",
        "destinationKey": "image_b64",
        "options": {}
      }
    },
    {
      "id": "1b2a8bb9-4663-4b5e-89dc-c9d9198c8dcc",
      "name": "GenKI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        704,
        128
      ],
      "notes": "🔁 RERUN: GenKI-Gateway statt Ollama (gemma3:27b).",
      "notesInFlow": true,
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('⚙️ Rerun-Konfiguration').first().json.model_small }}"
        },
        "options": {
          "maxTokens": 2000,
          "timeout": 300000,
          "maxRetries": 3
        }
      }
    },
    {
      "id": "ce1074b0-4345-47a0-a207-18ed66c1afef",
      "name": "🧩 ComfyUI-Graph (FLUX DEV)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1008,
        -236
      ],
      "parameters": {
        "jsCode": "const c = $('⚙️ Rerun-Konfiguration').first().json;\nconst prompt = (($('Basic LLM Chain').first().json.output.prompt.replace(/\\n/g, ' ')) || '').trim();\nif (prompt.length < 20) throw new Error('Prompt leer – Modell hat nichts geliefert');\nconst neg = '';\nconst image = null;\nconst prefix = 'craizy/' + c.run_id + '_FLUXDEV';\nconst fill = { __PROMPT__: prompt, __NEG__: neg, __SEED__: Number(c.seed), __IMAGE__: image, __PREFIX__: prefix };\nconst graph = JSON.parse(\"{\\\"1\\\": {\\\"class_type\\\": \\\"CheckpointLoaderSimple\\\", \\\"inputs\\\": {\\\"ckpt_name\\\": \\\"flux1-dev-fp8.safetensors\\\"}}, \\\"2\\\": {\\\"class_type\\\": \\\"CLIPTextEncode\\\", \\\"inputs\\\": {\\\"clip\\\": [\\\"1\\\", 1], \\\"text\\\": \\\"__PROMPT__\\\"}}, \\\"3\\\": {\\\"class_type\\\": \\\"FluxGuidance\\\", \\\"inputs\\\": {\\\"conditioning\\\": [\\\"2\\\", 0], \\\"guidance\\\": 2.0}}, \\\"4\\\": {\\\"class_type\\\": \\\"CLIPTextEncode\\\", \\\"inputs\\\": {\\\"clip\\\": [\\\"1\\\", 1], \\\"text\\\": \\\"\\\"}}, \\\"5\\\": {\\\"class_type\\\": \\\"EmptySD3LatentImage\\\", \\\"inputs\\\": {\\\"width\\\": 1344, \\\"height\\\": 768, \\\"batch_size\\\": 1}}, \\\"6\\\": {\\\"class_type\\\": \\\"KSampler\\\", \\\"inputs\\\": {\\\"model\\\": [\\\"1\\\", 0], \\\"positive\\\": [\\\"3\\\", 0], \\\"negative\\\": [\\\"4\\\", 0], \\\"latent_image\\\": [\\\"5\\\", 0], \\\"seed\\\": \\\"__SEED__\\\", \\\"steps\\\": 30, \\\"cfg\\\": 1.0, \\\"sampler_name\\\": \\\"ipndm\\\", \\\"scheduler\\\": \\\"ddim_uniform\\\", \\\"denoise\\\": 1.0}}, \\\"7\\\": {\\\"class_type\\\": \\\"VAEDecode\\\", \\\"inputs\\\": {\\\"samples\\\": [\\\"6\\\", 0], \\\"vae\\\": [\\\"1\\\", 2]}}, \\\"8\\\": {\\\"class_type\\\": \\\"SaveImage\\\", \\\"inputs\\\": {\\\"images\\\": [\\\"7\\\", 0], \\\"filename_prefix\\\": \\\"__PREFIX__\\\"}}}\", (k, v) => (typeof v === 'string' && v in fill) ? fill[v] : v);\nreturn [{ json: { graph, prompt } }];"
      },
      "notes": "🔁 RERUN: Community-Node → ComfyUI-API (UdK), FLUX DEV, Seed aus Konfiguration.",
      "notesInFlow": true
    },
    {
      "id": "5b4d2181-71ce-4336-aa0f-171610945a75",
      "name": "ComfyUI FLUX DEV",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1228,
        -236
      ],
      "parameters": {
        "method": "POST",
        "url": "https://comfyui.studio.udk.digital/prompt",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ prompt: $json.graph, client_id: 'craizy-n8n' }) }}"
      }
    },
    {
      "id": "3dd99699-a5ab-4fc3-8e5e-ed79bfcfac93",
      "name": "⏳ warten (FLUX DEV)",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1448,
        -236
      ],
      "parameters": {
        "amount": 10,
        "unit": "seconds"
      }
    },
    {
      "id": "24440bb7-1718-44f6-86ab-7496b30c137c",
      "name": "ComfyUI Status (FLUX DEV)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1668,
        -236
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://comfyui.studio.udk.digital/history/{{ $('ComfyUI FLUX DEV').first().json.prompt_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000
        }
      }
    },
    {
      "id": "2efd42e2-7a8a-4075-a8c5-d7ce99342a87",
      "name": "🔎 Ergebnis? (FLUX DEV)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1888,
        -236
      ],
      "parameters": {
        "jsCode": "const pid = $('ComfyUI FLUX DEV').first().json.prompt_id;\nconst h = $json[pid];\nif (h && h.status && h.status.status_str === 'error') throw new Error('ComfyUI-Fehler: ' + JSON.stringify(h.status.messages).slice(-600));\nconst outs = h ? Object.values(h.outputs || {}).flatMap(o => [...(o.images || []), ...(o.videos || []), ...(o.gifs || [])]) : [];\nif (!outs.length && $runIndex >= 120) throw new Error('ComfyUI: kein Ergebnis nach 120 Abfragen');\nreturn [{ json: { fertig: outs.length > 0, datei: outs[0] || null } }];"
      }
    },
    {
      "id": "bdbd9eec-b11f-452e-9788-1a819a759c3e",
      "name": "fertig? (FLUX DEV)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2108,
        -236
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "e7e6974e-3d3e-45c4-b831-cd1771b580b2",
              "leftValue": "={{ $json.fertig }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "c1901979-7c12-4289-91b9-eaa972167b68",
      "name": "Bild laden",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2328,
        -336
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://comfyui.studio.udk.digital/view?filename={{ encodeURIComponent($json.datei.filename) }}&subfolder={{ encodeURIComponent($json.datei.subfolder) }}&type={{ $json.datei.type }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000,
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      }
    },
    {
      "id": "de45b631-c58f-40c6-af8a-e94b1a78c5d5",
      "name": "🖼️ Bild ok?",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2548,
        -336
      ],
      "parameters": {
        "jsCode": "const b = $input.first().binary?.data;\nif (!b || !String(b.mimeType).startsWith('image/')) throw new Error('ComfyUI lieferte kein Bild (' + (b && b.mimeType) + ') – Login abgelaufen?');\nreturn $input.all();"
      }
    },
    {
      "id": "786d7fe6-2fce-4c76-b3a5-c848aae98d39",
      "name": "💾 Bild speichern",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        2768,
        -336
      ],
      "parameters": {
        "operation": "write",
        "fileName": "={{ $('⚙️ Rerun-Konfiguration').first().json.out_dir }}/mealmotion_{{ $('⚙️ Rerun-Konfiguration').first().json.run_id }}_essen.png",
        "dataPropertyName": "data",
        "options": {}
      }
    },
    {
      "id": "91aa158e-03ee-4a52-9385-9ed35b23890e",
      "name": "🧩 ComfyUI-Graph (Wan 2.2 i2v)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1420,
        184
      ],
      "parameters": {
        "jsCode": "const c = $('⚙️ Rerun-Konfiguration').first().json;\nconst prompt = (($('Basic LLM Chain').first().json.output.prompt.replace(/\\n/g, ' ')) || '').trim();\nif (prompt.length < 20) throw new Error('Prompt leer – Modell hat nichts geliefert');\nconst neg = \"色调艳丽，过曝，静态，细节模糊不清，字幕，风格，作品，画作，画面，静止，整体发灰，最差质量，低质量，JPEG压缩残留，丑陋的，残缺的，多余的手指，画得不好的手部，画得不好的脸部，畸形的，毁容的，形态畸形的肢体，手指融合，静止不动的画面，杂乱的背景，三条腿，背景人很多，倒着走\";\nconst image = $('Startbild hochladen').first().json.subfolder + '/' + $('Startbild hochladen').first().json.name;\nconst prefix = 'craizy/' + c.run_id + '_Wan22i2v';\nconst fill = { __PROMPT__: prompt, __NEG__: neg, __SEED__: Number(c.seed), __IMAGE__: image, __PREFIX__: prefix };\nconst graph = JSON.parse(\"{\\\"1\\\": {\\\"class_type\\\": \\\"CheckpointLoaderSimple\\\", \\\"inputs\\\": {\\\"ckpt_name\\\": \\\"split_files/diffusion_models/wan22_i2v_high_noise_14B_fp8_scaled.safetensors\\\"}}, \\\"2\\\": {\\\"class_type\\\": \\\"CheckpointLoaderSimple\\\", \\\"inputs\\\": {\\\"ckpt_name\\\": \\\"split_files/diffusion_models/wan22_i2v_low_noise_14B_fp8_scaled.safetensors\\\"}}, \\\"3\\\": {\\\"class_type\\\": \\\"CLIPLoader\\\", \\\"inputs\\\": {\\\"clip_name\\\": \\\"umt5_xxl_fp8_e4m3fn_scaled.safetensors\\\", \\\"type\\\": \\\"wan\\\"}}, \\\"4\\\": {\\\"class_type\\\": \\\"VAELoader\\\", \\\"inputs\\\": {\\\"vae_name\\\": \\\"Wan/wan_2.1_vae.safetensors\\\"}}, \\\"5\\\": {\\\"class_type\\\": \\\"CLIPTextEncode\\\", \\\"inputs\\\": {\\\"clip\\\": [\\\"3\\\", 0], \\\"text\\\": \\\"__PROMPT__\\\"}}, \\\"6\\\": {\\\"class_type\\\": \\\"CLIPTextEncode\\\", \\\"inputs\\\": {\\\"clip\\\": [\\\"3\\\", 0], \\\"text\\\": \\\"__NEG__\\\"}}, \\\"7\\\": {\\\"class_type\\\": \\\"LoadImage\\\", \\\"inputs\\\": {\\\"image\\\": \\\"__IMAGE__\\\"}}, \\\"8\\\": {\\\"class_type\\\": \\\"WanImageToVideo\\\", \\\"inputs\\\": {\\\"positive\\\": [\\\"5\\\", 0], \\\"negative\\\": [\\\"6\\\", 0], \\\"vae\\\": [\\\"4\\\", 0], \\\"width\\\": 1280, \\\"height\\\": 704, \\\"length\\\": 33, \\\"batch_size\\\": 1, \\\"start_image\\\": [\\\"7\\\", 0]}}, \\\"9\\\": {\\\"class_type\\\": \\\"ModelSamplingSD3\\\", \\\"inputs\\\": {\\\"model\\\": [\\\"1\\\", 0], \\\"shift\\\": 8.0}}, \\\"10\\\": {\\\"class_type\\\": \\\"ModelSamplingSD3\\\", \\\"inputs\\\": {\\\"model\\\": [\\\"2\\\", 0], \\\"shift\\\": 8.0}}, \\\"11\\\": {\\\"class_type\\\": \\\"KSamplerAdvanced\\\", \\\"inputs\\\": {\\\"model\\\": [\\\"9\\\", 0], \\\"add_noise\\\": \\\"enable\\\", \\\"noise_seed\\\": \\\"__SEED__\\\", \\\"steps\\\": 20, \\\"cfg\\\": 3.5, \\\"sampler_name\\\": \\\"euler\\\", \\\"scheduler\\\": \\\"simple\\\", \\\"positive\\\": [\\\"8\\\", 0], \\\"negative\\\": [\\\"8\\\", 1], \\\"latent_image\\\": [\\\"8\\\", 2], \\\"start_at_step\\\": 0, \\\"end_at_step\\\": 10, \\\"return_with_leftover_noise\\\": \\\"enable\\\"}}, \\\"12\\\": {\\\"class_type\\\": \\\"KSamplerAdvanced\\\", \\\"inputs\\\": {\\\"model\\\": [\\\"10\\\", 0], \\\"add_noise\\\": \\\"disable\\\", \\\"noise_seed\\\": \\\"__SEED__\\\", \\\"steps\\\": 20, \\\"cfg\\\": 3.5, \\\"sampler_name\\\": \\\"euler\\\", \\\"scheduler\\\": \\\"simple\\\", \\\"positive\\\": [\\\"8\\\", 0], \\\"negative\\\": [\\\"8\\\", 1], \\\"latent_image\\\": [\\\"11\\\", 0], \\\"start_at_step\\\": 10, \\\"end_at_step\\\": 10000, \\\"return_with_leftover_noise\\\": \\\"disable\\\"}}, \\\"13\\\": {\\\"class_type\\\": \\\"VAEDecode\\\", \\\"inputs\\\": {\\\"samples\\\": [\\\"12\\\", 0], \\\"vae\\\": [\\\"4\\\", 0]}}, \\\"14\\\": {\\\"class_type\\\": \\\"CreateVideo\\\", \\\"inputs\\\": {\\\"images\\\": [\\\"13\\\", 0], \\\"fps\\\": 16}}, \\\"15\\\": {\\\"class_type\\\": \\\"SaveVideo\\\", \\\"inputs\\\": {\\\"video\\\": [\\\"14\\\", 0], \\\"filename_prefix\\\": \\\"__PREFIX__\\\", \\\"format\\\": \\\"mp4\\\", \\\"codec\\\": \\\"auto\\\"}}}\", (k, v) => (typeof v === 'string' && v in fill) ? fill[v] : v);\nreturn [{ json: { graph, prompt } }];"
      },
      "notes": "🔁 RERUN: ComfyUI Image-to-Video (Wan 2.1) → Wan 2.2 i2v (UdK-ComfyUI). 🔧 Repariert: Video-Prompt = Food-Prompt statt ComfyUI-Beispiel. ca. 15–20 Min.",
      "notesInFlow": true
    },
    {
      "id": "14e15e13-bf3f-40dc-aee6-de97eab8e005",
      "name": "ComfyUI Wan 2.2 i2v",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1640,
        184
      ],
      "parameters": {
        "method": "POST",
        "url": "https://comfyui.studio.udk.digital/prompt",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ prompt: $json.graph, client_id: 'craizy-n8n' }) }}"
      }
    },
    {
      "id": "21038725-6273-4ff6-9a21-7e1777b4f8b3",
      "name": "⏳ warten (Wan 2.2 i2v)",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1860,
        184
      ],
      "parameters": {
        "amount": 60,
        "unit": "seconds"
      }
    },
    {
      "id": "09c65db5-aba9-4ca0-a4b4-fd456f00fee8",
      "name": "ComfyUI Status (Wan 2.2 i2v)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2080,
        184
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://comfyui.studio.udk.digital/history/{{ $('ComfyUI Wan 2.2 i2v').first().json.prompt_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000
        }
      }
    },
    {
      "id": "42523afc-4b85-44ba-84b1-3681cb48a1e8",
      "name": "🔎 Ergebnis? (Wan 2.2 i2v)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2300,
        184
      ],
      "parameters": {
        "jsCode": "const pid = $('ComfyUI Wan 2.2 i2v').first().json.prompt_id;\nconst h = $json[pid];\nif (h && h.status && h.status.status_str === 'error') throw new Error('ComfyUI-Fehler: ' + JSON.stringify(h.status.messages).slice(-600));\nconst outs = h ? Object.values(h.outputs || {}).flatMap(o => [...(o.images || []), ...(o.videos || []), ...(o.gifs || [])]) : [];\nif (!outs.length && $runIndex >= 90) throw new Error('ComfyUI: kein Ergebnis nach 90 Abfragen');\nreturn [{ json: { fertig: outs.length > 0, datei: outs[0] || null } }];"
      }
    },
    {
      "id": "c872ee14-da61-4518-83e0-8213b4495bd2",
      "name": "fertig? (Wan 2.2 i2v)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2520,
        184
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "12901d43-7965-48a6-aff9-916942f5acf6",
              "leftValue": "={{ $json.fertig }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "4db0210f-709a-4fa2-bfb6-b5c3f7f30eac",
      "name": "Video laden",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2740,
        84
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://comfyui.studio.udk.digital/view?filename={{ encodeURIComponent($json.datei.filename) }}&subfolder={{ encodeURIComponent($json.datei.subfolder) }}&type={{ $json.datei.type }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000,
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      }
    },
    {
      "id": "60ca250b-9e81-4773-952c-a17a1c755ed6",
      "name": "🖼️ Video ok?",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2960,
        84
      ],
      "parameters": {
        "jsCode": "const b = $input.first().binary?.data;\nif (!b || !String(b.mimeType).startsWith('video/')) throw new Error('ComfyUI lieferte kein Video (' + (b && b.mimeType) + ') – Login abgelaufen?');\nreturn $input.all();"
      }
    },
    {
      "id": "6491041d-180a-47a1-9fb3-9c2cba422026",
      "name": "💾 Video speichern",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        3180,
        84
      ],
      "parameters": {
        "operation": "write",
        "fileName": "={{ $('⚙️ Rerun-Konfiguration').first().json.out_dir }}/mealmotion_{{ $('⚙️ Rerun-Konfiguration').first().json.run_id }}_video.mp4",
        "dataPropertyName": "data",
        "options": {}
      }
    },
    {
      "id": "42539f91-d759-4e0d-8654-0b3de62436e0",
      "name": "Startbild hochladen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        184
      ],
      "parameters": {
        "method": "POST",
        "url": "https://comfyui.studio.udk.digital/upload/image",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "timeout": 600000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "image",
              "inputDataFieldName": "data"
            },
            {
              "name": "subfolder",
              "value": "craizy"
            },
            {
              "name": "overwrite",
              "value": "true"
            }
          ]
        }
      },
      "notes": "Bild für LoadImage hochladen. Der Graph nutzt den zurückgegebenen Pfad (subfolder/name).",
      "notesInFlow": true
    },
    {
      "id": "280a8900-3380-47b2-999a-8158b6748b37",
      "name": "📋 meta.json bauen",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3400,
        84
      ],
      "parameters": {
        "jsCode": "const c = $('⚙️ Rerun-Konfiguration').first().json;\nconst txt = (n) => $(n).first().json.choices[0].message.content;\nconst meta = { run_id: c.run_id, kuehlschrank: { url: c.kuehlschrank_url, quelle: 'https://commons.wikimedia.org/wiki/File:Fridge_contents.jpg', credit: 'Panamitsu, CC BY-SA 4.0' },\n  bildanalyse: txt('Analyze image'), rezept: txt('Message a model'),\n  bild_prompt: $('Basic LLM Chain').first().json.output.prompt, seed: c.seed,\n  video: $('🔎 Ergebnis? (Wan 2.2 i2v)').last().json.datei.filename,\n  modelle: { vision: c.model_vision, text: c.model_small, bild: 'flux1-dev-fp8 (ComfyUI)', video: 'wan2.2 i2v 14B (ComfyUI)' } };\nreturn [{ json: {}, binary: { data: await this.helpers.prepareBinaryData(Buffer.from(JSON.stringify(meta, null, 2)), 'meta.json', 'application/json') } }];"
      }
    },
    {
      "id": "9baa9e97-b588-4a6d-8826-f2ddc087c852",
      "name": "💾 meta speichern",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        3620,
        84
      ],
      "parameters": {
        "operation": "write",
        "fileName": "={{ $('⚙️ Rerun-Konfiguration').first().json.out_dir }}/mealmotion_{{ $('⚙️ Rerun-Konfiguration').first().json.run_id }}_meta.json",
        "dataPropertyName": "data",
        "options": {}
      }
    }
  ]
}