Usar Image to Image GPT, Google Sheets y Drive para generar y subir imágenes

Avanzado

Este es unContent Creation, Multimodal AIflujo de automatización del dominio deautomatización que contiene 23 nodos.Utiliza principalmente nodos como If, Code, Wait, GoogleDrive, HttpRequest. Usar Image-to-Image GPT, Google Sheets y Drive para generar y subir imágenes

Requisitos previos
  • Credenciales de API de Google Drive
  • Pueden requerirse credenciales de autenticación para la API de destino
  • Credenciales de API de Google Sheets
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752"
  },
  "nodes": [
    {
      "id": "1f995205-641d-4a03-a6d4-aada6bb2cb17",
      "name": "Google Sheets2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -480,
        260
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "36bdf920-27c4-4fb8-9f83-468e8d66a699",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -240,
        260
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2000,
        540
      ],
      "webhookId": "84b8c11a-546a-4874-8265-813d286510f6",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "5f9b58bc-228e-4cf2-ba1d-76fde79e8af8",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -760,
        260
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a46bc160-9ea7-4834-a031-b5b025f5356c",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        20,
        280
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e0b7b7c8-3a7a-466d-bae7-269282b49d34",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Prompt }}",
              "rightValue": ""
            },
            {
              "id": "64dde394-0e49-4306-a24a-de2bf448fc95",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json['drive path'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8a87ab83-d243-41f3-b85f-a0cbbb1edee2",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        560,
        360
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "205d9270-aa0e-4864-bbb6-c67206eda0a2",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d162216f-c4bb-4f6b-a116-15d3cd986b7c",
      "name": "Google Sheets4",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1260,
        560
      ],
      "parameters": {
        "columns": {
          "value": {
            "Base64": "={{ $json.error }}",
            "Prompt": "={{ $json.Prompt }}"
          },
          "schema": [
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drive path",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "drive path",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Generated Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Generated Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Base64",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Base64",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "84fbc87b-3511-4945-97b2-254bd644bed3",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        940,
        260
      ],
      "parameters": {
        "columns": {
          "value": {
            "Base64": "={{ $('HTTP Request1').item.json.image_base64 }}",
            "Prompt": "={{ $('If2').item.json.Prompt }}",
            "Generated Date": "={{$now}}"
          },
          "schema": [
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drive path",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "drive path",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Generated Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Generated Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Base64",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Base64",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7a7b4988-9650-48c5-a9cc-339a9403f090",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        860,
        -100
      ],
      "parameters": {
        "name": "={{ $binary.data.fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4d7b5ebe-2df9-4ac2-9b38-5e709654514d",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        240,
        240
      ],
      "parameters": {
        "url": "https://image-to-image-gpt.p.rapidapi.com/productgpt/index.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.Prompt }}"
            },
            {
              "name": "image",
              "value": "={{ $json['Image url'] }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "image-to-image-gpt.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "abc66cee-05b8-4bb7-976b-55130b761fda",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        540,
        -100
      ],
      "parameters": {
        "jsCode": "const base64String = $input.first().json.image_base64;\nconsole.log(base64String);\n// If it includes a prefix like 'data:image/jpeg;base64,', split it\nconst cleanedBase64 = base64String.includes(\",\")\n  ? base64String.split(\",\")[1]\n  : base64String;\n\nreturn [\n  {\n    binary: {\n      data: {\n        data: Buffer.from(cleanedBase64, 'base64'),\n        mimeType: 'image/jpeg', // or image/png depending on the format\n        fileName: 'output.jpg'\n      }\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d268cfe7-3ca2-4d96-9965-263fb1d8146a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1780,
        -380
      ],
      "parameters": {
        "width": 720,
        "height": 1280,
        "content": "# 🧠 AI Image Generator with Google Sheets & Drive\n\n## 📌 Purpose\nAutomatically generate images from prompts in Google Sheets, upload them to Google Drive, and log the link back to the sheet.\n\n---\n\n## ✅ Key Benefits\n- Zero manual effort to generate/store images\n- Centralized prompt management via Google Sheets\n- Drive integration provides shareable image links\n- Built-in error handling and logging\n\n---\n\n## 🧩 Node Descriptions (One-liners)\n\n**1. Manual Trigger**  \nStarts the flow when you manually execute the workflow.\n\n**2. Google Sheets2**  \nReads rows (prompts) from the connected Google Sheet.\n\n**3. Loop Over Items**  \nIterates over each row from the sheet.\n\n**4. If2**  \nFilters rows: continues only if a prompt exists and no image is yet uploaded.\n\n**5. HTTP Request**  \nSends the prompt to the AI image generation API (e.g., RapidAPI).\n\n**6. Try Catch**  \nHandles any API or logic errors gracefully.\n\n**7. Google Drive**  \nUploads the generated base64 image to Google Drive.\n\n**8. Set**  \nConstructs a public share URL for the uploaded image.\n\n**9. Google Sheets1**  \nUpdates the original sheet row with the Drive image link.\n\n**10. Google Sheets3 (Logger)**  \nWrites success/failure logs to a separate sheet or tab.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "61abe854-c306-488c-b427-bfd51b88cde1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        120
      ],
      "parameters": {
        "height": 280,
        "content": "### 1. **Manual Trigger**\nManually starts the workflow for testing or controlled execution."
      },
      "typeVersion": 1
    },
    {
      "id": "1e81a32e-5e79-4b20-8067-0258d068f874",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        80
      ],
      "parameters": {
        "height": 340,
        "content": "### 2. **Google Sheets2 – Fetch Prompts**\n- Connects to a specific Google Sheet.\n- Reads rows that include prompts.\n- These prompts will be used to generate images."
      },
      "typeVersion": 1
    },
    {
      "id": "880542b2-bf17-48ad-951e-466073fc0008",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        100
      ],
      "parameters": {
        "width": 220,
        "height": 280,
        "content": "### 3. **Loop Over Items**\n- Loops through each row one by one.\n- This ensures each prompt is handled independently.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "27299667-dba0-4ea4-99d3-1ccaac9342bc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        40
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "### 4. **If2 – Filter Valid Rows**\n- Checks two conditions:\n  1. Whether the \"Prompt\" column has text\n  2. Whether the \"drive path\" column is empty (i.e., not processed yet)\n- If both conditions pass, the flow proceeds; otherwise, it skips to the next row.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "23efdf34-796a-41b7-9b32-ef18e0ce408f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        20
      ],
      "parameters": {
        "height": 340,
        "content": "### 5. **HTTP Request – Call Image API**\n- Sends a POST or GET request to the AI image generator API (like RapidAPI or Replicate).\n- Includes the prompt as a parameter.\n- Receives the image in base64 or URL form.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c8555a0b-fd48-4776-bb95-f9148fbaaaa5",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        180
      ],
      "parameters": {
        "height": 300,
        "content": "### 6. **Try Catch – Error Handling**\n- Wraps around the API call and upload step.\n- If image generation or upload fails, the error is caught here and handled without breaking the loop."
      },
      "typeVersion": 1
    },
    {
      "id": "d5c01bf8-aa58-4dd3-a066-96c177e723bf",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -320
      ],
      "parameters": {
        "height": 380,
        "content": "### 7. **Google Drive – Upload Image**\n- Converts base64 image (if needed).\n- Uploads the image to a specified Google Drive folder.\n- Retrieves the public/shared URL of the uploaded image.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1c9adb0e-e7ff-418f-ace3-6064f5ea6ea5",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        -240
      ],
      "parameters": {
        "height": 280,
        "content": "### 8. **Set – Prepare Image Link**\n- Formats the image URL from Drive to make it user-friendly or shareable.\n- Prepares this value to update back into the sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "5f0d6cd1-9c02-4883-9574-1886c7ecaad4",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        80
      ],
      "parameters": {
        "height": 320,
        "content": "### 9. **Google Sheets1 – Update Sheet**\n- Writes the image link into the same row from which the prompt came.\n- Marks the row as \"processed\" by updating the drive path field."
      },
      "typeVersion": 1
    },
    {
      "id": "b1f0dccc-5124-4d89-af0b-8cead135c300",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        360
      ],
      "parameters": {
        "height": 300,
        "content": "### 10. **Google Sheets3 – Log Status**\n- Appends a new row in a separate log sheet or tab.\n- Records status (success/failure), prompt, and time.\n- Useful for tracking flow execution over time."
      },
      "typeVersion": 1
    },
    {
      "id": "30397d7d-206e-4a64-b262-05858e226f1a",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1940,
        380
      ],
      "parameters": {
        "height": 320,
        "content": "This node is used to insert a delay before proceeding to the next step in the workflow. In your case, the node waits for `10 seconds`."
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "8a87ab83-d243-41f3-b85f-a0cbbb1edee2": {
      "main": [
        [
          {
            "node": "d162216f-c4bb-4f6b-a116-15d3cd986b7c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a46bc160-9ea7-4834-a031-b5b025f5356c": {
      "main": [
        [
          {
            "node": "4d7b5ebe-2df9-4ac2-9b38-5e709654514d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "36bdf920-27c4-4fb8-9f83-468e8d66a699",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c": {
      "main": [
        [
          {
            "node": "36bdf920-27c4-4fb8-9f83-468e8d66a699",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "abc66cee-05b8-4bb7-976b-55130b761fda": {
      "main": [
        [
          {
            "node": "7a7b4988-9650-48c5-a9cc-339a9403f090",
            "type": "main",
            "index": 0
          },
          {
            "node": "84fbc87b-3511-4945-97b2-254bd644bed3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7a7b4988-9650-48c5-a9cc-339a9403f090": {
      "main": [
        [
          {
            "node": "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4d7b5ebe-2df9-4ac2-9b38-5e709654514d": {
      "main": [
        [
          {
            "node": "abc66cee-05b8-4bb7-976b-55130b761fda",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8a87ab83-d243-41f3-b85f-a0cbbb1edee2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "84fbc87b-3511-4945-97b2-254bd644bed3": {
      "main": [
        [
          {
            "node": "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1f995205-641d-4a03-a6d4-aada6bb2cb17": {
      "main": [
        [
          {
            "node": "36bdf920-27c4-4fb8-9f83-468e8d66a699",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d162216f-c4bb-4f6b-a116-15d3cd986b7c": {
      "main": [
        [
          {
            "node": "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "36bdf920-27c4-4fb8-9f83-468e8d66a699": {
      "main": [
        [],
        [
          {
            "node": "a46bc160-9ea7-4834-a031-b5b025f5356c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5f9b58bc-228e-4cf2-ba1d-76fde79e8af8": {
      "main": [
        [
          {
            "node": "1f995205-641d-4a03-a6d4-aada6bb2cb17",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Creación de contenido, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos23
Categoría2
Tipos de nodos9
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34