错误信息: Invalid Token (request id: 20260318110228257804819rZXN5tMr) 堆栈信息: AI_APICa...

2026年03月18日 11:02 状态: processing

🚨 错误信息

错误名称: AI_APICallError 错误信息: Invalid Token (request id: 20260318110228257804819rZXN5tMr) 堆栈信息: AI_APICallError: Invalid Token (request id: 20260318110228257804819rZXN5tMr) at file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/dist-C5yJPvrk.js:2082:11 at async postToApi (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/dist-C5yJPvrk.js:1977:24) at async OpenAICompatibleChatLanguageModel.doStream (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/dist-CeiCgJTm.js:451:48) at async wrapStream (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:55062:32) at async fn (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:53928:17) at async file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:50282:19 at async _retryWithExponentialBackoff (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:50445:10) at async streamStep (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:53897:109) at async fn (file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:54203:5) at async file:///D:/Users/%E8%B5%AB%E6%BD%87%E6%96%8C/AppData/Local/Programs/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-DDHJgx8G.js:50282:19 错误原因: "[undefined]" 状态码: 401 请求路径: https://www.dmxapi.cn/v1/chat/completions 请求体: { "model": "deepseek-v3.2-exp", "user": "[undefined]", "max_tokens": "[undefined]", "temperature": "[undefined]", "top_p": "[undefined]", "frequency_penalty": "[undefined]", "presence_penalty": "[undefined]", "response_format": "[undefined]", "stop": "[undefined]", "seed": "[undefined]", "reasoning_effort": "[undefined]", "verbosity": "[undefined]", "messages": [ { "role": "system", "content": "test" }, { "role": "user", "content": "hi" } ], "tools": "[undefined]", "tool_choice": "[undefined]", "stream": true, "stream_options": { "include_usage": true } } 响应首部: { "content-length": "116", "content-type": "application/json; charset=utf-8", "date": "Wed, 18 Mar 2026 03:02:28 GMT", "document-policy": "include-js-call-stacks-in-crash-reports", "server": "nginx", "x-rixapi-request-id": "20260318110228257804819rZXN5tMr" } 响应内容: { "error": { "code": "", "message": "Invalid Token (request id: 20260318110228257804819rZXN5tMr)", "type": "rix_api_error" } } 数据: { "error": { "message": "Invalid Token (request id: 20260318110228257804819rZXN5tMr)", "type": "rix_api_error", "code": "" } }

🤖 AI解决方案

报错分析报告

1.错误翻译



原文:Invalid Token
译文:无效的令牌

2. 原因分析


  • 根本原因:API请求使用的认证令牌(Token)无效或已过期,导致服务器拒绝访问(状态码401)。

  • 发生位置:调用DMXAPI的/v1/chat/completions接口时,未在请求头中携带有效Authorization信息(或Token错误)。
  • 3. 解决方案


    ``javascript
    // 修复后的Node.js/fetch示例(替换为有效Token)
    const API_KEY = "YOUR_VALID_DMXAPI_TOKEN"; // 从DMXAPI控制台获取新Token
    const response = await fetch("https://www.dmxapi.cn/v1/chat/completions", {
    method: "POST",
    headers: {
    "Content-Type": "application/json",
    "Authorization":
    Bearer ${API_KEY} // 关键:添加有效Token
    },
    body: JSON.stringify({
    model: "deepseek-v3.2-exp",
    messages: [
    {"role": "system", "content": "test"},
    {"role": "user", "content": "hi"}
    ],
    stream: true,
    stream_options: {"include_usage": true}
    })
    });
    `

    4.️ 预防措施


  • 最佳实践1:用环境变量(如.env文件)存储API Token,避免硬编码(推荐工具:dotenv库)。

  • 最佳实践2:定期校验Token有效性(如调用API的/auth/verify端点),过期前主动更新。
  • ---
    :请登录DMXAPI控制台重新生成有效Token,替换代码中的
    YOUR_VALID_DMXAPI_TOKEN`。