{
  "name": "apizt · 单次文字请求",
  "nodes": [
    {
      "parameters": {},
      "id": "a389b38b-15f2-46df-929a-a798d148c001",
      "name": "手动开始",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "model",
              "name": "model",
              "value": "glm-5.3",
              "type": "string"
            },
            {
              "id": "prompt",
              "name": "prompt",
              "value": "用两条要点说明怎样核对 API 调用结果。",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a389b38b-15f2-46df-929a-a798d148c002",
      "name": "准备输入",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apizt.com/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({model: $json.model, messages: [{role: \"user\", content: $json.prompt}], stream: false, max_tokens: 1024}) }}",
        "options": {
          "timeout": 60000,
          "response": {
            "response": {
              "responseFormat": "json",
              "neverError": false
            }
          }
        }
      },
      "id": "a389b38b-15f2-46df-929a-a798d148c003",
      "name": "请求 apizt",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        0
      ],
      "retryOnFail": false
    },
    {
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst choice = response.choices?.[0];\nconst answer = choice?.message?.content;\nif (typeof answer !== \"string\" || !answer.trim()) {\n  throw new Error(\"没有收到文字答案；检查模型、接口与执行记录。\");\n}\nif (choice.finish_reason === \"length\") {\n  throw new Error(\"输出被截断；先核对本次调用，再调整输出预算。\");\n}\nreturn [{ json: {\n  answer,\n  model: response.model,\n  response_id: response.id,\n  finish_reason: choice.finish_reason,\n  usage: response.usage ?? null,\n} }];"
      },
      "id": "a389b38b-15f2-46df-929a-a798d148c004",
      "name": "核对答案",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        0
      ]
    }
  ],
  "connections": {
    "手动开始": {
      "main": [
        [
          {
            "node": "准备输入",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "准备输入": {
      "main": [
        [
          {
            "node": "请求 apizt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "请求 apizt": {
      "main": [
        [
          {
            "node": "核对答案",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "executionTimeout": 120
  },
  "pinData": {},
  "tags": []
}
