tools are not supported when an image model is used through Responses

2026年10月15日 03:22 7.21 秒 success

错误信息

tools are not supported when an image model is used through Responses

AI 解决方案

原文:tools are not supported when an image model is used through Responses
译文:当通过 Responses 使用图像模型时,不支持使用 tools

🎯 原因分析


在使用 Responses API 调用图像模型时,系统限制了 tools(工具/函数调用)功能的使用。这是由于图像模型的设计用途是处理视觉内容生成或理解任务,而非执行工具调用逻辑,二者在功能架构上存在冲突。

💡 解决方案


移除调用图像模型时的 tools 参数,直接保留图像生成或处理的核心逻辑。

``代码语言

错误示例:图像模型中使用了 tools 参数


response = client.responses.create(
model="image-model-name",
input=[{"role": "user", "content": [{"type": "image", "image_url": "..."}]}],
tools=[{"type": "function", "function": {...}}] # 报错点:工具参数不被支持
)

正确示例:移除 tools 参数


response = client.responses.create(
model="image-model-name",
input=[{"role": "user", "content": [{"type": "image", "image_url": "..."}]}]
)
``

🛡️ 预防措施


  • 模型与功能匹配:调用前明确模型类型,图像模型专注于视觉任务,避免叠加不支持的功能参数。

  • 参数校验:通过 API 文档或 SDK 类型提示,提前确认模型支持的参数列表,剔除冲突参数。