] API错误 (404 ): { "error": { "message": "Invalid URL (POST /v1/responses/chat/co...
错误信息
[ERROR] API错误 (404 ):
{
"error": {
"message": "Invalid URL (POST /v1/responses/chat/completions)",
"type": "invalid_request_error",
"code": ""
}
}
[ERROR] LLM API调用失败: API接口未找到,请检查API地址
详细信息: {
"error": {
"message": "Invalid URL (POST /v1/responses/chat/completions)",
"type": "invalid_request_error",
"code": ""
}
}
[ERROR] LLM处理错误: API接口未找到,请检查API地址
详细信息: {
"error": {
"message": "Invalid URL (POST /v1/responses/chat/completions)",
"type": "invalid_request_error",
"code": ""
}
}
[ERROR] 错误堆栈: Error: API接口未找到,请检查API地址
详细信息: {
"error": {
"message": "Invalid URL (POST /v1/responses/chat/completions)",
"type": "invalid_request_error",
"code": ""
}
}
at handleAPIError (D:\my-neuro-main\my-neuro-main\live-2d\js\api-utils.js:96:11)
at async LLMClient.chatCompletion (D:\my-neuro-main\my-neuro-main\live-2d\js\ai\llm-client.js:84:17)
at async InputRouter.llmHandler (D:\my-neuro-main\my-neuro-main\live-2d\js\ai\llm-handler.js:258:34)
at async InputRouter.handleTextInput (D:\my-neuro-main\my-neuro-main\live-2d\js\ai\conversation\InputRouter.js:131:9)
[ERROR] 用户显示错误: 无效的API地址,请检查配置
AI 解决方案
报错分析报告
1.错误翻译
原文:Invalid URL (POST /v1/responses/chat/completions)
译文:无效URL(POST请求路径:/v1/responses/chat/completions)
2.原因分析
/responses层级),服务器无法识别该URL。js/ai/llm-client.js的chatCompletion方法)。3.解决方案
// 修复后的API调用代码(以Axios为例,路径需匹配DMXAPI官方文档)
async function chatCompletion(messages) {
try {
const response = await axios.post(
"https://api.dmxapi.com/v1/chat/completions", // 移除多余的/responses
{ model: "your-model", messages },
{ headers: { Authorization: `Bearer YOUR_API_KEY` } }
);
return response.data;
} catch (error) {
console.error("API错误:", error.response?.data || error.message);
}
}
注:最终路径以DMXAPI官方文档为准(常见正确路径为/v1/chat/completions)。4.️ 预防措施
---
请优先确认DMXAPI的最新端点文档,避免路径错误复发。