code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'cod...

2026年06月08日 08:40 25.59 秒 success

错误信息

[2026-06-08 08:38:50.944] [Core] [ERRO] [v4.25.5] [core.astr_main_agent:1000]: Failed to generate webchat title for session 1c245e41-6aad-4f25-be57-ad81eca8ef59: Error code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'code': 'bad_response_status_code'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/astr_main_agent.py", line 988, in _handle_webchat llm_resp = await prov.text_chat( ^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1286, in text_chat ) = await self._handle_api_error( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1232, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1274, in text_chat llm_response = await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 639, in _query completion = await self.client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2814, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1931, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1716, in request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'code': 'bad_response_status_code'}} [2026-06-08 08:38:50.960] [Core] [WARN] [v4.25.5] [runners.tool_loop_agent_runner:554]: Chat Model openai/M2-her request error: Error code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'code': 'bad_response_status_code'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 509, in _iter_llm_responses_with_fallback async for attempt in retrying: File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 170, in __anext__ do = await self.iter(retry_state=self._retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 393, in <lambda> self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 513, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses( File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 473, in _iter_llm_responses async for resp in stream: # type: ignore File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1358, in text_chat_stream ) = await self._handle_api_error( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1232, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1345, in text_chat_stream async for response in self._query_stream(payloads, func_tool): File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 691, in _query_stream stream = await self.client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2814, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1931, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1716, in request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'code': 'bad_response_status_code'}} [2026-06-08 08:38:50.966] [Core] [WARN] [v4.25.5] [result_decorate.stage:169]: 启用流式输出时,依赖发送消息前事件钩子的插件可能无法正常工作 [2026-06-08 08:38:50.967] [Core] [INFO] [result_decorate.stage:189]: 流式输出已启用,跳过结果装饰阶段

AI 解决方案

📊 报错分析

1. 🌐 错误翻译


原文:openai.NotFoundError: Error code: 404 - {'error': {'message': '', 'type': 'rix_api_error', 'param': '', 'code': 'bad_response_status_code'}}
译文:openai 未找到错误:错误代码 404 - {'错误': {'消息': '', '类型': 'rix_api错误', '参数': '', '代码': '错误的响应状态码'}}

2. 🎯 原因分析


根本原因是向OpenAI兼容API发送请求时,服务器返回了 HTTP 404 (Not Found) 错误。
具体分析:
  • 模型 M2-her 不可用:错误发生在使用模型 openai/M2-her 时。此模型名称在您配置的API端点(如DMXAPI)上不存在、已下线,或您的API密钥没有访问权限。

  • API端点或路径错误:请求的API地址可能不正确。404错误通常意味着服务器无法找到您请求的资源(端点或特定模型)。

  • 自定义服务端问题:错误类型 rix_api_error 表明这可能来自一个自定义或第三方API服务(而非标准的OpenAI服务),该服务内部处理时遇到了问题。
  • 3. 💡 解决方案


    请按顺序检查并修复:
    # 步骤1: 验证并修正模型名称
    # 在 AstrBot 的配置文件中,检查 provider 的 `model` 设置。
    # 将 'openai/M2-her' 更换为您所使用API服务(如DMXAPI)明确支持的模型ID。
    # 例如,对于 DMXAPI,可能需要使用 'gpt-3.5-turbo', 'gpt-4o' 等有效模型。
    provider:
      type: openai_source
      # ... 其他配置
      model: 'gpt-4o'  # 替换为有效的模型ID,例如 'gpt-3.5-turbo', 'gpt-4', 'gpt-4o' 等
    

    # 步骤2: 检查API配置
    # 确保 api_base (endpoint) 和 api_key 配置正确,指向了有效的服务地址和密钥。
    provider:
      type: openai_source
      # 如果是DMXAPI或其他中转服务,确保地址正确
      api_base: 'https://api.dmxai.com/v1'  # 请替换为您的实际API地址
      api_key: 'sk-xxxxxxxxxxxxxxxx'          # 确保密钥有效且有权访问所选模型
      model: 'gpt-4o'
    

    # 步骤3: (可选) 进行快速连通性测试
    # 您可以用一个简单的Python脚本测试API配置是否正确。
    import openai
    
    client = openai.OpenAI(
        api_key="your-api-key",
        base_url="https://api.dmxai.com/v1"  # 替换为你的API地址
    )
    
    try:
        response = client.chat.completions.create(
            model="gpt-3.5-turbo",  # 使用一个已知存在的模型
            messages=[{"role": "user", "content": "Hello"}]
        )
        print("API 连接成功,响应:", response.choices[0].message.content)
    except openai.NotFoundError as e:
        print(f"模型或端点未找到: {e}")
    except Exception as e:
        print(f"其他错误: {e}")
    

    4. 🛡️ 预防措施


  • 配置前验证:在修改配置文件或部署新模型前,使用工具(如Postman或上述Python脚本)直接调用API,确认端点、密钥和模型ID组合有效。

  • 启用并记录详细日志:在AstrBot或应用配置中开启更详细的日志级别(如DEBUG),可以帮助捕获更具体的错误信息,例如返回的完整HTTP响应体。

  • 实施优雅的错误处理与回退机制:在代码中,当首选模型调用失败时,应能自动回退到备用模型或返回友好的错误提示,避免整个功能中断。