":{"message":"Invalid 'tools':array too long.Expected an array withmaximum lengt...
🚨 错误信息
{"error":{"message":"Invalid 'tools':array too long.Expected an array withmaximum length 128, but got an arraywith length 150 instead.(request id:202510221756342299880382TOEZ3bm)","type":"openai_error","param":","cOde":"array_above_max_length"]}
🤖 AI解决方案
{
"error": {
"message": "Invalid 'tools': array too long. Expected an array with maximum length 128, but got an array with length 150 instead. (request id:202510221756342299880382TOEZ3bm)",
"type": "openai_error",
"param": ",",
"code": "array_above_max_length"
}
}
核心关键句翻译:
"Invalid 'tools': array too long. Expected an array with maximum length 128, but got an array with length 150 instead." "无效的 'tools':数组过长。期望数组的最大长度为 128,但收到了长度为 150 的数组。"原因分析:
tools 参数传递的数组长度超过了 API 规定的最大值 128。
解决方案:
精简tools 数组,将其长度控制在 128 以内。检查并移除不必要的工具定义。
预防措施:
- 在调用 API 前,对
tools数组的长度进行校验,确保其不超过 128。 - 维护工具列表时,只保留实际使用的工具,避免冗余。