错误信息: 堆栈信息: AI_APICallError at /Applications/Cherry Studio.app/Contents/Resource...

2026年08月06日 16:30 27.54 秒 success

错误信息

错误名称: AI_APICallError 错误信息: 堆栈信息: AI_APICallError at /Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:52165:12 at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async postToApi$2 (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:52080:25) at async GoogleGenerativeAILanguageModel.doStream (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:158145:68) at async wrapStream (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:268739:19) at async fn (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:61695:18) at async /Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:56251:19 at async _retryWithExponentialBackoff (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:56435:10) at async streamStep (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:61664:110) at async fn (/Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:61981:6) at async /Applications/Cherry Studio.app/Contents/Resources/app.asar/out/main/main.js:56251:19 状态码: 401 请求路径: https://aihubmix.com/gemini/v1beta/models/gemini-3.1-pro-preview:streamGenerateContent?alt=sse 请求体: {"generationConfig":{},"contents":[{"role":"user","parts":[{"text":"镜头 1|水景与主楼入口\n画面:入口景观喷泉与“金成府”标志\n旁白:住金成府,回家就是舒服。\n镜头 2|小区整体航拍\n画面:小区整体及楼栋分布大景\n旁白:208号楼在园区正中间。\n镜头 3|楼栋位置与周边环境\n画面:208#楼栋特写,展示前不临路、无切角的位置\n旁白:背靠山不临路,静谧聚财。\n镜头 4|跑道与绿化细节\n画面:蓝色跑道与绿植近景\n旁白:楼下就是跑道,散步舒心。\n镜头 5|大楼间距与采光\n画面:楼间距推镜及阳光洒落画面\n旁白:超大楼间距,全天有阳光。\n镜头 6|园林核心景观\n画面:园区中央休闲空间与绿化景观\n旁白:4800平绿化,享楼王同景。\n镜头 7|东西两侧视野\n画面:从高处向东西两侧远眺的景观视野\n旁白:东西视野好,通风真顺畅。\n镜头 8|园区通道与出入口\n画面:通往西门、北门的便捷路径\n旁白:紧邻西北门,出行超方便。\n镜头 9|独立电梯厅与入户\n画面:独立电梯厅及入户门空间展示\n旁白:独立电梯厅,私密又安静。\n镜头 10|室内空间与格局\n画面:通透奢阔的室内客厅及开阔样板间展示\n旁白:120平享受150平大空间。\n镜头 11|高层建筑仰拍收尾\n画面:仰拍208#楼栋挺拔全貌及天空\n旁白:限量36户,绝版手慢无!\n\n根据画面优化一下每句旁白文案 每句字数不能超过12个字"}]}],"systemInstruction":{"parts":[{"text":"你是一位资深的房地产文案与营销策划专家。你的专属任务是为【唐山金隅金成府】项目撰写各类宣传文案、社交媒体推文和活动策划案。\n\n文案需富有创意和感染力;策划案需逻辑清晰、具备实操性。\n请根据我的具体指令灵活调整风格,直接输出高质量内容,无需过多解释。\n输出的文案要求符合广告法,禁止使用极限词\n"}]},"safetySettings":[{"category":"HARM_CATEGORY_HATE_SPEECH","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_DANGEROUS_CONTENT","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_HARASSMENT","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_SEXUALLY_EXPLICIT","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_CIVIC_INTEGRITY","threshold":"BLOCK_NONE"}],"tools":[{"functionDeclarations":[{"name":"fs_read","description":"Read a text file by absolute path.\n\nPrimary use: retrieving the full content behind a <persisted-output> marker — call with the path shown after \"Full output saved to:\". Markers from earlier turns work too (persisted outputs live as long as their message does). Only paths from this conversation's markers are readable; reads elsewhere return access-denied.\n\nPagination is line-based: pass `offset` (1-indexed line) + `limit` for large files; results include `totalLines`. Lines are returned in full (never truncated mid-line); the per-call output is bounded as a whole, and oversized pages return an `output-too-large` error with a file-specific recommended `limit`. The one input it can't subdivide is a single physical line larger than that cap (e.g. heavily minified JSON) — line paging can't split one line and there is no byte-range read, so that case is reported as `output-too-large`; reason from the inline head/tail excerpt for such inputs.\n\nWhen reading a persisted output to summarize, analyze, or act on it, read sequential pages (advance `offset` to the returned `endLine` + 1) until you have covered 100% of the content. Before summarizing or drawing conclusions, state what fraction you actually read — and if you did not read all of it (including the single-oversized-line case), say so explicitly rather than implying full coverage.\n\nThe persistence layer applies to non-read tools only; this tool never persists its own output — narrow the read (smaller `limit`) instead.","parameters":{"required":["path"],"type":"object","properties":{"path":{"description":"Absolute file path. Relative paths are rejected.","type":"string","minLength":1},"offset":{"description":"1-indexed line number to start reading at. Default: 1.","type":"integer"},"limit":{"description":"Maximum number of lines to return. Default: 2000. No schema upper bound — the per-call output cap (the configured tool-output threshold, 50000 chars by default) is the real gate; an oversized page reports the exact cap and a recommended limit.","type":"integer"}}}}]}],"toolConfig":{"functionCallingConfig":{"mode":"AUTO"}}} 响应首部: { "alt-svc": "h3=\":443\"; ma=2592000", "content-length": "159", "content-type": "application/json; charset=utf-8", "date": "Thu, 06 Aug 2026 08:28:35 GMT", "document-policy": "include-js-call-stacks-in-crash-reports", "via": "1.1 google", "x-aihubmix-request-id": "2026080608283532031448686770818" } 响应内容: {"error":{"message":"Failed to retrieve token - invalid or expired API key (tid: 2026080608283532031448686770818)","type":"Aihubmix_api_error"},"type":"error"}

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:Failed to retrieve token - invalid or expired API key (tid: 2026080608283532031448686770818)
译文:获取Token失败 - API密钥无效或已过期(事务ID:2026080608283532031448686770818)

2. 🎯 原因分析


  • 根本原因:API密钥无效或已过期,导致身份验证失败,服务端返回401未授权状态码

  • 错误位置postToApi$2函数中发起API调用时,在GoogleGenerativeAILanguageModel.doStream流程中触发

  • 上下文:应用尝试调用Google Gemini API(通过AIhubmix代理),但配置的API密钥无法通过身份验证
  • 3. 💡 解决方案


  • 核心修复步骤:更新或更换有效的API密钥
  • // 在应用的API配置模块中,更新有效的API密钥
    // 例如(根据实际配置位置修改):
    const API_CONFIG = {
      // 确保以下配置项使用有效的密钥
      apiKey: '你的有效_AIHUBMIX_API_KEY_HERE',
      baseUrl: 'https://aihubmix.com/gemini/v1beta'
    };
    

    具体操作

  • 登录AIhubmix平台,进入「API密钥」管理页面

  • 检查现有密钥状态,若过期则重新生成新密钥

  • 将新密钥替换到Cherry Studio的配置中(通常在设置页面的API配置或模型服务配置处)

  • 重启Cherry Studio后重试调用
  • 4. 🛡️ 预防措施


  • 密钥管理最佳实践:使用环境变量或配置文件集中管理API密钥,避免硬编码在代码中,方便统一更新,推荐使用dotenv等工具进行配置管理

  • 密钥有效性监控:在开发和生产环境中,添加密钥有效性的前置校验逻辑(如启动时调用一次密钥验证接口),提前发现过期或无效密钥,避免影响核心业务逻辑;可使用Postman定期自动测试API密钥有效性

  • 密钥过期提醒:在平台中开启密钥过期通知,及时续期或更换密钥,避免服务中断