400 'tools' is not supported by the model (request id: 20260902072237243122405c1...
错误信息
API Error: 400 'tools' is not supported by the model (request id: 20260902072237243122405c14228f5ITRKbZKv)
AI 解决方案
🔍 报错分析
1. 🌐 错误翻译
原文:API Error: 400 'tools' is not supported by the model (request id: 20260902072237243122405c14228f5ITRKbZKv)
译文:API错误:400 'tools' 不被模型支持(请求ID:20260902072237243122405c14228f5ITRKbZKv)
2. 🎯 原因分析
tools 功能,这是API版本与功能不匹配导致的参数错误。tools 参数,但该模型未集成工具调用能力,属于请求参数与模型能力不兼容的问题。3. 💡 解决方案
有两种解决方向,二选一即可:
#### 方案一:更换支持 tools 的模型
``代码语言`
// 更换为支持工具调用的模型,例如gpt-4-turbo等
const model = 'gpt-4-turbo'; // 替换原模型为支持tools的模型
const response = await client.chat.completions.create({
model,
// 保留其他正常参数,保留tools配置
tools: [yourToolsConfig],
messages: [yourMessages]
});
代码语言
#### 方案二:移除不支持的 `tools` 参数
// 直接删除tools相关配置,改为纯文本对话请求
const response = await client.chat.completions.create({
model: '原模型名称', // 保持原模型
// 移除tools配置
messages: [yourMessages]
});