AutomationFlowsContent & Video › Generate AI Images with Gemini and Upload Them to Wordpress (sub-workflow)

Generate AI Images with Gemini and Upload Them to Wordpress (sub-workflow)

ByAI Solutions @legalgpts on n8n.io

Sub-workflow — Called by a parent workflow to generate a photorealistic AI image from a text prompt and upload it directly to the WordPress Media Library. Receives a string field via the Execute Workflow Trigger (passthrough mode). Sends the query to Google Gemini to generate a…

Event trigger★★★☆☆ complexityAI-powered9 nodesExecute Workflow TriggerGoogle GeminiHTTP Request
Content & Video Trigger: Event Nodes: 9 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #15100 — we link there as the canonical source.

This workflow follows the Execute Workflow Trigger → 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
{
  "id": "8iRcKiCUN5HuBdKZ",
  "name": "N8N-ImageGen",
  "tags": [],
  "nodes": [
    {
      "id": "c75b96e0-cbbf-434d-83bb-a02694c2b5ba",
      "name": "Trigger \u2014 Receive Query",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        464,
        240
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "cd0ae13e-ef87-47fe-b974-bd1636978473",
      "name": "Gemini \u2014 Generate Image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        688,
        240
      ],
      "parameters": {
        "prompt": "=create a professional photorealistic image for the following: {{ $json.query }}\n\n",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-pro-image-preview",
          "cachedResultName": "models/gemini-3-pro-image-preview"
        },
        "options": {
          "binaryPropertyOutput": "data"
        },
        "resource": "image"
      },
      "typeVersion": 1
    },
    {
      "id": "9eff4394-d7a4-4830-b281-1e29f575f91e",
      "name": "WP \u2014 Upload Image to Media Library",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        944,
        240
      ],
      "parameters": {
        "url": "https://your-wordpress-site.com/wp-json/wp/v2/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Disposition",
              "value": "=attachment; filename=\"article-image-{{ $now.toMillis() }}.jpg\""
            }
          ]
        },
        "inputDataFieldName": "data",
        "nodeCredentialType": "wordpressApi"
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "c92d76ee-c4df-4aa2-846e-41828f2cb495",
      "name": "Set \u2014 Return Image Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1248,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "url-out",
              "name": "url",
              "type": "string",
              "value": "={{ $json.source_url }}"
            },
            {
              "id": "media-id-out",
              "name": "media_id",
              "type": "number",
              "value": "={{ $json.id }}"
            },
            {
              "id": "alt-out",
              "name": "alt",
              "type": "string",
              "value": "={{ $json.alt_text || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7abd1f7f-f41f-4982-a7cd-ac3d580bd436",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        32
      ],
      "parameters": {
        "width": 400,
        "height": 808,
        "content": "## \ud83d\uddbc\ufe0f Generate AI Image with Gemini and Upload to WordPress\n**Sub-workflow** \u2014 Called by a parent workflow to generate a photorealistic AI image from a text prompt and upload it directly to the WordPress Media Library.\n\n### How it works\n1. Receives a `query` string field via the Execute Workflow Trigger (passthrough mode).\n2. Sends the query to **Google Gemini** to generate a professional, photorealistic image.\n3. Uploads the resulting binary image to your **WordPress Media Library** via the WP REST API.\n4. Returns `url`, `media_id`, and `alt` to the calling parent workflow.\n\n### Setup\n1. Connect your **Google Gemini (PaLM) API** credential to the **Gemini \u2014 Generate Image** node.\n2. Connect your **WordPress API** credential to the **WP \u2014 Upload Image to Media Library** node.\n3. Update the WordPress URL in that node to point to your site: `https://your-site.com/wp-json/wp/v2/media`.\n4. Call this workflow from a parent workflow, passing a JSON field named `query`.\n\n### Customization\n- Change the Gemini model in **Gemini \u2014 Generate Image** to adjust image quality or style.\n- Edit the prompt prefix in the same node to change the default photorealistic tone.\n- The filename in the `Content-Disposition` header uses a timestamp \u2014 adjust as needed.\n\n\u26a0\ufe0f **Community Node Notice:** This workflow uses `@n8n/n8n-nodes-langchain.googleGemini`, a LangChain community node. It requires a **self-hosted n8n instance** with the LangChain add-on installed."
      },
      "typeVersion": 1
    },
    {
      "id": "8f186354-e7b7-49ea-a825-5b98fbc9544b",
      "name": "Trigger Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 400,
        "content": "## 1 \u2014 Trigger\nReceives `query` from a parent workflow via Execute Workflow Trigger (passthrough). No transformation \u2014 raw input passes through."
      },
      "typeVersion": 1
    },
    {
      "id": "b7c0cd64-26f2-4451-a285-1c0b6ef5236f",
      "name": "Gemini Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 400,
        "content": "## 2 \u2014 Image Generation\nCalls Google Gemini image model with a photorealistic prompt built from the incoming `query`. Binary output stored in the `data` field."
      },
      "typeVersion": 1
    },
    {
      "id": "c316bcef-6b45-4e11-89a0-20b64d328211",
      "name": "WP Upload Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 408,
        "content": "## 3 \u2014 WordPress Upload\nPOSTs binary image data to the WordPress Media Library REST endpoint. Retries once on failure (5s delay). Continues on error to prevent blocking the parent workflow.\n\n**Update the URL** to your own WordPress site before activating."
      },
      "typeVersion": 1
    },
    {
      "id": "285c5848-b816-4dd8-8eca-08652b451d2d",
      "name": "Return Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 248,
        "height": 400,
        "content": "## 4 \u2014 Return Data\nMaps WordPress response to clean output fields: `url`, `media_id`, `alt`. These values are returned to the calling parent workflow."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "8f49dca0-b9b7-4447-af25-a452d1a588bb",
  "connections": {
    "Gemini \u2014 Generate Image": {
      "main": [
        [
          {
            "node": "WP \u2014 Upload Image to Media Library",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger \u2014 Receive Query": {
      "main": [
        [
          {
            "node": "Gemini \u2014 Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WP \u2014 Upload Image to Media Library": {
      "main": [
        [
          {
            "node": "Set \u2014 Return Image Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

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

About this workflow

Sub-workflow — Called by a parent workflow to generate a photorealistic AI image from a text prompt and upload it directly to the WordPress Media Library. Receives a string field via the Execute Workflow Trigger (passthrough mode). Sends the query to Google Gemini to generate a…

Source: https://n8n.io/workflows/15100/ — original creator credit. Request a take-down →

More Content & Video workflows → · Browse all categories →

Related workflows

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

Content & Video

This workflow is designed for Content Marketing Teams, Agencies, and Professional Editors who prefer writing in Google Docs but need a seamless way to publish to WordPress.

HTTP Request, Google Gemini, Google Drive +1
Content & Video

Enrich Faq Sections On Your Website Pages At Scale With Ai. Uses manualTrigger, lmChatOpenAi, splitInBatches, splitOut. Event-driven trigger; 36 nodes.

OpenAI Chat, Google Drive, Google Sheets +6
Content & Video

Strapi Splitout. Uses manualTrigger, lmChatOpenAi, splitInBatches, splitOut. Event-driven trigger; 36 nodes.

OpenAI Chat, Google Drive, Google Sheets +6
Content & Video

2434. Uses lmChatOpenAi, googleDrive, googleSheets, executeWorkflowTrigger. Event-driven trigger; 36 nodes.

OpenAI Chat, Google Drive, Google Sheets +6
Content & Video

This n8n workflow template lets you easily generate comprehensive FAQ (Frequently Asked Questions) content for multiple services (or any items or pages you need to add the FAQs to). Simply provide the

OpenAI Chat, Google Drive, Google Sheets +6