400 The supported API model names are deepseek-flash, deepseek-v4-pro, but you p...

2026年10月22日 10:27 15.54 秒 success

错误信息

API Error: 400 The supported API model names are deepseek-flash, deepseek-v4-pro, but you passed qwen3.7-plus. (request_id: d13dc3e6-27f0-429e-ba17-e7232bde49e8)

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:API Error: 400 The supported API model names are deepseek-flash, deepseek-v4-pro, but you passed qwen3.7-plus. (request_id: d13dc3e6-27f0-429e-ba17-e7232bde49e8)
译文:API错误:400 支持的API模型名称为deepseek-flash和deepseek-v4-pro,但您传入的是qwen3.7-plus。

2. 🎯 原因分析


  • 根本原因:调用API时传入了平台不支持的模型名称 qwen3.7-plus

  • 错误位置:API请求的模型参数配置处

  • 上下文:当前DMXAPI平台仅支持 deepseek-flash 和 deepseek-v4-pro 两个模型,传入未授权的模型名称导致请求被拒绝
  • 3. 💡 解决方案


    将模型参数替换为平台支持的模型名称:

    // 错误写法
    const response = await fetch("https://api.dmxapi.com/v1/chat/completions", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY"
      },
      body: JSON.stringify({
        model: "qwen3.7-plus",  // ❌ 不支持的模型
        messages: [{ role: "user", content: "你好" }]
      })
    });
    
    // 正确写法
    const response = await fetch("https://api.dmxapi.com/v1/chat/completions", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY"
      },
      body: JSON.stringify({
        model: "deepseek-v4-pro",  // ✅ 使用支持的模型
        messages: [{ role: "user", content: "你好" }]
      })
    });
    

    4. 🛡️ 预防措施


  • 模型白名单校验:在请求前先校验传入的模型名称是否在平台支持列表中,避免无效请求

  • 动态获取模型列表:通过平台提供的模型查询接口获取最新支持的模型,不硬编码模型名称,提升兼容性