Skip to content

[Bug] NVIDIA Provider 测试连通性报错 "OpenAI completion has no choices" ——max_tokens 未正确写入请求 payload #9206

Description

@knight-de-ficus

What happened / 发生了什么

配置页面测试 nvidia/minimaxai/minimax-m3 时,测试连通性报错 "OpenAI completion has no choices. response_id="
实际对话时,调用该模型返回为空,报错见日志。

临时解决措施

此措施可以临时解决此bug:模型提供商 - nvidia/minimaxai/minimax-m3 - 自定义请求体参数 - 新键名max_tokens,值类型number - 指定为8192 - 保存

根因

NVIDIA NIM API 的Minimax模型要求请求体中必须包含 max_tokens(其他特定参数如 temperature未测试),否则返回空 choices

{
  "id": "",
  "choices": [],
  "created": 0,
  "model": "",
  "object": "chat.completion",
  "usage": null
}

而 AstrBot 的 test() 方法调用 text_chat 时,组装出的 payload 只包含 messagesmodel没有 max_tokens

Reproduce / 如何复现?

  1. 在 AstrBot Desktop 中添加 NVIDIA 提供商,模型选择 minimaxai/minimax-m3
  2. 点击「测试连通性」
  3. 报错 "OpenAI completion has no choices. response_id="

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot 版本: 4.26.4
部署方式: Astrbot Desktop,Windows版本
提供商: NVIDIA(type=openai_chat_completion),模型 nvidia/minimaxai/minimax-m3
消息平台: Astrbot Desktop

OS

Windows

Logs / 报错日志

报错现象

Image
[2026-07-11 13:19:21.348] [Core]
[INFO]
[core.event_bus:74]: [default] [webchat(webchat)] astrbot/astrbot: 你好 
[2026-07-11 13:19:21.367] [Core]
[INFO]
[respond.stage:206]: Prepare to send - astrbot/astrbot: 
[2026-07-11 13:19:21.367] [Core]
[INFO]
[respond.stage:222]: 应用流式输出(webchat)
[2026-07-11 13:19:22.343] [Core]
[WARN]
[v4.26.4] [runners.tool_loop_agent_runner:556]: Chat Model nvidia/minimaxai/minimax-m3 request error: Internal server error
Traceback (most recent call last):
  File "\\?\E:\Astrbot\backend\app\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 511, in _iter_llm_responses_with_fallback
    async for attempt in retrying:
  File "E:\Astrbot\backend\python\Lib\site-packages\tenacity\asyncio\__init__.py", line 170, in __anext__
    do = await self.iter(retry_state=self._retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Astrbot\backend\python\Lib\site-packages\tenacity\asyncio\__init__.py", line 157, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Astrbot\backend\python\Lib\site-packages\tenacity\_utils.py", line 111, in inner
    return call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "E:\Astrbot\backend\python\Lib\site-packages\tenacity\__init__.py", line 393, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "E:\Astrbot\backend\python\Lib\concurrent\futures\_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "E:\Astrbot\backend\python\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "\\?\E:\Astrbot\backend\app\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 515, in _iter_llm_responses_with_fallback
    async for resp in self._iter_llm_responses(
  File "\\?\E:\Astrbot\backend\app\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 475, in _iter_llm_responses
    async for resp in stream:  # type: ignore
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1294, in text_chat_stream
    ) = await self._handle_api_error(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1158, in _handle_api_error
    raise e
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1277, in text_chat_stream
    async for response in self._query_stream(
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 625, in _query_stream
    async for chunk in stream:
  File "E:\Astrbot\backend\python\Lib\site-packages\openai\_streaming.py", line 158, in __aiter__
    async for item in self._iterator:
  File "E:\Astrbot\backend\python\Lib\site-packages\openai\_streaming.py", line 205, in __stream__
    raise APIError(
openai.APIError: Internal server error
[2026-07-11 13:19:22.351] [Core]
[ERRO]
[v4.26.4] [core.astr_main_agent:1049]: Failed to generate webchat title for session ea9adb41-e79b-4338-95e7-d476c5353fd3: OpenAI completion has no choices. response_id=
Traceback (most recent call last):
  File "\\?\E:\Astrbot\backend\app\astrbot\core\astr_main_agent.py", line 1037, in _handle_webchat
    llm_resp = await prov.text_chat(
               ^^^^^^^^^^^^^^^^^^^^^
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1217, in text_chat
    ) = await self._handle_api_error(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1158, in _handle_api_error
    raise e
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 1201, in text_chat
    llm_response = await self._query(
                   ^^^^^^^^^^^^^^^^^^
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 569, in _query
    llm_response = await self._parse_openai_completion(completion, tools)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\\?\E:\Astrbot\backend\app\astrbot\core\provider\sources\openai_source.py", line 824, in _parse_openai_completion
    raise EmptyModelOutputError(
astrbot.core.exceptions.EmptyModelOutputError: OpenAI completion has no choices. response_id=

底层报错

raise EmptyModelOutputError(
    f"OpenAI completion has no choices. response_id={completion.id}"
)

底层 API 返回的裸响应:

{"id":"","choices":[],"created":0,"model":"","object":"chat.completion","usage":null}

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions