{
  "id": "n8ph9D1haiUvCWVx",
  "name": "AI Visual Generator \u2014 Claude Prompt Engineering + Gemini Images",
  "tags": [],
  "nodes": [
    {
      "id": "9b816f9a-952c-4d39-b93e-3ea5a59ffe23",
      "name": "Image Request Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        208,
        512
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Generate image",
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Generating your image now \u2014 it will arrive by email shortly."
            }
          }
        },
        "formTitle": "Generate an AI image",
        "formFields": {
          "values": [
            {
              "fieldType": "email",
              "fieldLabel": "Your Email",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Image Description",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Style",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Photorealistic"
                  },
                  {
                    "option": "Illustration"
                  },
                  {
                    "option": "3D Render"
                  },
                  {
                    "option": "Minimalist"
                  },
                  {
                    "option": "Cinematic"
                  }
                ]
              }
            }
          ]
        },
        "formDescription": "Describe what you want. We enhance your prompt and generate an image, delivered to your inbox."
      },
      "typeVersion": 2.6
    },
    {
      "id": "72566923-1a91-4cb3-8ca0-6c6be0154b28",
      "name": "Normalize Image Request",
      "type": "n8n-nodes-base.set",
      "position": [
        576,
        512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "i_email",
              "name": "email",
              "type": "string",
              "value": "={{ $json[\"Your Email\"] ?? $json.email ?? \"\" }}"
            },
            {
              "id": "i_desc",
              "name": "description",
              "type": "string",
              "value": "={{ $json[\"Image Description\"] ?? $json.description ?? \"\" }}"
            },
            {
              "id": "i_style",
              "name": "style",
              "type": "string",
              "value": "={{ $json.Style ?? $json.style ?? \"Photorealistic\" }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6dab1fbc-6467-464a-9903-2a6980edc6b0",
      "name": "Prompt Enhancer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1008,
        512
      ],
      "parameters": {
        "text": "=Description: {{ $json.description }}\nStyle: {{ $json.style }}",
        "options": {
          "systemMessage": "You are a prompt engineer for AI image generation. Expand the user description into a single vivid, detailed image-generation prompt in the chosen style. Include subject, composition, lighting, mood, colour palette, and render/camera details. Keep it under 80 words. Output ONLY the final prompt text \u2014 no preamble, no quotes."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "4554fbec-6e0c-4c6c-b71a-031f032fec29",
      "name": "Claude Sonnet 4.6",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1008,
        720
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-6",
          "cachedResultName": "Claude Sonnet 4.6"
        },
        "options": {
          "temperature": 0.7,
          "maxTokensToSample": 400
        }
      },
      "typeVersion": 1.5
    },
    {
      "id": "0d4da9b4-f141-4d37-9a97-87044c73f695",
      "name": "Generate Image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "maxTries": 3,
      "position": [
        1360,
        512
      ],
      "parameters": {
        "prompt": "={{ $json.output }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3.1-flash-image-preview",
          "cachedResultName": "Gemini 3.1 Flash Image"
        },
        "options": {
          "binaryPropertyOutput": "data"
        },
        "resource": "image"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "6c7ef91b-3a97-47d0-8000-a5e7d1190bb0",
      "name": "Email Image",
      "type": "n8n-nodes-base.gmail",
      "onError": "continueRegularOutput",
      "maxTries": 3,
      "position": [
        1584,
        416
      ],
      "parameters": {
        "sendTo": "={{ $(\"Normalize Image Request\").item.json.email }}",
        "message": "=<p>Here is your generated image, attached.</p><p><b>Style:</b> {{ $(\"Normalize Image Request\").item.json.style }}</p><p><b>Prompt used:</b> {{ $(\"Prompt Enhancer\").item.json.output }}</p>",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {}
            ]
          },
          "appendAttribution": false
        },
        "subject": "=\ud83c\udfa8 Your AI image: {{ $(\"Normalize Image Request\").item.json.description }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 2.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "3bd5faed-1111-49e9-a4a1-29b58bf9367b",
      "name": "Log to Image Table",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1584,
        608
      ],
      "parameters": {
        "columns": {
          "value": {
            "style": "={{ $(\"Normalize Image Request\").item.json.style }}",
            "prompt": "={{ $(\"Prompt Enhancer\").item.json.output }}",
            "logged_at": "={{ $now.toISO() }}",
            "description": "={{ $(\"Normalize Image Request\").item.json.description }}"
          },
          "schema": [
            {
              "id": "description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "logged_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "logged_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow"
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "image_gen_log"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "452aed77-408b-4266-bbbe-b3b58ef0da3a",
      "name": "Sticky Note 4174cab7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -48
      ],
      "parameters": {
        "color": 4,
        "width": 584,
        "height": 488,
        "content": "## \ud83c\udfa8 AI Visual Generator (Claude + Gemini)\n\nDescribe an image in plain words. Claude engineers a rich prompt, Google Gemini generates the image, and it lands in your inbox \u2014 every prompt logged for reuse.\n\n**Flow:** Form \u2192 Normalize \u2192 Claude (prompt enhance) \u2192 Gemini (image) \u2192 email + log.\n\n### Setup\n1. Connect **Anthropic**, **Google Gemini (PaLM)**, and **Gmail** credentials.\n2. Activate and share the form URL.\n3. Describe an image, pick a style, submit."
      },
      "typeVersion": 1
    },
    {
      "id": "c5fb5e12-05ab-46af-ba05-792eb24c6de5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        816
      ],
      "parameters": {
        "width": 352,
        "height": 240,
        "content": "### \ud83d\udfe2 Image Request Form\n**Type:** Form Trigger\n**Function:** Collects the initial one-line image description and style preference from the user to kick off the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "df9ed09e-bc37-470a-80e2-d6cf9b2b574f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        816
      ],
      "parameters": {
        "width": 368,
        "height": 192,
        "content": "### \ud83d\udee0\ufe0f Normalize Image Request\n**Type:** Data Manipulation (Manual)\n**Function:** Cleans up and structures the raw form input data so the AI agent can easily understand and process it."
      },
      "typeVersion": 1
    },
    {
      "id": "2780cf57-f629-4cda-a19d-2cb149bd9006",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        848
      ],
      "parameters": {
        "width": 352,
        "height": 352,
        "content": "### \ud83e\udde0 Prompt Enhancer\n**Type:** AI Agent\n**Function:** Expands the simple one-line description into a highly detailed, style-aware prompt (including subject, lighting, composition, and palette). \n**Connected Sub-nodes:**\n- Chat Model: Claude Sonnet 4.6\n- Memory\n- Tool"
      },
      "typeVersion": 1
    },
    {
      "id": "14ed458f-0d3a-4798-9e66-9c8b36713ada",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1296,
        816
      ],
      "parameters": {
        "width": 272,
        "height": 240,
        "content": "### \ud83d\uddbc\ufe0f Generate Image\n**Type:** Google Gemini (Generate: Image)\n**Function:** Takes the engineered, detailed prompt from Claude and generates the actual image artwork."
      },
      "typeVersion": 1
    },
    {
      "id": "df585cf7-b5e7-4bad-8564-c98fa6a81cb1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1776,
        240
      ],
      "parameters": {
        "width": 256,
        "height": 224,
        "content": "### \u2709\ufe0f Email Image\n**Type:** Gmail (Action: Send Message)\n**Function:** Delivers the final generated image as an attachment directly to your inbox."
      },
      "typeVersion": 1
    },
    {
      "id": "46e1a7a9-6e4d-48a6-b04c-8c345cdb4ba3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        608
      ],
      "parameters": {
        "width": 336,
        "height": 224,
        "content": "### \ud83d\udcca Log to Image Table\n**Type:** Spreadsheet/Database \n**Function:** Records the detailed prompt and image generation details into a table so every successful prompt is logged for future reuse."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "1009ff02-d00e-4b6b-9002-1220c9be5eee",
  "nodeGroups": [],
  "connections": {
    "Generate Image": {
      "main": [
        [
          {
            "node": "Email Image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Image Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Enhancer": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet 4.6": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt Enhancer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Image Request Form": {
      "main": [
        [
          {
            "node": "Normalize Image Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Image Request": {
      "main": [
        [
          {
            "node": "Prompt Enhancer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}