快速结论:RAGFlow 升级到 v0.23.x 后,通过 Azure 直接添加的 OpenAI 模型调用时返回 404 Resource not found。优先排查异步聊天路径是否使用了 Azure 专用异步客户端 (AsyncAzureOpenAI) 代替通用 AsyncOpenAI。
适用环境:RAGFlow 镜像版本 f4da24b(对应 v0.23.x 系列);Azure OpenAI 服务;Python 环境未限定。
最快修复方案:Issue 已验证的修复是手动修改 rag/llm/chat_model.py 中的 AzureChat 类,将其 self.client 和 self.async_client 分别替换为 AzureOpenAI 和 AsyncAzureOpenAI,并传入正确的 azure_endpoint 和 api_version。或迁移至 LiteLLM 的 Azure-OpenAI provider(参考 PR #11934)。
注意事项:此方案需要直接修改源代码,升级后可能被覆盖;配置 api_key 需为 JSON 字符串(如 {"api_key": "YOUR_KEY", "api_version": "2024-02-01"})。LiteLLM 路径需确保模型前缀为 azure/。
问题场景
用户在 RAGFlow 中通过“Azure”方式添加 Azure OpenAI 模型(如 GPT-4、GPT-3.5-turbo),并在助手对话或检索中使用该模型时,出现 404 错误,模型无法正常响应。非 Azure 的 OpenAI(直接使用 OpenAI API)工作正常。
报错原文
ERROR: MODEL_ERROR - Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
原因分析
RAGFlow v0.23.x 中 AzureChat 实现(位于 rag/llm/chat_model.py)的异步调用路径仍使用通用的 AsyncOpenAI 客户端,该客户端不会构建 Azure 所需的部署 URL(格式为 /openai/deployments/{deployment}/...),也不会自动添加 api-version 参数。因此请求发送到错误的 API 路径,Azure 返回 404 “Resource not found”。
环境排查
- 确认 RAGFlow 版本是否为 f4da24b 或 v0.23.x 系列(可通过
docker images查看镜像 tag)。 - 检查
rag/llm/chat_model.py中AzureChat类的async_client是否为AsyncOpenAI类型(非 Azure 专用)。 - 确认 Azure 部署名称、API Key、API Version 是否与 Azure 门户中的实际资源一致。
- 可选:设置环境变量
OPENAI_LOG=debug或HTTPX_LOG_LEVEL=DEBUG查看实际发出的请求 URL。
解决步骤
- 备份原始文件
rag/llm/chat_model.py。 - 在文件头部添加导入:
from openai.lib.azure import AzureOpenAI, AsyncAzureOpenAI - 在
AzureChat.__init__方法中,将原有self.client = OpenAI(...)和self.async_client = AsyncOpenAI(...)替换为:self.client = AzureOpenAI( api_key=api_key, azure_endpoint=base_url, api_version=api_version ) self.async_client = AsyncAzureOpenAI( api_key=api_key, azure_endpoint=base_url, api_version=api_version )注意:
base_url应传入 Azure 的终结点(如https://YOUR_RESOURCE.openai.azure.com),api_version需设置为有效值(例如2024-02-01)。 - 保存文件并重启 RAGFlow 服务(或重建 Docker 容器)。
- 如果希望使用更稳定的 LiteLLM provider,可将模型类型改为
Azure-OpenAI(配置中模型名称前缀加azure/),并确保api_key为 JSON 格式。
验证方法
在 RAGFlow 对话框中发送一条消息给之前报错的 Azure 模型,确认不再出现 404 错误并能正常返回回答。若有日志,检查日志中请求路径是否包含 /openai/deployments/{deployment} 格式。
参考来源
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。
![[Question]: Failed to exec "uv sync --python 3.10 --all-extras " on linux manjaro.](https://www.chat-gpts.plus/wp-content/uploads/2026/07/6716-a2505e14-768x403.jpg)
![[Feature Request]: The absence of sandbox configuration and image in helm prevents the execution of code and adminServer, whereas they exist](https://www.chat-gpts.plus/wp-content/uploads/2026/07/12042-b1dc84a7-768x403.jpg)
