{"id":435,"date":"2026-10-31T02:13:32","date_gmt":"2026-10-31T02:13:32","guid":{"rendered":"https:\/\/ntokenx.com\/blog\/index.php\/2026\/10\/31\/wecom-llm-bot-api\/"},"modified":"2026-10-31T02:13:32","modified_gmt":"2026-10-31T02:13:32","slug":"wecom-llm-bot-api","status":"publish","type":"post","link":"https:\/\/ntokenx.com\/blog\/index.php\/2026\/10\/31\/wecom-llm-bot-api\/","title":{"rendered":"\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\uff1aWebhook\u4e0e\u4ee3\u7801\u5b9e\u6218"},"content":{"rendered":"<p><em>\u4f5c\u8005\uff1anTokenX\uff5c\u53d1\u5e03\u65e5\u671f\uff1a2026-10-31\uff5c\u66f4\u65b0\u65e5\u671f\uff1a2026-10-31<\/em><\/p>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\uff0c\u6838\u5fc3\u4e0d\u662f\u5355\u72ec\u8c03\u7528\u67d0\u4e00\u4e2a\u6a21\u578b\uff0c\u800c\u662f\u6253\u901a\u201c\u4f01\u4e1a\u5fae\u4fe1\u6d88\u606f\u56de\u8c03\u2014\u4e1a\u52a1\u670d\u52a1\u2014\u7edf\u4e00\u5927\u6a21\u578bAPI\u2014\u673a\u5668\u4eba\u56de\u590d\u201d\u8fd9\u6761\u94fe\u8def\u3002\u672c\u6587\u4ee5 URL \u56de\u8c03\u6a21\u5f0f\u4e3a\u4f8b\uff0c\u8bf4\u660e\u914d\u7f6e\u65b9\u6cd5\u3001\u4ee3\u7801\u7ed3\u6784\u3001\u9274\u6743\u8bbe\u8ba1\u3001\u8d85\u65f6\u5904\u7406\u548c\u5e38\u89c1\u6545\u969c\u6392\u67e5\u3002<\/p>\n<figure class=\"wp-block-image size-large\" style=\"margin:1.5em 0;\"><img decoding=\"async\" src=\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/10\/backend-8910-1.jpg\" alt=\"\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\u7684\u7cfb\u7edf\u67b6\u6784\u56fe\" style=\"max-width:100%;height:auto;\"><\/figure>\n<h2>\u4ec0\u4e48\u662f\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\uff1f<\/h2>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\uff0c\u662f\u6307\u8ba9\u4f01\u4e1a\u5fae\u4fe1\u667a\u80fd\u673a\u5668\u4eba\u63a5\u6536\u7528\u6237\u6d88\u606f\uff0c\u518d\u7531\u81ea\u6709\u670d\u52a1\u8c03\u7528\u5916\u90e8\u5927\u6a21\u578b\u63a5\u53e3\u751f\u6210\u7b54\u6848\uff0c\u6700\u540e\u5c06\u7ed3\u679c\u56de\u590d\u5230\u4f01\u4e1a\u5fae\u4fe1\u4f1a\u8bdd\u4e2d\u3002<\/p>\n<p>\u5b8c\u6574\u94fe\u8def\u53ef\u4ee5\u62bd\u8c61\u4e3a\uff1a<\/p>\n<pre><code class=\"language-text\">\u7528\u6237\u53d1\u9001\u6d88\u606f\n    \u2193\n\u4f01\u4e1a\u5fae\u4fe1 URL \u56de\u8c03\n    \u2193\n\u670d\u52a1\u7aef\u9a8c\u7b7e\u4e0e\u89e3\u5bc6\n    \u2193\n\u8c03\u7528\u7edf\u4e00\u5927\u6a21\u578b API\n    \u2193\n\u5904\u7406\u6a21\u578b\u54cd\u5e94\n    \u2193\n\u4f01\u4e1a\u5fae\u4fe1 response_url \u56de\u590d\n<\/code><\/pre>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u667a\u80fd\u673a\u5668\u4eba\u901a\u5e38\u9700\u8981\u914d\u7f6e\u56de\u8c03 URL\u3001Token \u548c EncodingAESKey\u3002\u6536\u5230\u6d88\u606f\u540e\uff0c\u670d\u52a1\u7aef\u5fc5\u987b\u5148\u5b8c\u6210\u7b7e\u540d\u6821\u9a8c\u548c\u89e3\u5bc6\uff0c\u518d\u8bfb\u53d6\u7528\u6237\u6587\u672c\uff1b\u5982\u679c\u6a21\u578b\u5904\u7406\u65f6\u95f4\u8f83\u957f\uff0c\u5219\u5e94\u4f7f\u7528\u4e3b\u52a8\u56de\u590d\u63a5\u53e3\uff0c\u800c\u4e0d\u662f\u957f\u65f6\u95f4\u963b\u585e\u539f\u59cb\u56de\u8c03\u3002\u76f8\u5173\u56de\u8c03\u673a\u5236\u548c <code>response_url<\/code> \u4f7f\u7528\u65b9\u5f0f\uff0c\u53ef\u53c2\u8003\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba API \u8d44\u6599\u3002(<a href=\"https:\/\/github.com\/go-sphere\/wecom-bot-api\/blob\/master\/API.md\">github.com<\/a>)<\/p>\n<h2>URL \u56de\u8c03\u4e0e\u7fa4\u673a\u5668\u4eba Webhook\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h2>\n<p>\u4e24\u8005\u90fd\u5e38\u88ab\u79f0\u4e3a\u201c\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba Webhook\u201d\uff0c\u4f46\u7528\u9014\u4e0d\u540c\uff1a<\/p>\n<div style=\"overflow-x:auto;\">\n<table style=\"width:100%;border-collapse:collapse;margin:1.5em 0;font-size:0.95em;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u7c7b\u578b<\/th>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u4e3b\u8981\u7528\u9014<\/th>\n<th style=\"text-align:right\">\u662f\u5426\u63a5\u6536\u7528\u6237\u6d88\u606f<\/th>\n<th style=\"text-align:right\">\u662f\u5426\u9002\u5408\u63a5\u5165\u5927\u6a21\u578b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u7fa4\u673a\u5668\u4eba Webhook<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5411\u7fa4\u804a\u63a8\u9001\u901a\u77e5<\/td>\n<td style=\"text-align:right\">\u901a\u5e38\u4e0d\u63a5\u6536<\/td>\n<td style=\"text-align:right\">\u9002\u5408\u5355\u5411\u544a\u8b66\u3001\u65e5\u62a5<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u667a\u80fd\u673a\u5668\u4eba URL \u56de\u8c03<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u63a5\u6536\u7528\u6237\u4e0e\u673a\u5668\u4eba\u4ea4\u4e92<\/td>\n<td style=\"text-align:right\">\u53ef\u4ee5\u63a5\u6536<\/td>\n<td style=\"text-align:right\">\u9002\u5408\u95ee\u7b54\u548c\u4e1a\u52a1\u5904\u7406<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u667a\u80fd\u673a\u5668\u4eba\u957f\u8fde\u63a5<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u901a\u8fc7\u957f\u8fde\u63a5\u6536\u53d1\u6d88\u606f<\/td>\n<td style=\"text-align:right\">\u53ef\u4ee5\u63a5\u6536<\/td>\n<td style=\"text-align:right\">\u9002\u5408\u4f4e\u5ef6\u8fdf\u670d\u52a1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u5982\u679c\u9700\u6c42\u662f\u201c\u7528\u6237\u5728\u4f01\u4e1a\u5fae\u4fe1\u4e2d\u63d0\u95ee\uff0c\u673a\u5668\u4eba\u8c03\u7528\u6a21\u578b\u540e\u56de\u7b54\u201d\uff0c\u5e94\u4f18\u5148\u9009\u62e9\u667a\u80fd\u673a\u5668\u4eba\u7684 API \u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u53ea\u914d\u7f6e\u4e00\u4e2a\u7fa4\u673a\u5668\u4eba\u53d1\u9001\u5730\u5740\u3002\u7fa4\u673a\u5668\u4eba Webhook \u4e3b\u8981\u7528\u4e8e\u5411\u7fa4\u804a\u63a8\u9001\u6587\u672c\u3001Markdown \u6216\u544a\u8b66\u6d88\u606f\u3002(<a href=\"https:\/\/cloud.tencent.cn\/document\/product\/1759\/128391\">cloud.tencent.cn<\/a>)<\/p>\n<h2>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u914d\u7f6e\u6b65\u9aa4<\/h2>\n<h3>1. \u521b\u5efa API \u6a21\u5f0f\u667a\u80fd\u673a\u5668\u4eba<\/h3>\n<p>\u5728\u4f01\u4e1a\u5fae\u4fe1\u7ba1\u7406\u540e\u53f0\u8fdb\u5165\u667a\u80fd\u673a\u5668\u4eba\u521b\u5efa\u9875\u9762\uff0c\u9009\u62e9\u624b\u52a8\u521b\u5efa\uff0c\u5e76\u5207\u6362\u5230 <strong>API \u6a21\u5f0f\u521b\u5efa<\/strong>\u3002\u6839\u636e\u5b9e\u9645\u9875\u9762\u9009\u62e9\u201c\u4f7f\u7528 URL \u56de\u8c03\u201d\uff0c\u586b\u5199\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\u56de\u8c03 URL\uff1a\u4f8b\u5982 <code>https:\/\/example.com\/wecom\/callback<\/code><\/li>\n<li>Token\uff1a\u81ea\u5b9a\u4e49\u968f\u673a\u5b57\u7b26\u4e32<\/li>\n<li>EncodingAESKey\uff1a\u4f7f\u7528\u4f01\u4e1a\u5fae\u4fe1\u751f\u6210\u7684 43 \u4f4d\u5bc6\u94a5<\/li>\n<li>\u6d88\u606f\u6743\u9650\uff1a\u786e\u4fdd\u673a\u5668\u4eba\u62e5\u6709\u63a5\u6536\u548c\u56de\u590d\u6d88\u606f\u7684\u6743\u9650<\/li>\n<\/ul>\n<p>\u56de\u8c03 URL \u5fc5\u987b\u80fd\u591f\u88ab\u4f01\u4e1a\u5fae\u4fe1\u670d\u52a1\u5668\u8bbf\u95ee\uff0c\u751f\u4ea7\u73af\u5883\u5efa\u8bae\u4f7f\u7528 HTTPS\uff0c\u5e76\u5c06\u63a5\u53e3\u90e8\u7f72\u5728\u72ec\u7acb\u8def\u5f84\u4e0b\uff0c\u4f8b\u5982 <code>\/wecom\/callback<\/code>\uff0c\u907f\u514d\u4e0e\u666e\u901a\u4e1a\u52a1\u63a5\u53e3\u6df7\u7528\u3002<\/p>\n<h3>2. \u670d\u52a1\u7aef\u5b8c\u6210 URL \u9a8c\u8bc1<\/h3>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u4fdd\u5b58\u914d\u7f6e\u65f6\uff0c\u901a\u5e38\u4f1a\u5411\u56de\u8c03\u5730\u5740\u53d1\u8d77\u9a8c\u8bc1\u8bf7\u6c42\u3002\u670d\u52a1\u7aef\u9700\u8981\u8bfb\u53d6 <code>msg_signature<\/code>\u3001<code>timestamp<\/code>\u3001<code>nonce<\/code> \u548c <code>echostr<\/code>\uff0c\u4f7f\u7528\u4f01\u4e1a\u5fae\u4fe1\u52a0\u89e3\u5bc6\u5e93\u6821\u9a8c\u7b7e\u540d\u5e76\u8fd4\u56de\u89e3\u5bc6\u540e\u7684\u660e\u6587\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u4e0d\u8981\u628a Token \u6216 EncodingAESKey \u5199\u6b7b\u5728\u4ee3\u7801\u4ed3\u5e93\u4e2d\uff0c\u5efa\u8bae\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u6ce8\u5165\uff1a<\/p>\n<pre><code class=\"language-bash\">WECOM_TOKEN=replace-with-token\nWECOM_AES_KEY=replace-with-encoding-aes-key\nLLM_API_KEY=replace-with-gateway-key\nLLM_BASE_URL=https:\/\/your-gateway.example\/v1\nLLM_MODEL=your-model-name\n<\/code><\/pre>\n<h2>\u5982\u4f55\u7f16\u5199\u56de\u8c03\u670d\u52a1\uff1f<\/h2>\n<p>\u4e0b\u9762\u793a\u4f8b\u5c55\u793a\u6838\u5fc3\u4e1a\u52a1\u7ed3\u6784\u3002\u793a\u4f8b\u4e2d\u7684\u52a0\u89e3\u5bc6\u51fd\u6570\u9700\u8981\u66ff\u6362\u4e3a\u4f01\u4e1a\u5fae\u4fe1\u5b98\u65b9\u517c\u5bb9\u5e93\u6216\u7ecf\u8fc7\u9a8c\u8bc1\u7684\u5b9e\u73b0\uff0c\u91cd\u70b9\u662f\u4f53\u73b0\u8bf7\u6c42\u5206\u5c42\uff0c\u800c\u4e0d\u662f\u628a\u52a0\u5bc6\u7b97\u6cd5\u81ea\u884c\u91cd\u5199\u3002<\/p>\n<pre><code class=\"language-python\">import os\nimport httpx\nfrom fastapi import FastAPI, Request, HTTPException\n\napp = FastAPI()\n\nLLM_API_KEY = os.environ[&quot;LLM_API_KEY&quot;]\nLLM_BASE_URL = os.environ[&quot;LLM_BASE_URL&quot;]\nLLM_MODEL = os.environ[&quot;LLM_MODEL&quot;]\n\ndef verify_and_decrypt(signature, timestamp, nonce, echostr):\n    &quot;&quot;&quot;\n    \u4f7f\u7528\u4f01\u4e1a\u5fae\u4fe1\u5b98\u65b9\u517c\u5bb9\u7684\u6d88\u606f\u52a0\u89e3\u5bc6\u5e93\u5b8c\u6210\u6821\u9a8c\u548c\u89e3\u5bc6\u3002\n    \u8fd4\u56de\u660e\u6587 echostr\u3002\n    &quot;&quot;&quot;\n    return wecom_crypto_verify(\n        token=os.environ[&quot;WECOM_TOKEN&quot;],\n        aes_key=os.environ[&quot;WECOM_AES_KEY&quot;],\n        signature=signature,\n        timestamp=timestamp,\n        nonce=nonce,\n        echostr=echostr,\n    )\n\n@app.get(&quot;\/wecom\/callback&quot;)\nasync def verify_callback(\n    msg_signature: str,\n    timestamp: str,\n    nonce: str,\n    echostr: str\n):\n    return verify_and_decrypt(\n        msg_signature, timestamp, nonce, echostr\n    )\n\n@app.post(&quot;\/wecom\/callback&quot;)\nasync def receive_message(request: Request):\n    body = await request.body()\n\n    message = wecom_decrypt_message(\n        body=body,\n        token=os.environ[&quot;WECOM_TOKEN&quot;],\n        aes_key=os.environ[&quot;WECOM_AES_KEY&quot;],\n    )\n\n    user_text = message.get(&quot;content&quot;, &quot;&quot;).strip()\n    response_url = message.get(&quot;response_url&quot;)\n\n    if not user_text or not response_url:\n        return {&quot;errcode&quot;: 0}\n\n    answer = await call_llm(user_text)\n    await reply_to_wecom(response_url, answer)\n\n    return {&quot;errcode&quot;: 0}\n\nasync def call_llm(user_text: str) -&gt; str:\n    headers = {\n        &quot;Authorization&quot;: f&quot;Bearer {LLM_API_KEY}&quot;,\n        &quot;Content-Type&quot;: &quot;application\/json&quot;,\n    }\n\n    payload = {\n        &quot;model&quot;: LLM_MODEL,\n        &quot;messages&quot;: [\n            {\n                &quot;role&quot;: &quot;system&quot;,\n                &quot;content&quot;: &quot;\u4f60\u662f\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u52a9\u624b\uff0c\u56de\u7b54\u8981\u51c6\u786e\u3001\u7b80\u6d01\uff0c\u4e0d\u786e\u5b9a\u65f6\u660e\u786e\u8bf4\u660e\u3002&quot;,\n            },\n            {\n                &quot;role&quot;: &quot;user&quot;,\n                &quot;content&quot;: user_text,\n            },\n        ],\n        &quot;temperature&quot;: 0.2,\n    }\n\n    async with httpx.AsyncClient(timeout=30) as client:\n        response = await client.post(\n            f&quot;{LLM_BASE_URL}\/chat\/completions&quot;,\n            headers=headers,\n            json=payload,\n        )\n        response.raise_for_status()\n        data = response.json()\n\n    return data[&quot;choices&quot;][0][&quot;message&quot;][&quot;content&quot;]\n\nasync def reply_to_wecom(response_url: str, answer: str):\n    payload = {\n        &quot;msgtype&quot;: &quot;text&quot;,\n        &quot;text&quot;: {\n            &quot;content&quot;: answer[:4000]\n        }\n    }\n\n    async with httpx.AsyncClient(timeout=10) as client:\n        response = await client.post(response_url, json=payload)\n        response.raise_for_status()\n<\/code><\/pre>\n<p>\u4ee3\u7801\u4e2d\u7684 <code>LLM_BASE_URL<\/code> \u4f7f\u7528\u7edf\u4e00\u7f51\u5173\u5730\u5740\uff0c\u4e1a\u52a1\u4ee3\u7801\u4e0d\u5fc5\u7ed1\u5b9a\u67d0\u4e00\u4e2a\u6a21\u578b\u5382\u5546\u7684 SDK\u3002\u7528\u6237\u53ea\u7533\u8bf7\u4e00\u4e2a API Key\uff0c\u5373\u53ef\u5728\u7f51\u5173\u5c42\u8c03\u7528 GPT\u3001Claude\u3001Gemini\u3001Grok \u7b49\u591a\u4e2a\u6a21\u578b\uff1b\u5177\u4f53\u53ef\u7528\u6a21\u578b\u3001\u6743\u9650\u548c\u8ba1\u8d39\u65b9\u5f0f\u5e94\u4ee5\u5b9e\u9645\u7f51\u5173\u914d\u7f6e\u4e3a\u51c6\u3002<\/p>\n<p>\u5bf9\u4e8e\u9700\u8981\u7edf\u4e00\u9274\u6743\u3001\u9879\u76ee\u5206\u8d26\u6216\u591a\u6a21\u578b\u8def\u7531\u7684\u56e2\u961f\uff0c\u53ef\u7ed3\u5408<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/10\/30\/llm-api-unified-gateway-authentication-best-practices\/\">\u5927\u6a21\u578bAPI\u7edf\u4e00\u7f51\u5173\u9274\u6743\u8ba4\u8bc1\u6700\u4f73\u5b9e\u8df5<\/a>\u8bbe\u8ba1\u5bc6\u94a5\u548c\u6743\u9650\u4f53\u7cfb\u3002<\/p>\n<h2>\u5982\u4f55\u5904\u7406\u56de\u8c03\u8d85\u65f6\u4e0e\u5f02\u6b65\u56de\u590d\uff1f<\/h2>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u56de\u8c03\u63a5\u53e3\u4e0d\u9002\u5408\u957f\u65f6\u95f4\u7b49\u5f85\u6a21\u578b\u751f\u6210\u3002\u5982\u679c\u6a21\u578b\u54cd\u5e94\u8f83\u6162\uff0c\u63a8\u8350\u91c7\u7528\u201c\u5feb\u901f\u786e\u8ba4+\u5f02\u6b65\u751f\u6210+\u4e3b\u52a8\u56de\u590d\u201d\u7684\u6a21\u5f0f\uff1a<\/p>\n<ol>\n<li>\u56de\u8c03\u63a5\u53e3\u7acb\u5373\u5b8c\u6210\u9a8c\u7b7e\u3001\u89e3\u5bc6\u548c\u6d88\u606f\u5165\u961f\u3002<\/li>\n<li>\u540e\u53f0\u4efb\u52a1\u8c03\u7528\u5927\u6a21\u578b API\u3002<\/li>\n<li>\u751f\u6210\u7ed3\u679c\u540e\uff0c\u4f7f\u7528 <code>response_url<\/code> \u56de\u590d\u7528\u6237\u3002<\/li>\n<li>\u5bf9\u540c\u4e00\u6d88\u606f\u8bbe\u7f6e\u552f\u4e00 ID\uff0c\u907f\u514d\u91cd\u8bd5\u9020\u6210\u91cd\u590d\u56de\u7b54\u3002<\/li>\n<\/ol>\n<p>\u5b9e\u8df5\u4e2d\u6700\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u662f\u5e42\u7b49\u6027\u3002\u53ef\u4ee5\u4f7f\u7528\u201c\u673a\u5668\u4eba ID+\u7528\u6237 ID+\u6d88\u606f ID\u201d\u4f5c\u4e3a\u4e1a\u52a1\u952e\uff0c\u5c06\u5904\u7406\u72b6\u6001\u8bb0\u5f55\u4e3a <code>received<\/code>\u3001<code>processing<\/code>\u3001<code>completed<\/code>\u3002\u8fd9\u6837\u5373\u4f7f\u4f01\u4e1a\u5fae\u4fe1\u91cd\u590d\u63a8\u9001\uff0c\u4e5f\u4e0d\u4f1a\u91cd\u590d\u6d88\u8017\u6a21\u578b\u989d\u5ea6\u3002<\/p>\n<p>\u5982\u679c\u9047\u5230 429 \u6216\u7f51\u5173\u8d85\u65f6\uff0c\u5e94\u91c7\u7528\u6307\u6570\u9000\u907f\u548c\u968f\u673a\u6296\u52a8\uff0c\u800c\u4e0d\u662f\u7acb\u5373\u65e0\u9650\u91cd\u8bd5\u3002\u53ef\u53c2\u8003<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/10\/04\/llm-429-retry\/\">\u5927\u6a21\u578b\u63a5\u53e3\u8c03\u7528\u9519\u8bef\u7801429\u81ea\u52a8\u91cd\u8bd5\u7b56\u7565<\/a>\u4e0e<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/10\/22\/llm-504-timeout\/\">504 \u7f51\u5173\u8d85\u65f6\u5904\u7406\u6307\u5357<\/a>\u3002<\/p>\n<figure class=\"wp-block-image size-large\" style=\"margin:1.5em 0;\"><img decoding=\"async\" src=\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/10\/backend-8910-2.jpg\" alt=\"\u4f01\u4e1a\u5fae\u4fe1\u56de\u8c03\u3001\u6a21\u578b\u8bf7\u6c42\u4e0e\u4e3b\u52a8\u56de\u590d\u7684\u65f6\u5e8f\u56fe\" style=\"max-width:100%;height:auto;\"><\/figure>\n<h2>\u591a\u6a21\u578b API \u805a\u5408\u5e73\u53f0\u5982\u4f55\u63a5\u5165\uff1f<\/h2>\n<p>\u8fd9\u7c7b\u5e73\u53f0\u901a\u5e38\u5206\u4e3a\u4e24\u79cd\uff1a<\/p>\n<ol>\n<li><strong>\u6b63\u89c4 API \u805a\u5408\u6216\u7f51\u5173<\/strong>\uff1a\u7528\u6237\u7ed1\u5b9a\u81ea\u5df1\u7684\u6a21\u578b\u5382\u5546 Key\uff0c\u5e73\u53f0\u8d1f\u8d23\u7edf\u4e00\u8f6c\u53d1\u3001\u8ba1\u8d39\u3001\u76d1\u63a7\u548c\u6743\u9650\u7ba1\u7406\u3002<\/li>\n<li><strong>\u7b2c\u4e09\u65b9\u6a21\u578b\u4e2d\u8f6c\u670d\u52a1<\/strong>\uff1a\u5e73\u53f0\u91c7\u8d2d\u6216\u4ee3\u7406\u6a21\u578b\u989d\u5ea6\uff0c\u518d\u5411\u7528\u6237\u63d0\u4f9b\u7edf\u4e00 API\u3002<\/li>\n<\/ol>\n<p>\u4e24\u7c7b\u670d\u52a1\u7684\u6388\u6743\u8fb9\u754c\u3001\u7a33\u5b9a\u6027\u3001\u6570\u636e\u5904\u7406\u65b9\u5f0f\u548c\u6545\u969c\u8d23\u4efb\u5e76\u4e0d\u76f8\u540c\u3002\u4f01\u4e1a\u63a5\u5165\u524d\u5e94\u91cd\u70b9\u786e\u8ba4\uff1a<\/p>\n<ul>\n<li>\u662f\u5426\u652f\u6301 OpenAI \u517c\u5bb9\u683c\u5f0f\uff1b<\/li>\n<li>Base URL\u3001\u6a21\u578b\u540d\u548c\u9274\u6743\u65b9\u5f0f\u662f\u5426\u660e\u786e\uff1b<\/li>\n<li>\u662f\u5426\u80fd\u67e5\u770b\u8bf7\u6c42\u65e5\u5fd7\u548c\u9519\u8bef\u7801\uff1b<\/li>\n<li>\u662f\u5426\u652f\u6301\u6309\u9879\u76ee\u6216\u6210\u5458\u5206\u914d\u989d\u5ea6\uff1b<\/li>\n<li>\u662f\u5426\u8bf4\u660e\u6570\u636e\u7559\u5b58\u3001\u9690\u79c1\u548c\u6a21\u578b\u5382\u5546\u8f6c\u53d1\u5173\u7cfb\uff1b<\/li>\n<li>\u662f\u5426\u63d0\u4f9b\u6b63\u5f0f\u7684\u670d\u52a1\u6761\u6b3e\u548c\u5408\u89c4\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p>nTokenX\u7684\u54c1\u724c\u4e8b\u5b9e\u8303\u56f4\u5185\uff0c\u652f\u6301\u7528\u6237\u7533\u8bf7\u4e00\u4e2a API Key\uff0c\u8c03\u7528 GPT\u3001Claude\u3001Gemini\u3001Grok \u7b49\u591a\u4e2a\u6a21\u578b\u3002\u91c7\u7528\u7edf\u4e00\u7f51\u5173\u65f6\uff0c\u5efa\u8bae\u5728\u4e1a\u52a1\u4ee3\u7801\u4e2d\u53ea\u4fdd\u7559\u6807\u51c6\u63a5\u53e3\u5c42\uff0c\u5c06\u6a21\u578b\u5207\u6362\u653e\u5230\u73af\u5883\u53d8\u91cf\u6216\u914d\u7f6e\u4e2d\u5fc3\uff0c\u51cf\u5c11\u540e\u7eed\u6539\u9020\u6210\u672c\u3002<\/p>\n<h2>\u5e38\u89c1\u95ee\u9898<\/h2>\n<h3>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u4e00\u5b9a\u8981\u516c\u7f51\u670d\u52a1\u5668\u5417\uff1f<\/h3>\n<p>URL \u56de\u8c03\u6a21\u5f0f\u9700\u8981\u4f01\u4e1a\u5fae\u4fe1\u80fd\u591f\u8bbf\u95ee\u56de\u8c03\u5730\u5740\uff0c\u56e0\u6b64\u901a\u5e38\u9700\u8981\u516c\u7f51\u53ef\u8bbf\u95ee\u7684 HTTPS \u670d\u52a1\u3002\u82e5\u4f7f\u7528\u957f\u8fde\u63a5\u6a21\u5f0f\uff0c\u7f51\u7edc\u67b6\u6784\u548c\u90e8\u7f72\u8981\u6c42\u4e0d\u540c\uff0c\u5e94\u6309\u4f01\u4e1a\u5fae\u4fe1\u540e\u53f0\u63d0\u4f9b\u7684\u8fde\u63a5\u65b9\u5f0f\u914d\u7f6e\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u4fdd\u5b58\u56de\u8c03\u914d\u7f6e\u65f6\u63d0\u793a\u9a8c\u8bc1\u5931\u8d25\uff1f<\/h3>\n<p>\u4f18\u5148\u68c0\u67e5\u56db\u9879\uff1aURL \u662f\u5426\u53ef\u8bbf\u95ee\u3001GET \u8bf7\u6c42\u662f\u5426\u653e\u884c\u3001Token \u662f\u5426\u5b8c\u5168\u4e00\u81f4\u3001EncodingAESKey \u662f\u5426\u590d\u5236\u5b8c\u6574\u3002\u8fd8\u8981\u786e\u8ba4\u53cd\u5411\u4ee3\u7406\u6ca1\u6709\u6539\u5199\u67e5\u8be2\u53c2\u6570\u6216\u8bf7\u6c42\u4f53\u3002<\/p>\n<h3>\u6a21\u578b\u8fd4\u56de\u4e86\u7ed3\u679c\uff0c\u4f46\u4f01\u4e1a\u5fae\u4fe1\u6ca1\u6709\u663e\u793a\uff1f<\/h3>\n<p>\u68c0\u67e5 <code>response_url<\/code> \u662f\u5426\u88ab\u91cd\u590d\u4f7f\u7528\u3001\u56de\u590d JSON \u7684 <code>msgtype<\/code> \u662f\u5426\u6b63\u786e\u3001\u6587\u672c\u662f\u5426\u8d85\u8fc7\u63a5\u53e3\u9650\u5236\uff0c\u4ee5\u53ca\u670d\u52a1\u7aef\u662f\u5426\u5728\u540e\u53f0\u4efb\u52a1\u4e2d\u6355\u83b7\u4e86\u5f02\u5e38\u3002<\/p>\n<h3>\u5982\u4f55\u907f\u514d\u628a\u7528\u6237\u9690\u79c1\u53d1\u9001\u7ed9\u6a21\u578b\uff1f<\/h3>\n<p>\u5728\u8c03\u7528\u6a21\u578b\u524d\u8fdb\u884c\u5b57\u6bb5\u8131\u654f\uff0c\u4f8b\u5982\u79fb\u9664\u624b\u673a\u53f7\u3001\u8eab\u4efd\u8bc1\u53f7\u3001\u5ba2\u6237\u7f16\u53f7\u548c\u5185\u90e8\u5bc6\u94a5\u3002\u5bf9\u4f01\u4e1a\u5185\u90e8\u673a\u5668\u4eba\uff0c\u8fd8\u5e94\u9650\u5236\u53ef\u4f7f\u7528\u6210\u5458\u8303\u56f4\uff0c\u5e76\u8bbe\u7f6e\u65e5\u5fd7\u4fdd\u7559\u5468\u671f\u548c\u8bbf\u95ee\u6743\u9650\u3002<\/p>\n<h3>\u7edf\u4e00\u7f51\u5173\u548c\u76f4\u63a5\u8c03\u7528\u6a21\u578b\u5382\u5546\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h3>\n<p>\u76f4\u63a5\u8c03\u7528\u901a\u5e38\u9700\u8981\u5206\u522b\u7ba1\u7406\u4e0d\u540c\u5382\u5546\u7684 Key\u3001SDK\u3001\u9519\u8bef\u7801\u548c\u8d26\u5355\u3002\u7edf\u4e00\u7f51\u5173\u5219\u5c06\u9274\u6743\u3001\u6a21\u578b\u8def\u7531\u3001\u7edf\u8ba1\u548c\u914d\u989d\u96c6\u4e2d\u5904\u7406\uff0c\u4f46\u4ecd\u9700\u6838\u9a8c\u5e73\u53f0\u7684\u6388\u6743\u3001\u6570\u636e\u5b89\u5168\u4e0e\u670d\u52a1\u7a33\u5b9a\u6027\u3002<\/p>\n<figure class=\"wp-block-image size-large\" style=\"margin:1.5em 0;\"><img decoding=\"async\" src=\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/10\/backend-8910-3.jpg\" alt=\"\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u540e\u7684\u6d88\u606f\u5904\u7406\u6d41\u7a0b\u793a\u610f\u56fe\" style=\"max-width:100%;height:auto;\"><\/figure>\n<p>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\u7684\u5173\u952e\uff0c\u4e0d\u662f\u628a\u4e00\u6bb5\u6a21\u578b\u8c03\u7528\u4ee3\u7801\u5d4c\u5165\u56de\u8c03\u63a5\u53e3\uff0c\u800c\u662f\u5efa\u7acb\u53ef\u9a8c\u8bc1\u3001\u53ef\u91cd\u8bd5\u3001\u53ef\u5ba1\u8ba1\u7684\u6d88\u606f\u5904\u7406\u94fe\u8def\u3002\u63a8\u8350\u5148\u7528\u4e00\u4e2a\u6a21\u578b\u5b8c\u6210\u6700\u5c0f\u95ed\u73af\uff0c\u518d\u9010\u6b65\u589e\u52a0\u591a\u6a21\u578b\u8def\u7531\u3001\u6743\u9650\u63a7\u5236\u3001\u9884\u7b97\u9650\u5236\u548c\u65e5\u5fd7\u76d1\u63a7\u3002<\/p>\n<p><script type=\"application\/ld+json\">\n{\"@context\":\"https:\/\/schema.org\",\"@type\":\"Article\",\"author\":{\"@type\":\"Organization\",\"name\":\"nTokenX\"},\"dateModified\":\"2026-10-31\",\"datePublished\":\"2026-10-31\",\"description\":\"\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\u5b8c\u6574\u6307\u5357\uff0c\u6db5\u76d6URL\u56de\u8c03\u3001\u6d88\u606f\u89e3\u5bc6\u3001\u7edf\u4e00\u7f51\u5173\u8c03\u7528\u3001\u5f02\u6b65\u56de\u590d\u4e0e\u6392\u9519\u4ee3\u7801\uff0c\u5e2e\u52a9\u56e2\u961f\u5feb\u901f\u642d\u5efa\u53ef\u7ef4\u62a4\u7684AI\u673a\u5668\u4eba\u3002\",\"headline\":\"\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\uff1aWebhook\u4e0e\u4ee3\u7801\u5b9e\u6218 | nTokenX\",\"image\":\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/10\/art-13260-cover.jpg\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"nTokenX\"}}\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u63a5\u5165\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5f00\u53d1\u5b8c\u6574\u6307\u5357\uff0c\u6db5\u76d6URL\u56de\u8c03\u3001\u6d88\u606f\u89e3\u5bc6\u3001\u7edf\u4e00\u7f51\u5173\u8c03\u7528\u3001\u5f02\u6b65\u56de\u590d\u4e0e\u6392\u9519\u4ee3\u7801\uff0c\u5e2e\u52a9\u56e2\u961f\u5feb\u901f\u642d\u5efa\u53ef\u7ef4\u62a4\u7684AI\u673a\u5668\u4eba\u3002<\/p>\n","protected":false},"author":1,"featured_media":434,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-435","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=435"}],"version-history":[{"count":0,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/435\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/434"}],"wp:attachment":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}