⚒️ Analyze images with OpenAI Vision while preserving binary data for reuse

1,378 views · ⚒️ Engineering

Description

Use this template to upload an image, run a first-pass OpenAI Vision analysis, then re-attach the original file (binary/base64) to the next step using a Merge node. The pattern ensures your downstream AI Agent (or any node) can access both the original file (data) and the first analysis result (content) at the same time.


✅ What this template does


🧩 How it works (Node-by-node)

  1. Form Trigger
    • Presents a simple upload form and emits a binary/base64 field named data.
  2. Analyze image (OpenAI Vision)
    • Reads the same data field as base64 and runs image analysis with GPT-4o.
    • The node outputs a text content (first-pass analysis).
  3. Merge (combine by position)
    • Combines the two branches so the next node receives both the original upload (data) and the analysis (content) on the same item.
  4. AI Agent
    • Receives data + content together.
    • Prompt includes the original image (=data) and the first analysis ({{$json.content}}) to compare or refine results.
  5. OpenAI Chat Model
    • Provides the language model for the Agent (wired as ai_languageModel).

🛠️ Setup Instructions (from the JSON)

> Keep it simple: mirror these settings and you’re good to go.

1) Form Trigger (n8n-nodes-base.formTrigger)

2) Analyze image (@n8n/n8n-nodes-langchain.openAi)

3) Merge (n8n-nodes-base.merge)

4) AI Agent (@n8n/n8n-nodes-langchain.agent)

5) OpenAI Chat Model (@n8n/n8n-nodes-langchain.lmChatOpenAi)

> Security Note: Store API keys in Credentials (do not hardcode keys in nodes).


🧠 Why “Combine by Position” fixes the binary issue


🧪 Test Tips


🔧 Customize


📝 Requirements


🩹 Troubleshooting


💬 Sticky Note (included in the workflow)

> “Use Binary Field after next step” — This workflow demonstrates how to preserve and reuse an uploaded file (binary/base64) after a downstream step by using a Merge node (combineByPosition). A user uploads an image via Form Trigger → the image is analyzed with OpenAI Vision → results are merged back with the original upload so the next AI Agent step can access both the original file (data) and the first analysis (content) at the same time.


📬 Contact

Need help customizing this (e.g., filtering by campaign, sending reports by email, or formatting your PDF)?

🔗 Nodes Used

AI Agent, OpenAI Chat Model, n8n Form Trigger, OpenAI

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup