binary-husky/gpt_academic · error · ValueError
AZURE_CFG_ARRAY中配置的模型必须以azure开头
Error message
AZURE_CFG_ARRAY中配置的模型必须以azure开头
What it means
At import time, bridge_all.py iterates the AZURE_CFG_ARRAY config (from shared_utils/config_loader via get_conf) and requires every key (model name) to start with 'azure'; otherwise it raises ValueError. This is a naming contract: azure-prefixed names are what route requests to the Azure endpoint wiring defined right below the check.
Source
Thrown at request_llms/bridge_all.py:1383
continue
model_info.update({
model: {
"fn_with_ui": ollama_ui,
"fn_without_ui": ollama_noui,
"endpoint": ollama_endpoint,
"max_token": max_token_tmp,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
})
# -=-=-=-=-=-=- azure模型对齐支持 -=-=-=-=-=-=-
AZURE_CFG_ARRAY = get_conf("AZURE_CFG_ARRAY") # <-- 用于定义和切换多个azure模型 -->
if len(AZURE_CFG_ARRAY) > 0:
for azure_model_name, azure_cfg_dict in AZURE_CFG_ARRAY.items():
# 可能会覆盖之前的配置,但这是意料之中的
if not azure_model_name.startswith('azure'):
raise ValueError("AZURE_CFG_ARRAY中配置的模型必须以azure开头")
endpoint_ = azure_cfg_dict["AZURE_ENDPOINT"] + \
f'openai/deployments/{azure_cfg_dict["AZURE_ENGINE"]}/chat/completions?api-version=2023-05-15'
model_info.update({
azure_model_name: {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": endpoint_,
"azure_api_key": azure_cfg_dict["AZURE_API_KEY"],
"max_token": azure_cfg_dict["AZURE_MODEL_MAX_TOKEN"],
"tokenizer": tokenizer_gpt35, # tokenizer只用于粗估token数量
"token_cnt": get_token_num_gpt35,
}
})
if azure_model_name not in AVAIL_LLM_MODELS:
AVAIL_LLM_MODELS += [azure_model_name]
# -=-=-=-=-=-=- Openrouter模型对齐支持 -=-=-=-=-=-=-
# 为了更灵活地接入Openrouter路由,设计了此接口View on GitHub (pinned to d6bde0fa54)
Solutions
- Rename every key in AZURE_CFG_ARRAY to start with lowercase 'azure', e.g. 'azure-gpt-4-32k' (then select that name as LLM_MODEL).
- Check for case/whitespace: 'Azure-xxx' and ' azure-xxx' both fail the startswith check.
- Restart the app after fixing config — the check runs at import time, not per request.
- If you intended a non-Azure model, remove it from AZURE_CFG_ARRAY and configure it under the regular model section instead.
Example fix
# before (config)
AZURE_CFG_ARRAY = {
'gpt-4-azure': {'AZURE_ENDPOINT': ..., 'AZURE_API_KEY': ..., 'AZURE_ENGINE': ...}
}
# after
AZURE_CFG_ARRAY = {
'azure-gpt-4': {'AZURE_ENDPOINT': ..., 'AZURE_API_KEY': ..., 'AZURE_ENGINE': ...}
} Defensive patterns
Strategy: validation
Validate before calling
def validate_azure_cfg(cfg: dict) -> list[str]:
return [name for name in cfg if not name.startswith('azure')]
bad = validate_azure_cfg(get_conf('AZURE_CFG_ARRAY'))
if bad:
raise SystemExit(f'rename {bad} to start with "azure" in AZURE_CFG_ARRAY') Try / catch
try:
import request_llms.bridge_all # noqa: F401 (config check runs at import)
except ValueError as e:
if 'azure开头' in str(e):
raise SystemExit(f'config error: {e} — fix AZURE_CFG_ARRAY keys and restart')
raise Prevention
- Always name Azure entries with the lowercase 'azure' prefix (azure-gpt-4, azure-gpt35-turbo).
- Validate config keys in a startup script so import-time crashes become readable startup messages.
- Re-check after copying config blocks from other projects or docs.
When it happens
Trigger: Editing config so that AZURE_CFG_ARRAY contains a key like 'gpt-4-32k' or 'my_azure_model' (no 'azure' prefix) — the import of request_llms.bridge_all then fails immediately, usually at startup or when any module first imports the bridge.
Common situations: Users copy an Azure model block from another project keeping the original model name; typos like 'Azure-gpt4' (capital A — startswith('azure') is case-sensitive and fails); commenting out one field but renaming the key; config shared across machines with local edits.
Related errors
- Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:
- AZURE_CFG_ARRAY中配置的模型必须以azure开头
- OpenAI拒绝了请求:
- OpenAI拒绝了请求:
- 由于提问含不合规内容被过滤。
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/ecda302df0e80315.
Report an issue: GitHub.