status_code=400, The parameter `***.type` specified in the request are not valid...

2026年10月22日 11:12 11.57 秒 success

错误信息

status_code=400, The parameter `***.type` specified in the request are not valid: `The parameter `type` specified in the request are not valid: unknown tool type: tool_search.`.

AI 解决方案

🌐 错误翻译


原文:status_code=400, The parameter `***.type` specified in the request are not valid: `The parameter `type` specified in the request are not valid: unknown tool type: tool_search.`
译文:状态码=400,请求中指定的参数`***.type`无效:请求中指定的`type`参数无效:未知的工具类型:tool_search

🎯 原因分析


  • 根本原因:请求中传入了平台不支持的工具类型tool_search,导致参数校验失败

  • 具体位置:type字段的取值不符合API允许的工具类型规范,属于请求参数配置错误
  • 💡 解决方案


    // 修复后的工具类型配置(示例)
    const tools = [
      // 替换为平台支持的工具类型,例如function/search等
      {
        type: "function", 
        function: {
          name: "your_valid_tool",
          description: "有效的工具描述",
          parameters: { /* 正确的参数结构 */ }
        }
      }
    ];
    

    🛡️ 预防措施


  • ✅ 类型校验前置:调用API前,先对照官方文档确认支持的type取值范围,避免传入非法值

  • ✅ 动态配置校验:对工具类型等关键参数增加本地校验逻辑,拦截不支持的类型再发起请求