跳至内容

OpenAI聊天模型节点常见问题#

以下是OpenAI Chat Model节点常见错误与问题及其解决方法或排查步骤。

处理参数#

OpenAI聊天模型节点是一个子节点。在使用表达式处理多个项目时,子节点的行为与其他节点不同。

大多数节点,包括根节点,可以接收任意数量的项目作为输入,处理这些项目并输出结果。您可以使用表达式来引用输入项,节点会依次为每个项目解析该表达式。例如,给定五个名称值作为输入,表达式{{ $json.name }}会依次解析为每个名称。

在子节点中,表达式始终解析为第一项。例如,给定五个名称值的输入,表达式 {{ $json.name }} 始终解析为第一个名称。

服务收到来自您的请求过多#

当您超过OpenAI的速率限制时会出现此错误。

有两种方法可以解决这个问题:

  1. Split your data up into smaller chunks using the Loop Over Items node and add a Wait node at the end for a time amount that will help. Copy the code below and paste it into a workflow to use as a template.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    {
        "nodes": [
        {
            "parameters": {},
            "id": "35d05920-ad75-402a-be3c-3277bff7cc67",
            "name": "When clicking ‘Test workflow’",
            "type": "n8n-nodes-base.manualTrigger",
            "typeVersion": 1,
            "position": [
            880,
            400
            ]
        },
        {
            "parameters": {
            "batchSize": 500,
            "options": {}
            },
            "id": "ae9baa80-4cf9-4848-8953-22e1b7187bf6",
            "name": "Loop Over Items",
            "type": "n8n-nodes-base.splitInBatches",
            "typeVersion": 3,
            "position": [
            1120,
            420
            ]
        },
        {
            "parameters": {
            "resource": "chat",
            "options": {},
            "requestOptions": {}
            },
            "id": "a519f271-82dc-4f60-8cfd-533dec580acc",
            "name": "OpenAI",
            "type": "n8n-nodes-base.openAi",
            "typeVersion": 1,
            "position": [
            1380,
            440
            ]
        },
        {
            "parameters": {
            "unit": "minutes"
            },
            "id": "562d9da3-2142-49bc-9b8f-71b0af42b449",
            "name": "Wait",
            "type": "n8n-nodes-base.wait",
            "typeVersion": 1,
            "position": [
            1620,
            440
            ],
            "webhookId": "714ab157-96d1-448f-b7f5-677882b92b13"
        }
        ],
        "connections": {
        "When clicking ‘Test workflow’": {
            "main": [
            [
                {
                "node": "Loop Over Items",
                "type": "main",
                "index": 0
                }
            ]
            ]
        },
        "Loop Over Items": {
            "main": [
            null,
            [
                {
                "node": "OpenAI",
                "type": "main",
                "index": 0
                }
            ]
            ]
        },
        "OpenAI": {
            "main": [
            [
                {
                "node": "Wait",
                "type": "main",
                "index": 0
                }
            ]
            ]
        },
        "Wait": {
            "main": [
            [
                {
                "node": "Loop Over Items",
                "type": "main",
                "index": 0
                }
            ]
            ]
        }
        },
        "pinData": {}
    }
    
  2. 使用HTTP请求节点配合内置的批量限制选项来调用OpenAI API,而非直接使用OpenAI节点。

Insufficient quota#

配额问题

OpenAI存在多个与配额相关的问题,包括最近补充配额后出现的故障。为避免这些问题,请确保账户中有余额,并从API密钥页面重新生成新的API密钥。

当您的OpenAI账户没有足够的积分或容量来满足请求时,会显示此错误。这可能意味着您的OpenAI试用期已结束、账户需要更多积分,或者您已超出使用限制。

要排查此错误,请前往您的OpenAI设置页面:

  • 在左上角的第一个选择器中为您的API密钥选择正确的组织。
  • 在左上角的第二个选择器中为您的API密钥选择正确的项目。
  • 检查组织级别的账单概览页面,确保该组织有足够的信用额度。请再次确认您在此页面选择了正确的组织。
  • 检查组织级别的使用限制页面。请再次确认您为该页面选择了正确的组织,并滚动至使用限制部分,以核实您未超出组织的使用限制。
  • 检查您的OpenAI项目使用限额。请再次确认在左上角的第二个选择器中选择了正确的项目。选择项目 > 限额来查看或修改项目限额。
  • 检查OpenAI API是否正常运行。

平衡等待期

充值余额后,您的OpenAI账户可能需要一段时间才能显示新的余额。

在n8n中:

If you find yourself frequently running out of account credits, consider turning on auto recharge in your OpenAI billing settings to automatically reload your account with credits when your balance reaches $0.

错误请求 - 请检查您的参数#

当请求导致错误但n8n无法解析OpenAI返回的错误信息时,会显示此错误。

开始排查问题时,可以尝试使用HTTP Request节点运行相同的操作,该节点应能提供更详细的错误信息。

优云智算