AutomationFlowsAI & RAG › AI Background Generation with Nano Banana

AI Background Generation with Nano Banana

Original n8n title: AI Background Generation with Nano Banana (gemini Image)

AI Background Generation with Nano Banana (Gemini Image). Uses httpRequest, googleDrive. Webhook trigger; 35 nodes.

Webhook trigger★★★★★ complexity35 nodesHTTP RequestGoogle Drive
AI & RAG Trigger: Webhook Nodes: 35 Complexity: ★★★★★ Added:

This workflow follows the Google Drive → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "AI Background Generation with Nano Banana (Gemini Image)",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83c\udfa8 AI Background Generation\n\n**What it does:**\n- Generates custom background image from text prompt\n- Uses Gemini's Nano Banana (native image generation)\n- Removes foreground video background\n- Composites video on AI-generated background\n- Saves final result to Google Drive\n\n**Perfect for:**\n- Creating custom scenes from imagination\n- Marketing videos with branded environments\n- Product demos with tailored backgrounds\n- Social media content with unique visuals\n- AI avatars in AI-generated worlds\n\n**Processing time:** 2-4 minutes per video\n- Image generation: ~10-20 seconds\n- Background removal: ~20-60 seconds\n- Composition: ~30-60 seconds\n\n**Setup:** ~5 minutes (2 API keys)\n\n[\ud83d\udcd6 Full Documentation](https://docs.videobgremover.com/)",
        "height": 580,
        "width": 520
      },
      "id": "c7388890-0c23-4122-bd5d-252650bc1bcc",
      "name": "\ud83d\udccb Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3360,
        -144
      ],
      "notesTextSize": "large",
      "notesBackgroundColor": 4
    },
    {
      "parameters": {
        "content": "## \ud83d\udd11 API Keys Setup (Required)\n\n**Step 1: Gemini API Key**\n- Visit: https://aistudio.google.com/apikey\n- Create new API key\n- Add to n8n: Settings \u2192 Variables\n  - Name: `GEMINI_KEY`\n  - Value: your Gemini API key\n\n**Step 2: VideoBGRemover API Key**\n- Visit: https://videobgremover.com/api-management\n- Sign up (free tier available)\n- Copy your API key\n- Add to n8n: Settings \u2192 Variables\n  - Name: `VIDEOBGREMOVER_KEY`\n  - Value: your API key\n\n\u2705 This workflow uses `$vars.GEMINI_KEY` and `$vars.VIDEOBGREMOVER_KEY` (secure)\n\n**Pricing:**\n- Gemini: $0.03 per image (~1024x1024)\n- VideoBGRemover: $0.50-$2.00 per min",
        "height": 380,
        "width": 380
      },
      "id": "4cea6533-3c98-4416-9590-55d59fa384c1",
      "name": "\ud83d\udd11 API Key Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2784,
        -160
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udce5 Input Required\n\n**video_url** (required)\n- URL to your foreground video\n- AI actors, product demos, talking heads\n- Any resolution up to 4K\n- Must be publicly accessible\n\n**background_prompt** (required)\n- Text description of desired background\n- Be descriptive and specific\n- Example: \"A modern minimalist office with floor-to-ceiling windows overlooking a city skyline at sunset\"\n\n**aspect_ratio** (optional)\n- Default: \"1:1\" (square)\n- Landscape: \"16:9\", \"4:3\"\n- Portrait: \"9:16\", \"3:4\"\n- Full list: https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios\n\n\u26a0\ufe0f Video must be **publicly accessible URL**",
        "height": 320,
        "width": 380
      },
      "id": "e78fbba9-30f1-4195-b186-7b0e1089592f",
      "name": "\ud83d\udce5 Inputs",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2240,
        -144
      ]
    },
    {
      "parameters": {
        "content": "## \ud83c\udfa8 Nano Banana (Gemini Image)\n\n**How it works:**\n- Uses Gemini 2.5 Flash with native image generation\n- Generates high-quality backgrounds from text\n- Supports detailed, photorealistic prompts\n- Built-in SynthID watermarking\n\n**Prompt tips:**\n- Be descriptive and specific\n- Mention lighting, colors, mood\n- Use photography terms for realism\n- Describe the scene, not just keywords\n\n**Examples:**\n- \"A cozy coffee shop interior with warm lighting and vintage decor\"\n- \"Modern tech office with glass walls and city views\"\n- \"Tropical beach at golden hour with palm trees\"\n\n**Output:** Base64-encoded PNG image\n**Latency:** ~10-20 seconds per image",
        "height": 380,
        "width": 380
      },
      "id": "0c554823-6fe3-4ab1-8ff8-ae6ea3d6e369",
      "name": "\ud83c\udfa8 Nano Banana",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1680,
        -144
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udd04 Processing Flow\n\n**1. Generate Background** (~10-20s)\n- Gemini creates image from prompt\n- Returns base64-encoded PNG\n- Supports multiple aspect ratios\n\n**2. Background Removal** (~20-60s)\n- VideoBGRemover processes video\n- AI-powered segmentation\n- Clean edge detection\n\n**3. Composition** (~30-60s)\n- Composite video on AI background\n- Centered template (maintain aspect)\n- Professional framing\n\n**4. Upload to Drive**\n- Automatic save with shareable link\n- Permanent storage\n\n\u23f1\ufe0f Total: 2-4 min per video",
        "height": 320,
        "width": 380
      },
      "id": "c644eeb5-59d2-4423-8ae4-78843e8c17b6",
      "name": "\ud83d\udd04 Processing",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1120,
        -144
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcbe Google Drive Setup\n\n**Step 1:** Connect Google Drive\n- Click \"Upload to Google Drive\" node\n- Click \"Connect\"\n- Authorize n8n\n\n**Step 2:** Choose folder (optional)\n- Default: Root of \"My Drive\"\n- Or select specific folder\n\n**Output:**\n- Permanent shareable link\n- Direct download URL\n- File metadata\n\n\u23f1\ufe0f Setup time: ~2 minutes",
        "height": 280,
        "width": 380
      },
      "id": "6cf6aa8c-213e-454b-acc4-86c8331cbb25",
      "name": "\ud83d\udcbe Google Drive",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -144
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\ude80 How to Use\n\n**Manual testing:**\n1. Update inputs in \"Sample Inputs (manual)\"\n   - `video_url`: Your video URL\n   - `background_prompt`: Describe background\n   - `aspect_ratio`: Optional (default 1:1)\n2. Click \"Execute Workflow\"\n3. Wait 2-4 minutes for processing\n4. Check Google Drive for result\n\n**Webhook automation:**\n1. Activate workflow\n2. Copy webhook URL\n3. POST to webhook:\n```json\n{\n  \"video_url\": \"https://...\",\n  \"background_prompt\": \"A modern office...\",\n  \"aspect_ratio\": \"16:9\"\n}\n```\n\n**Batch processing:** Connect to Google Sheets or Airtable for bulk automation",
        "height": 380,
        "width": 380
      },
      "id": "6961e968-3b00-468d-8109-f9ce3c2ebaa4",
      "name": "\ud83d\ude80 Usage",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        16,
        -144
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ai-background-gen",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "827a2d53-0d00-492c-b2d4-095bf01a9dc2",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        -2800,
        272
      ]
    },
    {
      "parameters": {},
      "id": "d0af9917-1f4f-4357-bf89-2ab33bdc329c",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -2800,
        432
      ]
    },
    {
      "parameters": {
        "content": "## \ud83c\udfa8 GEMINI AI IMAGE GENERATION SECTION\nGenerates custom background image from text prompt using Nano Banana \u2192 Returns base64 PNG",
        "height": 100,
        "width": 900
      },
      "id": "525d4ab1-81c3-4194-8428-8eba04186dbb",
      "name": "Section: Gemini",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2368,
        512
      ],
      "notesBackgroundColor": 5
    },
    {
      "parameters": {
        "content": "## \ud83d\udcf8 Example: Input\n\n![AI Actor](https://videos.videobgremover.com/public-assets/template-04-assets/01-foreground-ai-actor.jpg)\n\n**1. Foreground Video**\n*AI avatar speaking*\n\n**Prompt:**\n\"Modern office with city skyline at golden hour\"\n\n**Aspect ratio:** 16:9\n\n**Full video:**\nhttps://videos.videobgremover.com/public-videos/assets/ai-actor.mp4",
        "height": 748,
        "width": 416
      },
      "id": "2619d740-a101-489c-b2a0-0b6bcd3371e5",
      "name": "\ud83d\udcf8 Input",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3360,
        704
      ],
      "notesBackgroundColor": 4
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "video_url",
              "value": "={{ $json.body?.video_url ?? $json.video_url }}",
              "type": "string"
            },
            {
              "name": "background_prompt",
              "value": "={{ $json.body?.background_prompt ?? $json.background_prompt }}",
              "type": "string"
            },
            {
              "name": "aspect_ratio",
              "value": "={{ $json.body?.aspect_ratio ?? $json.aspect_ratio ?? '1:1' }}",
              "type": "string"
            },
            {
              "name": "source",
              "value": "webhook",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "0e05ad57-00a1-48f6-8a2a-15583cd04750",
      "name": "Extract Webhook Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        -2640,
        272
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "video_url",
              "value": "https://videos.videobgremover.com/public-videos/assets/ai-actor.mp4",
              "type": "string"
            },
            {
              "name": "background_prompt",
              "value": "A modern minimalist office with floor-to-ceiling windows overlooking a vibrant city skyline at golden hour. Warm sunlight streams through the glass, casting soft shadows on a polished concrete floor. In the background, sleek wooden desks and green plants create a professional yet inviting atmosphere. The lighting is natural and diffused, creating a calm, productive mood. Photorealistic, architectural photography style.",
              "type": "string"
            },
            {
              "name": "aspect_ratio",
              "value": "16:9",
              "type": "string"
            },
            {
              "name": "source",
              "value": "manual",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "e1149727-5f4b-4d18-93c8-2607c069b2f4",
      "name": "Sample Inputs (Edit Here)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        -2640,
        432
      ]
    },
    {
      "parameters": {
        "mode": "append"
      },
      "id": "65c2e215-a254-4514-a5bd-c36bd6d344ca",
      "name": "Merge Triggers",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        -2480,
        352
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-goog-api-key",
              "value": "={{ $vars.GEMINI_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\": [\n      {\"text\": \"{{ $json.background_prompt }}\"}\n    ]\n  }],\n  \"generationConfig\": {\n    \"responseModalities\": [\"Image\"],\n    \"imageConfig\": {\n      \"aspectRatio\": \"{{ $json.aspect_ratio }}\"\n    }\n  }\n}",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "6483a5c1-fd4e-42ee-8ad8-219aded66c30",
      "name": "1. Generate Background Image (Gemini)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -2320,
        352
      ]
    },
    {
      "parameters": {
        "jsCode": "// Extract base64 image from Gemini response\nconst imageData = $input.item.json.candidates[0].content.parts[0].inlineData.data;\nconst mimeType = $input.item.json.candidates[0].content.parts[0].inlineData.mimeType;\n\n// Convert base64 to binary for temporary storage\nconst buffer = Buffer.from(imageData, 'base64');\n\n// Create a data URL for VideoBGRemover API\nconst dataUrl = `data:${mimeType};base64,${imageData}`;\n\nreturn {\n  json: {\n    background_image_data: imageData,\n    background_image_mime: mimeType,\n    background_image_url: dataUrl\n  },\n  binary: {\n    data: {\n      data: buffer,\n      mimeType: mimeType,\n      fileName: 'generated_background.png'\n    }\n  }\n};"
      },
      "id": "157c8a70-af96-4353-9fe8-8104d1f2073e",
      "name": "Extract Image Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2080,
        352
      ]
    },
    {
      "parameters": {
        "name": "=ai_bg_{{ $('Merge Triggers').item.json.background_prompt.substring(0, 30).replace(/[^a-zA-Z0-9]/g, '_') }}_{{ new Date().getTime() }}.png",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root"
        },
        "options": {
          "simplifyOutput": true
        }
      },
      "id": "0ba0480a-ace4-447e-8698-1dc854205011",
      "name": "2. Save Background Image to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -1840,
        352
      ]
    },
    {
      "parameters": {
        "operation": "share",
        "fileId": "={{ $json.id }}",
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "options": {}
      },
      "id": "68810993-3dbf-4f53-a27c-a461653f8f7f",
      "name": "3. Make Background Image Public",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -1600,
        352
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcf8 Example: Generated\n\n![Generated Background](https://videos.videobgremover.com/public-assets/template-04-assets/02-generated-background-nano-banana.png)\n\n**2. Nano Banana Output**\n*AI-generated office background*\n\n**Details:**\n- Model: Gemini 2.5 Flash\n- Aspect ratio: 16:9\n- Resolution: ~1536x864px\n- Time: ~10-15 seconds\n- PNG with SynthID\n\n**Saved to Drive & made public**",
        "height": 700,
        "width": 432
      },
      "id": "2dd106d4-9f8e-4a22-8da7-c5f245fbf0f5",
      "name": "\ud83d\udcf8 Generated",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2800,
        704
      ],
      "notesBackgroundColor": 6
    },
    {
      "parameters": {
        "content": "## \ud83c\udfac VIDEOBGREMOVER COMPOSITION SECTION\nRemoves foreground video background \u2192 Composites on AI-generated image \u2192 Centered template",
        "height": 100,
        "width": 1020
      },
      "id": "6bcc43e4-4de5-4c73-9dba-610e91d0a23f",
      "name": "Section: VideoBGRemover",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1360,
        512
      ],
      "notesBackgroundColor": 2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.videobgremover.com/api/v1/jobs",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-Key",
              "value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={ \"video_url\": \"{{ $('Merge Triggers').item.json.video_url }}\" }",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "639e12d4-7275-4353-9bbd-5a4a62138ada",
      "name": "4. Create Job (Upload Video)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -1360,
        592
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.videobgremover.com/api/v1/jobs/{{ $json.id }}/start",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-Key",
              "value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"background\": {\n    \"type\": \"composition\",\n    \"composition\": {\n      \"template\": \"centered\",\n      \"background_type\": \"image\",\n      \"background_url\": \"https://drive.google.com/uc?id={{ $('2. Save Background Image to Drive').item.json.id }}\",\n      \"export_format\": \"h264\",\n      \"export_preset\": \"medium\"\n    }\n  }\n}",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "aef3cf73-31dc-429e-9f61-083338ca1520",
      "name": "5. Start Composition (AI Background)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -1120,
        592
      ]
    },
    {
      "parameters": {
        "url": "=https://api.videobgremover.com/api/v1/jobs/{{ $('4. Create Job (Upload Video)').item.json.id }}/status",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-Key",
              "value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "e3a43a09-01ad-4618-ba17-b16429bfe3b4",
      "name": "6. Check Job Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -880,
        592
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "is_completed_condition",
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "249577e0-7159-4945-92fd-ad3a7bfbb9a1",
      "name": "Is Complete?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        -640,
        592
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcbe OUTPUT SECTION\nDownload final video \u2192 Upload to Google Drive \u2192 Return response",
        "height": 100,
        "width": 840
      },
      "id": "b0b6b36f-284c-446e-894b-1bacfae40264",
      "name": "Section: Output",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -400,
        512
      ],
      "notesBackgroundColor": 3
    },
    {
      "parameters": {
        "url": "={{ $json.processed_video_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "4acc452e-2286-4db8-92b0-799fda21f6de",
      "name": "7. Download Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -400,
        752
      ]
    },
    {
      "parameters": {
        "name": "=ai_bg_video_{{ $('4. Create Job (Upload Video)').item.json.id }}_{{ new Date().getTime() }}.mp4",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root"
        },
        "options": {
          "simplifyOutput": true
        }
      },
      "id": "432d20ce-1e25-400c-86a7-789e8447c323",
      "name": "8. Upload Video to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -160,
        752
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcf8 Example: Final\n\n![Final Result](https://videos.videobgremover.com/public-assets/template-04-assets/03-final-composed-result.jpg)\n\n**3. Composed Video**\n*AI actor on AI background*\n\n**Details:**\n- Template: Centered\n- Background removed\n- Aspect ratio preserved\n- Professional framing\n\n**Full video:**\nhttps://videos.videobgremover.com/public-assets/template-04-assets/final-result.mp4\n\n**Saved to Google Drive**",
        "height": 676,
        "width": 320
      },
      "id": "ac59da0a-0526-4f25-ab9c-fe42a3a353d1",
      "name": "\ud83d\udcf8 Final",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2240,
        704
      ],
      "notesBackgroundColor": 4
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "final_result",
              "type": "object",
              "value": "={{ {\n  success: true,\n  job_id: $('4. Create Job (Upload Video)').item.json.id,\n  export_id: $('5. Start Composition (AI Background)').item.json.export_id,\n  video: {\n    google_drive_id: $('8. Upload Video to Drive').item.json.id,\n    google_drive_url: $('8. Upload Video to Drive').item.json.webViewLink,\n    download_url: $('6. Check Job Status').item.json.processed_video_url,\n    filename: $('8. Upload Video to Drive').item.json.name,\n    length_seconds: $('6. Check Job Status').item.json.length_seconds\n  },\n  background_image: {\n    google_drive_id: $('2. Save Background Image to Drive').item.json.id,\n    google_drive_url: $('2. Save Background Image to Drive').item.json.webViewLink,\n    public_url: 'https://drive.google.com/uc?id=' + $('2. Save Background Image to Drive').item.json.id,\n    filename: $('2. Save Background Image to Drive').item.json.name,\n    prompt: $('Merge Triggers').item.json.background_prompt,\n    aspect_ratio: $('Merge Triggers').item.json.aspect_ratio\n  },\n  message: 'Video composed with AI-generated background successfully. Both video and background image saved to Google Drive',\n  source: $('Merge Triggers').item.json.source\n} }}"
            }
          ]
        },
        "options": {}
      },
      "id": "06d9ffa9-5ea1-4f76-b7c0-72ee3f9561a0",
      "name": "Build Success Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        96,
        752
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "is_failed_condition",
              "leftValue": "={{ $json.status }}",
              "rightValue": "failed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "4c13c1eb-3d12-444d-821a-9cce21a9356f",
      "name": "Has Failed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        -640,
        832
      ]
    },
    {
      "parameters": {
        "amount": 20
      },
      "id": "710a1000-eda6-4f22-be7c-618f875b2579",
      "name": "Wait 20s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -400,
        992
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "final_result",
              "type": "object",
              "value": "={{ {\n  success: false,\n  job_id: $('4. Create Job (Upload Video)').item.json.id,\n  error: $json.error || 'Video composition with AI background failed',\n  status: $json.status,\n  message: 'Failed to compose video with AI-generated background',\n  source: $('Merge Triggers').item.json.source\n} }}"
            }
          ]
        },
        "options": {}
      },
      "id": "afc2bd32-fe3a-4e16-a6ae-2d75575582c8",
      "name": "Build Error Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        -640,
        992
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "is_webhook_condition",
              "leftValue": "={{ $json.final_result?.source ?? $json.source }}",
              "rightValue": "webhook",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "006453e6-d202-4b10-9feb-544b6be77f52",
      "name": "From Webhook?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        336,
        752
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "a6ba3383-2e3b-4497-8e88-a9d2e96561c1",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        576,
        672
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "final_result",
              "type": "object",
              "value": "={{ $json.final_result ?? $json }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a30e6cda-335b-4a68-afbd-d492beb28c60",
      "name": "Manual Test Complete",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        576,
        832
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Extract Webhook Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Sample Inputs (Edit Here)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Webhook Data": {
      "main": [
        [
          {
            "node": "Merge Triggers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample Inputs (Edit Here)": {
      "main": [
        [
          {
            "node": "Merge Triggers",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Triggers": {
      "main": [
        [
          {
            "node": "1. Generate Background Image (Gemini)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Generate Background Image (Gemini)": {
      "main": [
        [
          {
            "node": "Extract Image Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Image Data": {
      "main": [
        [
          {
            "node": "2. Save Background Image to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Save Background Image to Drive": {
      "main": [
        [
          {
            "node": "3. Make Background Image Public",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Make Background Image Public": {
      "main": [
        [
          {
            "node": "4. Create Job (Upload Video)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. Create Job (Upload Video)": {
      "main": [
        [
          {
            "node": "5. Start Composition (AI Background)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. Start Composition (AI Background)": {
      "main": [
        [
          {
            "node": "6. Check Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. Check Job Status": {
      "main": [
        [
          {
            "node": "Is Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Complete?": {
      "main": [
        [
          {
            "node": "7. Download Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Has Failed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7. Download Video": {
      "main": [
        [
          {
            "node": "8. Upload Video to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8. Upload Video to Drive": {
      "main": [
        [
          {
            "node": "Build Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Success Response": {
      "main": [
        [
          {
            "node": "From Webhook?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Failed?": {
      "main": [
        [
          {
            "node": "Build Error Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 20s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Error Response": {
      "main": [
        [
          {
            "node": "From Webhook?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 20s": {
      "main": [
        [
          {
            "node": "6. Check Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "From Webhook?": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Manual Test Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

AI Background Generation with Nano Banana (Gemini Image). Uses httpRequest, googleDrive. Webhook trigger; 35 nodes.

Source: https://github.com/videobgremover/videobgremover-n8n-templates/blob/c3fa646aeb804ac6b14258997b06c15b30aab9c4/templates/04-ai-background-generation.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow is perfect for app developers, SaaS founders, and mobile growth teams who need constant UGC-style video ads without hiring creators or agencies. If you're spending $500+ per creator and

HTTP Request, Google Drive
AI & RAG

This template is for developers, teams, and automation enthusiasts who want a private, PIN-protected Telegram chatbot that answers questions from their own documents — without relying on external AI A

Postgres, Telegram, HTTP Request +2
AI & RAG

Storage Sync - Google Drive. Uses supabase, googleDrive, httpRequest. Webhook trigger; 22 nodes.

Supabase, Google Drive, HTTP Request
AI & RAG

This workflow automates the creation of user-generated-content-style product videos by combining Gemini's image generation with OpenAI's SORA 2 video generation. It accepts webhook requests with produ

HTTP Request, Google Sheets, Google Drive
AI & RAG

For content creators, agencies, and SaaS developers who need automated AI image generation and editing with professional delivery workflows.

HTTP Request, Google Drive, Email Send