tools' is not supported by the model

2026年08月19日 13:49 15.30 秒 success

错误信息

tools' is not supported by the model

AI 解决方案

🔧 报错分析

1. 🌐 错误翻译


原文:'tools' is not supported by the model
译文:“tools”不被该模型支持

2. 🎯 原因分析


该错误表明当前使用的模型不支持tools功能(即函数调用或工具调用能力)。通常发生在以下场景:
  • 使用了不支持函数调用(Function Calling)的模型版本或类型

  • 向模型请求了工具调用,但模型不具备该能力

  • API调用时传入了不兼容的参数
  • 3. 💡 解决方案


    #### 方案一:更换支持工具调用的模型
    ``代码语言
    // 例如使用支持函数调用的模型(以实际API为准)
    const model = 'gpt-4' // 或 'claude-3-5-sonnet' 等支持工具调用的模型
    
    #### 方案二:移除工具调用,使用纯对话模式
    
    代码语言
    // 移除工具调用配置,仅保留普通对话参数
    const response = await client.chat.completions.create({
    model: 'gpt-3.5-turbo', // 基础对话模型
    messages: [
    { role: 'user', content: '你的提问内容' }
    ]
    // 不包含 tools 参数
    });
    `

    4. 🛡️ 预防措施


  • 确认模型能力:调用工具前,先查阅模型文档,确认是否支持函数调用或工具功能

  • 参数校验:使用API前先通过model.capabilities`等接口查询模型支持的功能,避免传入不支持的参数

  • 🔍 推荐工具:使用Postman或API测试工具验证参数兼容性,查看模型官方文档中的"能力支持"部分