[2026-06-07 19:39:48.225] [Core]
[INFO]
[core.event_bus:66]: [伊蕾娜] [伊蕾娜(qq_official)] D89B1F7B856B73EA955A677998F45534: [At:qq_official] 你在干嘛呀?
[2026-06-07 19:39:48.945] [Core]
[ERRO]
[v4.25.2] [sources.gemini_source:147]: 检测到 Key 异常(API key not valid. Please pass a valid API key.),且已没有可用的 Key。 当前 Key: sk-VR7dyIgl4...
[2026-06-07 19:39:48.945] [Core]
[ERRO]
[v4.25.2] [astrbot_plugin_affection.unconscious:54]: [Unconscious] LLM 调用失败: 达到了 Gemini 速率限制, 请稍后再试...
[2026-06-07 19:39:50.681] [Core]
[ERRO]
[v4.25.2] [sources.gemini_source:147]: 检测到 Key 异常(API key not valid. Please pass a valid API key.),且已没有可用的 Key。 当前 Key: sk-VR7dyIgl4...
[2026-06-07 19:39:50.682] [Core]
[WARN]
[v4.25.2] [runners.tool_loop_agent_runner:557]: Chat Model google_gemini/Gemini 3 Flash request error: 达到了 Gemini 速率限制, 请稍后再试...
Traceback (most recent call last):
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\gemini_source.py", line 871, in text_chat
return await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\gemini_source.py", line 633, in _query
result = await self.client.models.generate_content(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai\models.py", line 8512, in generate_content
return await self._generate_content(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai\models.py", line 7076, in _generate_content
response = await self.api_client.async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai_api_client.py", line 1657, in async_request
result = await self.async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai_api_client.py", line 1590, in async_request
return await self.async_retry( # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 112, in call
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 157, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_utils.py", line 111, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_init.py", line 413, in exc_check
raise retry_exc.reraise()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_init.py", line 184, in reraise
raise self.last_attempt.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 401, in __get_result
raise self.exception
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 116, in call
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai_api_client.py", line 1570, in _async_request_once
await errors.APIError.raise_for_async_response(client_response)
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai\errors.py", line 247, in raise_for_async_response
await cls.raise_error_async(status_code, response_json, response)
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\google\genai\errors.py", line 269, in raise_error_async
raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'API key not valid. Please pass a valid API key.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'API_KEY_INVALID', 'domain': 'googleapis.com', 'metadata': {'service': 'generativelanguage.googleapis.com'}}, {'@type': 'type.googleapis.com/google.rpc.LocalizedMessage', 'locale': 'en-US', 'message': 'API key not valid. Please pass a valid API key.'}]}}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 512, in iter_llm_responses_with_fallback
async for attempt in retrying:
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 170, in anext
do = await self.iter(retry_state=self.retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 157, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_utils.py", line 111, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_init_.py", line 393, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 516, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 479, in _iter_llm_responses
yield await self.provider.text_chat(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\gemini_source.py", line 873, in text_chat
if await self._handle_api_error(e, keys):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\gemini_source.py", line 150, in _handle_api_error
raise Exception("达到了 Gemini 速率限制, 请稍后再试...")
Exception: 达到了 Gemini 速率限制, 请稍后再试...
你的问题在于 API Key 配置错误,不是切换 API 的 bug。
从日志可以看到你当前使用的 Key 是 sk-VR7dyIgl4...,这是 OpenAI 格式的 Key(以 sk- 开头),而你配置的模型是 Gemini。Gemini 的 API Key 格式以 AIza 开头,两者不兼容。
错误提示 "达到了 Gemini 速率限制" 实际上有些误导——真实原因是你配置的 Key 对 Gemini API 来说完全无效 [1]。当所有 Key 都无效且没有可用备选时,系统会抛出这个错误信息。
解决方法:
- 前往 Google AI Studio 获取正确的 Gemini API Key
- 在 AstrBot 管理面板中,将 Gemini provider 的 API Key 替换为正确的 Key(以
AIza 开头)
- 确保没有把 OpenAI 的 Key 填到 Gemini 的配置里
To reply, just mention @dosu.
Docs are dead. Just use Dosu.

我换成openai的也错误了!!为什么呀大佬?
[2026-06-07 19:53:13.338] [Core]
[ERRO]
[v4.25.2] [astrbot_plugin_affection.unconscious:54]: [Unconscious] LLM 调用失败: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlTTS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
[2026-06-07 19:53:13.587] [Core]
[WARN]
[v4.25.2] [runners.tool_loop_agent_runner:557]: Chat Model openai/gpt-4.1-mini request error: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlTTS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
Traceback (most recent call last):
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 512, in iter_llm_responses_with_fallback
async for attempt in retrying:
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 170, in anext
do = await self.iter(retry_state=self.retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 157, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_utils.py", line 111, in inner
return call(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_init_.py", line 393, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 516, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 479, in _iter_llm_responses
yield await self.provider.text_chat(payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1286, in text_chat
) = await self._handle_api_error(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1232, in _handle_api_error
raise e
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1274, in text_chat
llm_response = await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 639, in _query
completion = await self.client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai\resources\chat\completions\completions.py", line 2739, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai_base_client.py", line 1931, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai_base_client.py", line 1716, in request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlTTS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
[2026-06-07 19:53:13.664] [Core]
[WARN]
[v4.25.2] [runners.tool_loop_agent_runner:494]: Switched from openai/gpt-4.1-mini to fallback chat provider: openai/gpt-4.1-pro
[2026-06-07 19:53:20.236] [Core]
[WARN]
[v4.25.2] [runners.tool_loop_agent_runner:557]: Chat Model openai/gpt-4.1-pro request error: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlTTS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
Traceback (most recent call last):
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 512, in iter_llm_responses_with_fallback
async for attempt in retrying:
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 170, in anext
do = await self.iter(retry_state=self.retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity\asyncio_init.py", line 157, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_utils.py", line 111, in inner
return call(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\tenacity_init_.py", line 393, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\concurrent\futures_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 516, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 479, in _iter_llm_responses
yield await self.provider.text_chat(payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1286, in text_chat
) = await self._handle_api_error(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1232, in _handle_api_error
raise e
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 1274, in text_chat
llm_response = await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\astrbot\core\provider\sources\openai_source.py", line 639, in _query
completion = await self.client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai\resources\chat\completions\completions.py", line 2739, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai_base_client.py", line 1931, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\28572\AppData\Roaming\uv\tools\astrbot\Lib\site-packages\openai_base_client.py", line 1716, in request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlTTS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
[2026-06-07 19:53:20.251] [Core]
[INFO]
[respond.stage:183]: Prepare to send - /D89B1F7B856B73EA955A677998F45534: LLM 响应错误: All chat models failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-coGlT**********TS0D. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}
请你查阅拿到key的api站文档,并将base url正确填入,插件同理填入相应的正确位置