binary-husky/gpt_academic · error · RuntimeError
请配置ZHIPUAI_API_KEY
Error message
请配置ZHIPUAI_API_KEY
What it means
Configuration guard of the Zhipu GLM bridge: predict_no_ui_longconnection raises RuntimeError('请配置ZHIPUAI_API_KEY') when validate_key() reports the ZHIPUAI_API_KEY config empty. Note it fires after normalizing llm_kwargs['llm_model'] to the default zhipuai model, before any API call.
Source
Thrown at request_llms/bridge_zhipu.py:33
def make_media_input(inputs, image_paths):
for image_path in image_paths:
inputs = inputs + f'<br/><br/><div align="center"><img src="file={os.path.abspath(image_path)}"></div>'
return inputs
def predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], sys_prompt:str="",
observe_window:list=[], console_silence:bool=False):
"""
⭐多线程方法
函数的说明请见 request_llms/bridge_all.py
"""
watch_dog_patience = 5
response = ""
if llm_kwargs["llm_model"] == "zhipuai":
llm_kwargs["llm_model"] = zhipuai_default_model
if validate_key() is False:
raise RuntimeError('请配置ZHIPUAI_API_KEY')
# 开始接收回复
from .com_zhipuglm import ZhipuChatInit
zhipu_bro_init = ZhipuChatInit()
for chunk, response in zhipu_bro_init.generate_chat(inputs, llm_kwargs, history, sys_prompt):
if len(observe_window) >= 1:
observe_window[0] = response
if len(observe_window) >= 2:
if (time.time() - observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止。")
return response
def predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWithCookies,
history:list=[], system_prompt:str='', stream:bool=True, additional_fn:str=None):
"""
⭐单线程方法
函数的说明请见 request_llms/bridge_all.pyView on GitHub (pinned to d6bde0fa54)
Solutions
- Set ZHIPUAI_API_KEY in config_private.py (or docker-compose env), restart the service
- Verify: from toolbox import get_conf; assert get_conf('ZHIPUAI_API_KEY')
- Ensure the key comes from open.bigmodel.cn and is active (no quota/binding issues)
Example fix
# before ZHIPUAI_API_KEY = '' # after (config_private.py) ZHIPUAI_API_KEY = 'your-zhipuai-key'
Defensive patterns
Strategy: validation
Validate before calling
from toolbox import get_conf
assert get_conf('ZHIPUAI_API_KEY'), 'ZHIPUAI_API_KEY not configured' Try / catch
try:
predict_no_ui_long_connection(...)
except RuntimeError as e:
if 'ZHIPUAI_API_KEY' in str(e):
raise ConfigurationError(str(e)) from e
raise Prevention
- Store provider keys in config_private.py committed nowhere
- Preflight-validate keys for the model selected in the UI dropdown
When it happens
Trigger: Calling request_llms/bridge_zhipu.py:33 predict_no_ui_long_connection() with ZHIPUAI_API_KEY == '' from get_conf (config.py / config_private.py / env).
Common situations: Fresh install with placeholder config; user switched the model dropdown to zhipuai without a key; key set only in the shell that launched a different process (systemd/docker missing the env var).
Related errors
- 请配置讯飞星火大模型的XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET
- 请配置 TAICHU_API_KEY
- 请配置 DASHSCOPE_API_KEY
- 请配置讯飞星火大模型的XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET
- 文件大小 ({file_size_mb:.1f}MB) 超过限制 {max_size_mb}MB
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/1e83d0c482cee872.
Report an issue: GitHub.