{
  "name": "🤖 Build resilient AI workflows with automatic GPT and Gemini failover chain",
  "nodes": [
    {
      "id": "180a023e-a350-4315-a7f2-968d052f634d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        288,
        -16
      ]
    },
    {
      "id": "32f3f1ad-8e72-427b-9bcf-0686ae3c4c5c",
      "name": "Agent Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -48,
        -16
      ]
    },
    {
      "id": "2d7804a4-3744-4866-89b2-705bbec66acc",
      "name": "Fallback Models",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        288,
        512
      ]
    },
    {
      "id": "e3d0d416-2571-4e86-b701-27aee1e5856e",
      "name": "First Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        304,
        704
      ]
    },
    {
      "id": "75ce0d64-dcbd-47bf-a15b-802fa979333a",
      "name": "Falback Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        432,
        704
      ]
    },
    {
      "id": "10efe391-496f-45db-ae13-52324b41b4ff",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        208
      ],
      "parameters": {
        "width": 420,
        "height": 640,
        "content": "### ⚙️ CONFIGURE YOUR FALLBACK CHAIN HERE ⚙️\n\nThis node selects which AI model to use based on the number of previous failures.\n\n**To set up your models:**\n1.  Add your desired AI model nodes to the c"
      }
    },
    {
      "id": "93797015-159e-4e43-bf72-47f0533e92f1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -240
      ],
      "parameters": {
        "width": 340,
        "height": 320,
        "content": "#### 📝 DEFINE YOUR PROMPT HERE\n\nEnter the prompt or task for the AI agent in this node.\n\nIt will dynamically use the models provided one-by-one from the `Fallback Models` node. If it fails, it will au"
      }
    },
    {
      "id": "4cedd679-70d3-41a2-9bf5-addf8e146c9a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -240
      ],
      "parameters": {
        "width": 400,
        "height": 320,
        "content": "#### 🔁 Loop Controller\n\nThis node manages the retry loop.\n\nIt initializes and increments a `fail_count` variable each time the `AI Agent` fails, which tells the `Fallback Models` node to try the next "
      }
    },
    {
      "id": "4b5e9318-16fd-4e69-add6-0edbca278d91",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -320,
        -16
      ]
    },
    {
      "id": "0c0620d5-64fc-432a-bb22-84d7a4134f4b",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -240
      ],
      "parameters": {
        "width": 540,
        "height": 800,
        "content": "## Was this helpful? Let me know!\n\nI really hope this template helped you understand how Langchain code works here in n8n. Your feedback is incredibly valuable and helps me create better resources for"
      }
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [],
        [
          {
            "node": "Agent Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "First Model": {
      "ai_languageModel": [
        [
          {
            "node": "Fallback Models",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Falback Model": {
      "ai_languageModel": [
        [
          {
            "node": "Fallback Models",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Agent Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent Variables": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fallback Models": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}