**ERROR**: AUTH_ERROR – AsyncCompletions.create() got an unexpected keyword argument ‘images’

用户在通过 MCP (OpenAI) 客户端连接 RAGFlow 服务时触发该错误。访问地址类似 http://192.168.3.80:9380/api/v1/openai/{api_key}/chat/completions 。RAGFlow 服务本身正常(返回 HTTP 200),API 密钥

**ERROR**: AUTH_ERROR - AsyncCompletions.create() got an unexpected keyword argument 'images'

**ERROR**: AUTH_ERROR – AsyncCompletions.create() got an unexpected keyword argument ‘images’

快速结论:该报错通常发生在通过 MCP(OpenAI 兼容接口)连接 RAGFlow 时,客户端传入了 images 参数,但 RAGFlow 将 images 作为关键字参数直接传递给 OpenAI Python SDK 的 chat.completions.create() 方法,而 SDK 要求将图片嵌入到 messages 参数的 content 中。优先排查 RAGFlow 服务端的 chat_model.py 是否缺少处理 images 参数的补丁。

问题场景

用户在通过 MCP (OpenAI) 客户端连接 RAGFlow 服务时触发该错误。访问地址类似 http://192.168.3.80:9380/api/v1/openai/{api_key}/chat/completions。RAGFlow 服务本身正常(返回 HTTP 200),API 密钥认证通过(无 401 错误),且聊天助理 chat_id 配置正确。

报错原文

**ERROR**: AUTH_ERROR - AsyncCompletions.create() got an unexpected keyword argument 'images'

原因分析

在 RAGFlow 的 chat_model.py 中,images 参数被作为关键字参数传递给了 chat.completions.create() 方法。OpenAI Python SDK 不支持 images 作为顶层关键字参数,图片应作为 messagesuser 角色消息的 content 数组中的 image_url 类型内容。这可能是因为 RAGFlow 的 Base 类中 _async_chat_streamly_async_chat 方法未正确处理 images 参数导致。

环境排查

  • 确认 RAGFlow 版本:触发该问题的版本为 v0.26.1
  • 检查 OpenAI Python SDK 版本,是否兼容当前的 images 参数传递方式。
  • 确认客户端是否在请求中传入了 images 参数(例如 MCP 工具可能自动添加)。

解决步骤

  1. 修改 RAGFlow 服务端 chat_model.py 文件,在 _async_chat_streamly 方法开始处(LINE 212-227 位置)添加处理 images 的逻辑:从 kwargs 中弹出 images 参数,调用 _inject_images_into_history 将图片注入到历史消息中。
  2. 添加 _inject_images_into_history 方法(LINE 610-645 位置),该方法将图片以 base64 或 URL 形式作为 image_url 嵌入到 user 角色消息的 content 数组中。
  3. 修改 _async_chat 方法(LINE 647-675 位置),应用相同的 images 处理逻辑,确保非流式调用也能正确处理图片参数。

注意:以上步骤基于 Issue 中提供的补丁方案。由于 Issue 作者未提供完整的重现步骤,此方案为推测性修复,可优先尝试应用此补丁。

验证方法

重新发送包含 images 参数的请求,观察是否不再出现 ERROR: AUTH_ERROR 报错,并确认 RAGFlow 正常返回聊天补全响应。

参考来源

infiniflow/ragflow #16305

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 10140

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注