8
n8n 中文网amn8n.com

获取模型令牌计数和工具

中级

这是一个Building Blocks, AI领域的自动化工作流,包含 11 个节点。主要使用 N8n, Set, Code, HttpRequest, GoogleSheets 等节点,结合人工智能技术实现智能自动化。 🥇 令牌估算器 - 使用JinaAI跟踪AI模型令牌使用量和成本的子工作流

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "L7ExYkeKvBYwWbc3",
  "meta": {
    "instanceId": "ba3fa76a571c35110ef5f67e5099c9a5c1768ef125c2f3b804ba20de75248c0b",
    "templateCredsSetupCompleted": false
  },
  "name": "获取模型令牌计数和工具",
  "tags": [],
  "nodes": [
    {
      "id": "c920594a-980b-4f41-997a-78768984df6f",
      "name": "点击“测试工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1100,
        580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a6f21ab6-219a-49fa-b7ee-f59db8a49da6",
      "name": "n8n获取执行数据",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -800,
        340
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2aad0913-9c3c-413b-8a99-61acb7833f1d",
      "name": "获取AI使用数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -480,
        340
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "4983f61e-b7b6-4607-b255-6bea04d9fcda",
      "name": "设置AI运行数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -200,
        340
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "3ea6794e-25d6-432b-905c-3207f87fb048",
      "name": "获取AI定价",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        80,
        340
      ],
      "parameters": {},
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "e384a724-1f4f-4677-b15e-ddba8e693ecc",
      "name": "获取模型价格并添加摘要",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        340
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "6db7b4f5-b932-44d8-8311-2250aeee2502",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        660,
        340
      ],
      "parameters": {},
      "typeVersion": 4.5
    },
    {
      "id": "7f2a88b7-16b5-4ce4-89a4-68c477a08fba",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1860,
        140
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "d0606f04-8d97-4aa7-a2db-bbb748c0e714",
      "name": "当由其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1100,
        160
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "d53e218d-5f2a-461b-9e22-e515362d05e8",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        560
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "3c88feea-0dc4-480d-a3a5-236ee269b79b",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1860,
        -240
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {
    "When clicking ‘Test workflow’": [
      {
        "json": {
          "executionId": 44762
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "95e5afe5-706f-460b-bf58-f20c7ffe4151",
  "connections": {
    "Get AI Pricing": {
      "main": [
        [
          {
            "node": "Get Models Price and Add Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Ai_Run_Data": {
      "main": [
        [
          {
            "node": "Get AI Pricing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get AI Usage Data": {
      "main": [
        [
          {
            "node": "Set Ai_Run_Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n Get Execution Data": {
      "main": [
        [
          {
            "node": "Get AI Usage Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Models Price and Add Summary": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "n8n Get Execution Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "n8n Get Execution Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 构建模块, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量11
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
外部链接
在 n8n.io 查看

分享此工作流