{
  "name": "Token Tracker",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -32,
        0
      ],
      "id": "719a9dcd-f08d-4edc-bdc7-146f8b7f7a26",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "model": "openai/gpt-4.1-nano",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        128,
        272
      ],
      "id": "c53b7da0-ebe9-4d15-b34e-e5f215ebf38b",
      "name": "OpenRouter Chat Model1",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        320,
        272
      ],
      "id": "57e02a9f-d06b-4be9-8c6c-6f42d033fb82",
      "name": "Calculator"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "\u0421\u043a\u0430\u0436\u0438, \u043a\u0430\u043a\u0430\u044f \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0434\u0430\u0442\u0430? \u0418 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 5000 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 278 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c 651",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        240,
        0
      ],
      "id": "f7e6f095-cae7-4170-9914-82d6b34f2035",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "Execution_ID"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -864,
        224
      ],
      "id": "c1860081-d19c-4e17-9337-35f05196fef7",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {},
      "type": "CUSTOM.tokenCostOpenRouter",
      "typeVersion": 1,
      "position": [
        -496,
        224
      ],
      "id": "b59fd5c2-5f51-426f-9879-f637e2decc19",
      "name": "Token Cost (OpenRouter)",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        768,
        80
      ],
      "id": "d095fffc-4b60-4fb0-b080-f47a596b7248",
      "name": "Next Logic Workflow"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "S8p05KpvQT7Myhiw",
          "mode": "list",
          "cachedResultUrl": "/workflow/S8p05KpvQT7Myhiw",
          "cachedResultName": "[1] Token Tracker"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "Execution_ID": "={{ $json.execution_id }}"
          },
          "matchingColumns": [
            "Execution_ID"
          ],
          "schema": [
            {
              "id": "Execution_ID",
              "displayName": "Execution_ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {
          "waitForSubWorkflow": false
        }
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.3,
      "position": [
        784,
        -144
      ],
      "id": "6017cb8c-8256-419e-911c-7fc823511a15",
      "name": "Call '[1] Token Tracker'"
    },
    {
      "parameters": {
        "content": "## \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Token Cost \u0441 AI \u0430\u0433\u0435\u043d\u0442\u043e\u043c\n\u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430:\n- \u2705   Basic LLM\n- \u2705   Guardrails\n- \u2705   AI Agent Tools",
        "height": 896,
        "width": 1136
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -272
      ],
      "typeVersion": 1,
      "id": "3b63a4b3-cab1-4f14-8522-bd9653a8a6f3",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0442\u043e\u043a\u0435\u043d\u043e\u0432\n- \u0438 \u0438\u0445 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d OpenRouter",
        "height": 352,
        "width": 768,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        96
      ],
      "typeVersion": 1,
      "id": "e9a93e4b-0aea-47c4-89dc-d3a77f10983e",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "text": "\u0422\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0448\u044c \u043a\u0430\u043a\u0430\u044f \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0434\u0430\u0442\u0430",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "typeVersion": 2.2,
      "position": [
        464,
        336
      ],
      "id": "c8137199-279e-44c2-b90c-0ccab0bb18aa",
      "name": "AI Agent Tool"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        432,
        496
      ],
      "id": "fcefdf21-13b0-4679-ab9b-7b728ca068c7",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.dateTimeTool",
      "typeVersion": 2,
      "position": [
        672,
        496
      ],
      "id": "f6cd9205-bd41-4f07-a7c2-ab9fa4471c22",
      "name": "Date & Time"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -320,
        224
      ],
      "id": "b5493e20-5aff-4e31-ad05-6dac0c80787f",
      "name": "Save DB"
    },
    {
      "parameters": {
        "operation": "fetch",
        "executionId": "={{ $json.Execution_ID }}"
      },
      "type": "CUSTOM.tokenUsage",
      "typeVersion": 1,
      "position": [
        -672,
        224
      ],
      "id": "f8550a64-bb9e-4c71-8457-f4a3b8661083",
      "name": "Token Usage (Get)",
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "CUSTOM.tokenUsage",
      "typeVersion": 1,
      "position": [
        608,
        -144
      ],
      "id": "496d505f-2165-4ab3-ba41-f7492476208b",
      "name": "Token Usage (Save)",
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Next Logic Workflow",
            "type": "main",
            "index": 0
          },
          {
            "node": "Token Usage (Save)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Token Usage (Get)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "ai_tool": [
        [
          {
            "node": "AI Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Token Cost (OpenRouter)": {
      "main": [
        [
          {
            "node": "Save DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Token Usage (Get)": {
      "main": [
        [
          {
            "node": "Token Cost (OpenRouter)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Token Usage (Save)": {
      "main": [
        [
          {
            "node": "Call '[1] Token Tracker'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3ffc7e42-5710-4b4c-a85a-8fe3645ed032",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "S8p05KpvQT7Myhiw",
  "tags": []
}