{"record":{"id":"66df814c9d6fa2a0","repo":"binary-husky/gpt_academic","slug":"azure-cfg-array-azure-66df81","errorCode":null,"errorMessage":"AZURE_CFG_ARRAY中配置的模型必须以azure开头","messagePattern":"AZURE_CFG_ARRAY中配置的模型必须以azure开头","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"toolbox.py","lineNumber":620,"sourceCode":"\ndef load_chat_cookies():\n    API_KEY, LLM_MODEL, AZURE_API_KEY = get_conf(\n        \"API_KEY\", \"LLM_MODEL\", \"AZURE_API_KEY\"\n    )\n    AZURE_CFG_ARRAY, NUM_CUSTOM_BASIC_BTN = get_conf(\n        \"AZURE_CFG_ARRAY\", \"NUM_CUSTOM_BASIC_BTN\"\n    )\n\n    # deal with azure openai key\n    if is_any_api_key(AZURE_API_KEY):\n        if is_any_api_key(API_KEY):\n            API_KEY = API_KEY + \",\" + AZURE_API_KEY\n        else:\n            API_KEY = AZURE_API_KEY\n    if len(AZURE_CFG_ARRAY) > 0:\n        for azure_model_name, azure_cfg_dict in AZURE_CFG_ARRAY.items():\n            if not azure_model_name.startswith(\"azure\"):\n                raise ValueError(\"AZURE_CFG_ARRAY中配置的模型必须以azure开头\")\n            AZURE_API_KEY_ = azure_cfg_dict[\"AZURE_API_KEY\"]\n            if is_any_api_key(AZURE_API_KEY_):\n                if is_any_api_key(API_KEY):\n                    API_KEY = API_KEY + \",\" + AZURE_API_KEY_\n                else:\n                    API_KEY = AZURE_API_KEY_\n\n    customize_fn_overwrite_ = {}\n    for k in range(NUM_CUSTOM_BASIC_BTN):\n        customize_fn_overwrite_.update(\n            {\n                \"自定义按钮\"\n                + str(k + 1): {\n                    \"Title\": r\"\",\n                    \"Prefix\": r\"请在自定义菜单中定义提示词前缀.\",\n                    \"Suffix\": r\"请在自定义菜单中定义提示词后缀\",\n                }\n            }","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/toolbox.py#L602-L638","documentation":"Raised during config parsing in toolbox.py:620 (read_single_conf_via_LLM area) when iterating AZURE_CFG_ARRAY: every model name used as a key in that dict must start with the literal prefix 'azure'. The prefix is the routing signal that tells the key-pattern manager to select an Azure-style key (see error 200), so a non-prefixed name would silently break key selection and is rejected upfront with ValueError.","triggerScenarios":"Defining AZURE_CFG_ARRAY = { \"gpt-4-turbo\": {...} } (missing 'azure' prefix) in config_private.py. Also triggered by renaming a deployment entry to match the upstream OpenAI model name, or by copying an example config that omits the prefix. The loop over AZURE_CFG_ARRAY.items() raises on the first offending key.","commonSituations":"Users migrating from the plain API_KEY setup to the multi-deployment AZURE_CFG_ARRAY setup and keeping the original model names. Typos like 'Azure-gpt-4' (capital A) since the check is case-sensitive startswith('azure'). Copy-pasting model names from the Azure portal deployment list, which are usually unprefixed.","solutions":["Rename every key in AZURE_CFG_ARRAY to start with 'azure', e.g. 'azure-gpt-4-turbo'.","Check case: the prefix must be lowercase 'azure'; fix 'Azure-...' spellings.","After renaming, verify the same prefixed name is used in the model-selection UI/config so chat requests route to the Azure entry.","Remove stale/unused entries from AZURE_CFG_ARRAY entirely if you no longer need them."],"exampleFix":"# before (config_private.py)\nAZURE_CFG_ARRAY = {\n    \"gpt-4-turbo\": {\n        \"AZURE_API_KEY\": \"...\",\n        \"AZURE_API_BASE\": \"https://xxx.openai.azure.com/\",\n        \"AZURE_API_VERSION\": \"2024-xx-xx\",\n    }\n}\n\n# after\nAZURE_CFG_ARRAY = {\n    \"azure-gpt-4-turbo\": {\n        \"AZURE_API_KEY\": \"...\",\n        \"AZURE_API_BASE\": \"https://xxx.openai.azure.com/\",\n        \"AZURE_API_VERSION\": \"2024-xx-xx\",\n    }\n}","handlingStrategy":"validation","validationCode":"def validate_azure_cfg(azure_cfg_array: dict) -> list:\n    bad = [name for name in azure_cfg_array if not str(name).startswith('azure')]\n    if bad:\n        raise ValueError(f'AZURE_CFG_ARRAY model names must start with \"azure\": {bad}')\n    return bad\n\n# run after loading config, before the app starts:\n# validate_azure_cfg(AZURE_CFG_ARRAY)","typeGuard":"def is_valid_azure_cfg_name(name) -> bool:\n    return isinstance(name, str) and name.startswith('azure')","tryCatchPattern":"try:\n    # config load that parses AZURE_CFG_ARRAY\n    ...\nexcept ValueError as e:\n    if 'azure' in str(e):\n        print(f'config fix needed: prefix every AZURE_CFG_ARRAY key with \"azure-\": {e}')\n    raise","preventionTips":["Adopt the convention azure-<deployment-name> for every AZURE_CFG_ARRAY key when writing the config.","Add a startup validation pass over AZURE_CFG_ARRAY so misnamed entries are caught with a precise message before the server boots.","Watch for case sensitivity: 'azure' must be lowercase."],"tags":["configuration","azure-openai","startup","naming-convention"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}