] API错误 (404 ): { "error": { "message": "Invalid URL (POST /v1/responses/chat/co...

2026年04月27日 18:33 processing

错误信息

[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.原因分析


  • 根本原因:API端点路径错误(多了/responses层级),服务器无法识别该URL。

  • 发生位置:代码中调用LLM API时使用了错误路径(如js/ai/llm-client.jschatCompletion方法)。
  • 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.️ 预防措施


  • 查文档确认端点:调用API前务必核对官方文档的正确URL路径;

  • 预测试接口:用Postman/curl先验证接口可用性,再集成代码。
  • ---
    请优先确认DMXAPI的最新端点文档,避免路径错误复发。