错误信息: upstream error: do request failed (request id: 20251207194529177348791uKF8...
🚨 错误信息
错误名称: AI_APICallError
错误信息: upstream error: do request failed (request id: 20251207194529177348791uKF8XPa7)
堆栈信息: AI_APICallError: upstream error: do request failed (request id: 20251207194529177348791uKF8XPa7)
at file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/dist-mVY8hbYS.js:5132:11
at async postToApi (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/dist-mVY8hbYS.js:5028:24)
at async OpenAICompatibleChatLanguageModel.doStream (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:241677:48)
at async wrapStream (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:38808:31)
at async fn (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:36993:17)
at async file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:34371:19
at async _retryWithExponentialBackoff (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:34473:10)
at async streamStep (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:36961:108)
at async fn (file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:37240:5)
at async file:///D:/Program%20Files/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-Z-tJeJfQ.js:34371:19
错误原因: "[undefined]"
状态码: 500
请求路径: https://www.dmxapi.cn/v1/chat/completions
请求体: {
"model": "gemini-2.5-pro-deepsearch",
"user": "[undefined]",
"max_tokens": "[undefined]",
"temperature": "[undefined]",
"top_p": "[undefined]",
"frequency_penalty": "[undefined]",
"presence_penalty": "[undefined]",
"response_format": "[undefined]",
"stop": "[undefined]",
"seed": "[undefined]",
"extra_body": {
"google": {
"thinking_config": {
"thinking_budget": 26240,
"include_thoughts": true
}
}
},
"serviceTier": "[undefined]",
"reasoning_effort": "[undefined]",
"verbosity": "[undefined]",
"messages": [
{
"role": "system",
"content": "In this environment you have access to a set of tools you can use to answer the user's question. \\\nYou can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.\n\n## Tool Use Formatting\n\nTool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:\n\n<tool_use>\n <name>{tool_name}</name>\n <arguments>{json_arguments}</arguments>\n</tool_use>\n\nThe tool name should be the exact name of the tool you are using, and the arguments should be a JSON object containing the parameters required by that tool. For example:\n<tool_use>\n <name>python_interpreter</name>\n <arguments>{\"code\": \"5 + 3 + 1294.678\"}</arguments>\n</tool_use>\n\nThe user will respond with the result of the tool use, which should be formatted as follows:\n\n<tool_use_result>\n <name>{tool_name}</name>\n <result>{result}</result>\n</tool_use_result>\n\nThe result should be a string, which can represent a file or any other output type. You can use this result as input for the next action.\nFor example, if the result of the tool use is an image file, you can use it in the next action like this:\n\n<tool_use>\n <name>image_transformer</name>\n <arguments>{\"image\": \"image_1.jpg\"}</arguments>\n</tool_use>\n\nAlways adhere to this format for the tool use to ensure proper parsing and execution.\n\n## Tool Use Examples\n\nHere are a few examples using notional tools:\n---\nUser: Generate an image of the oldest person in this document.\n\nA: I can use the document_qa tool to find out who the oldest person is in the document.\n<tool_use>\n <name>document_qa</name>\n <arguments>{\"document\": \"document.pdf\", \"question\": \"Who is the oldest person mentioned?\"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>document_qa</name>\n <result>John Doe, a 55 year old lumberjack living in Newfoundland.</result>\n</tool_use_result>\n\nA: I can use the image_generator tool to create a portrait of John Doe.\n<tool_use>\n <name>image_generator</name>\n <arguments>{\"prompt\": \"A portrait of John Doe, a 55-year-old man living in Canada.\"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>image_generator</name>\n <result>image.png</result>\n</tool_use_result>\n\nA: the image is generated as image.png\n\n---\nUser: \"What is the result of the following operation: 5 + 3 + 1294.678?\"\n\nA: I can use the python_interpreter tool to calculate the result of the operation.\n<tool_use>\n <name>python_interpreter</name>\n <arguments>{\"code\": \"5 + 3 + 1294.678\"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>python_interpreter</name>\n <result>1302.678</result>\n</tool_use_result>\n\nA: The result of the operation is 1302.678.\n\n---\nUser: \"Which city has the highest population , Guangzhou or Shanghai?\"\n\nA: I can use the search tool to find the population of Guangzhou.\n<tool_use>\n <name>search</name>\n <arguments>{\"query\": \"Population Guangzhou\"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>search</name>\n <result>Guangzhou has a population of 15 million inhabitants as of 2021.</result>\n</tool_use_result>\n\nA: I can use the search tool to find the population of Shanghai.\n<tool_use>\n <name>search</name>\n <arguments>{\"query\": \"Population Shanghai\"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>search</name>\n <result>26 million (2019)</result>\n</tool_use_result>\nAssistant: The population of Shanghai is 26 million, while Guangzhou has a population of 15 million. Therefore, Shanghai has the highest population.\n\n## Tool Use Available Tools\nAbove example were using notional tools that might not exist for you. You only have access to these tools:\n<tools>\n\n<tool>\n <name>builtin_web_search</name>\n <description>Web search tool for finding current information, news, and real-time data from the internet.\n\nThis tool has been configured with search parameters based on the conversation context:\n- Prepared queries: \"你好\n\"\n\nYou can use this tool as-is to search with the prepared queries, or provide additionalContext to refine or replace the search terms.</description>\n <arguments>\n {\"~standard\":{\"vendor\":\"zod\",\"version\":1},\"def\":{\"type\":\"object\",\"shape\":{\"additionalContext\":{\"~standard\":{\"vendor\":\"zod\",\"version\":1},\"def\":{\"type\":\"optional\",\"innerType\":{\"~standard\":{\"vendor\":\"zod\",\"version\":1},\"def\":{\"type\":\"string\"},\"type\":\"string\",\"format\":null,\"minLength\":null,\"maxLength\":null}},\"type\":\"optional\"}}},\"type\":\"object\"}\n </arguments>\n</tool>\n\n</tools>\n\n## Tool Use Rules\nHere are the rules you should always follow to solve your task:\n1. Always use the right arguments for the tools. Never use variable names as the action arguments, use the value instead.\n2. Call a tool only when needed: do not call the search agent if you do not need information, try to solve the task yourself.\n3. If no tool call is needed, just answer the question directly.\n4. Never re-do a tool call that you previously did with the exact same parameters.\n5. For tool use, MAKE SURE use XML tag format as shown in the examples above. Do not use any other format.\n\n# User Instructions\n\n\nNow Begin! If you solve the task correctly, you will receive a reward of $1,000,000."
},
{
"role": "user",
"content": "你好"
}
],
"tools": "[undefined]",
"tool_choice": "[undefined]",
"stream": true,
"stream_options": {
"include_usage": true
}
}
响应首部: {
"cache-control": "no-cache",
"content-type": "text/event-stream",
"date": "Sun, 07 Dec 2025 11:45:29 GMT",
"document-policy": "include-js-call-stacks-in-crash-reports",
"server": "nginx",
"x-rixapi-request-id": "20251207194529177348791uKF8XPa7"
}
响应内容: {
"error": {
"message": "upstream error: do request failed (request id: 20251207194529177348791uKF8XPa7)",
"type": "rix_api_error",
"param": "",
"code": "do_request_failed"
}
}
数据: {
"error": {
"message": "upstream error: do request failed (request id: 20251207194529177348791uKF8XPa7)",
"type": "rix_api_error",
"param": "",
"code": "do_request_failed"
}
}
🤖 AI解决方案
错误分析
错误翻译
原文:upstream error: do request failed
译文:上游错误:请求执行失败
原因分析
这是一个API调用上游错误,主要问题出现在:- 请求参数异常:请求体中的多个关键参数值为
"[undefined]"(字符串形式),而不是真正的undefined或有效值 - 服务端处理失败:DMXAPI平台在处理包含无效参数的请求时,上游服务无法正常响应
- HTTP状态码500:表明是服务器内部错误,而非客户端问题
解决方案
// 修复后的请求体配置
const requestBody = {
"model": "gemini-2.5-pro-deepsearch",
"messages": [
{
"role": "system",
"content": "你的系统提示词内容..."
},
{
"role": "user",
"content": "你好"
}
],
"stream": true,
"stream_options": {
"include_usage": true
},
"extra_body": {
"google": {
"thinking_config": {
"thinking_budget": 26240,
"include_thoughts": true
}
}
}
// 移除所有值为 "[undefined]" 的参数
};
// 或者显式设置默认值
const fixedRequestBody = {
...requestBody,
"temperature": 0.7, // 设置合理的默认值
"max_tokens": 2048, // 设置合理的默认值
"top_p": 1.0 // 设置合理的默认值
};
️ 预防措施
"[undefined]"建议:检查生成请求体的代码逻辑,确保正确处理可选参数的默认值设置。