Skip to content

[Bug]多模态输入失败:图片 Base64 字符串为空 (Error 500) #3239

@DIO-goo

Description

@DIO-goo

发生了什么

我向机器人发送一条包含图片的消息,机器人未能返回分析结果,日志中出现 Error code: 500 错误,并提示图片数据为空。

Error code: 500 - {'error': {'message': 'error counting image token, media index[0], original data[data:image/jpeg;base64,], err: base64 string is empty (request id: XXX)', 'type': 'new_api_error', 'param': '', 'code': 'count_token_failed'}}

这个是日志

Image

同时CC那边提示这个

如何复现?

发送图片带QQ机器人上

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.5.1 和 4.5.0 linux手动部署 gemini2.5pro QQ个人号

操作系统

Windows

报错日志

[15:00:30] [Core] [ERRO] [sources.openai_source:373]: 发生了错误。Provider 配置如下: {'id': 'openai36', 'provider': 'openai', 'type': 'openai_chat_completion', 'provider_type': 'chat_completion', 'enable': True, 'key': ['sk-jMEW9CCJx7kMTW02CiIjIwmCa2V5KfWQnc1arNXx4sxTbdJk'], 'api_base': 'https://api.kkyyxx.xyz/v1', 'timeout': 120, 'model_config': {'model': 'gemini-2.5-flash-preview-09-2025', 'temperature': 0.4}, 'custom_extra_body': {}, 'modalities': ['text', 'image', 'tool_use'], 'hint': '也兼容所有与 OpenAI API 兼容的服务。'}
[15:00:30] [Plug] [ERRO] [astrbot.process_llm_request:77]: 处理图片描述失败: Error code: 500 - {'error': {'message': 'error counting image token, media index[0], original data[data:image/jpeg;base64,], err: base64 string is empty (request id: 2025110123003019504420rZAdbBtW)', 'type': 'new_api_error', 'param': '', 'code': 'count_token_failed'}}
[15:00:32] [Core] [ERRO] [sources.openai_source:373]: 发生了错误。Provider 配置如下: {'id': 'openai36', 'provider': 'openai', 'type': 'openai_chat_completion', 'provider_type': 'chat_completion', 'enable': True, 'key': ['sk-jMEW9CCJx7kMTW02CiIjIwmCa2V5KfWQnc1arNXx4sxTbdJk'], 'api_base': 'https://api.kkyyxx.xyz/v1', 'timeout': 120, 'model_config': {'model': 'gemini-2.5-flash-preview-09-2025', 'temperature': 0.4}, 'custom_extra_body': {}, 'modalities': ['text', 'image', 'tool_use'], 'hint': '也兼容所有与 OpenAI API 兼容的服务。'}
[15:00:32] [Core] [ERRO] [method.llm_request:304]: Traceback (most recent call last):
File "/root/AstrBot-master/astrbot/core/pipeline/process_stage/method/llm_request.py", line 262, in run_agent
async for resp in agent_runner.step():
File "/root/AstrBot-master/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 90, in step
async for llm_response in self._iter_llm_responses():
File "/root/AstrBot-master/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 69, in _iter_llm_responses
yield await self.provider.text_chat(**self.req.dict)
File "/root/AstrBot-master/astrbot/core/provider/sources/openai_source.py", line 436, in text_chat
) = await self._handle_api_error(
File "/root/AstrBot-master/astrbot/core/provider/sources/openai_source.py", line 385, in _handle_api_error
raise e
File "/root/AstrBot-master/astrbot/core/provider/sources/openai_source.py", line 419, in text_chat
llm_response = await self._query(payloads, func_tool)
File "/root/AstrBot-master/astrbot/core/provider/sources/openai_source.py", line 135, in _query
completion = await self.client.chat.completions.create(
File "/root/AstrBot-master/venv/lib/python3.10/site-packages/openai/resources/chat/completions/completions.py", line 2585, in create
return await self._post(
File "/root/AstrBot-master/venv/lib/python3.10/site-packages/openai/_base_client.py", line 1794, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
File "/root/AstrBot-master/venv/lib/python3.10/site-packages/openai/_base_client.py", line 1594, in request
raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 500 - {'error': {'message': 'error counting image token, media index[0], original data[data:image/jpeg;base64,], err: base64 string is empty (request id: 2025110123003251507621PXNOPF9w)', 'type': 'new_api_error', 'param': '', 'code': 'count_token_failed'}}

你愿意提交 PR 吗?

  • 是的,我愿意提交 PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions