binary-husky/gpt_academic · error · ValueError

Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:{endpoint}

Error message

Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:{endpoint}

What it means

ValueError from verify_endpoint in bridge_openrouter, an lru_cache'd guard that rejects any AZURE_ENDPOINT still containing the literal placeholder text '你亲手写的api名称' ('the api name you wrote by hand') copied from the config template. It exists to fail fast before an HTTP request is made with an obviously unedited endpoint.

Source

Thrown at request_llms/bridge_openrouter.py:119

    try:
        chunkjson = json.loads(chunk_decoded[6:])
        has_choices = 'choices' in chunkjson
        if has_choices: choice_valid = (len(chunkjson['choices']) > 0)
        if has_choices and choice_valid: has_content = ("content" in chunkjson['choices'][0]["delta"])
        if has_content: has_content = (chunkjson['choices'][0]["delta"]["content"] is not None)
        if has_choices and choice_valid: has_role = "role" in chunkjson['choices'][0]["delta"]
    except:
        pass
    return chunk_decoded, chunkjson, has_choices, choice_valid, has_content, has_role

from functools import lru_cache
@lru_cache(maxsize=32)
def verify_endpoint(endpoint):
    """
        检查endpoint是否可用
    """
    if "你亲手写的api名称" in endpoint:
        raise ValueError("Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:" + endpoint)
    return endpoint

def predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], sys_prompt:str="", observe_window:list=None, console_silence:bool=False):
    """
    发送至chatGPT,等待回复,一次性完成,不显示中间过程。但内部用stream的方法避免中途网线被掐。
    inputs:
        是本次问询的输入
    sys_prompt:
        系统静默prompt
    llm_kwargs:
        chatGPT的内部调优参数
    history:
        是之前的对话列表
    observe_window = None:
        用于负责跨越线程传递已经输出的部分,大部分时候仅仅为了fancy的视觉效果,留空即可。observe_window[0]:观测窗。observe_window[1]:看门狗
    """
    from request_llms.bridge_all import model_info

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Set AZURE_ENDPOINT in config_private.py to your real Azure OpenAI endpoint URL (https://<resource>.openai.azure.com)
  2. Restart the process after editing config so the lru_cache on verify_endpoint is cleared
  3. Grep the config for leftover placeholder text (你亲手写的api名称) and replace every occurrence

Example fix

# before
AZURE_ENDPOINT = "https://你亲手写的api名称.openai.azure.com"

# after
AZURE_ENDPOINT = "https://my-real-resource.openai.azure.com"
Defensive patterns

Strategy: validation

Validate before calling

from config import AZURE_ENDPOINT
assert AZURE_ENDPOINT and '你亲手写的api名称' not in AZURE_ENDPOINT, \
    'AZURE_ENDPOINT still contains the template placeholder'
assert AZURE_ENDPOINT.startswith('https://') and '.openai.azure.com' in AZURE_ENDPOINT

Try / catch

try:
    verify_endpoint(endpoint)
except ValueError as e:
    print(f'Fix config before running: {e}')
    sys.exit(2)

Prevention

When it happens

Trigger: AZURE_ENDPOINT in config.py (or environment) left as the template placeholder; deploying with the stock config_private.py.example values; cached stale config after editing but before process restart (lru_cache also caches the pass result).

Common situations: Fresh clone where the user copied config.py defaults without filling in their Azure deployment name; CI using template config; renaming the Azure deployment but not the config.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/f3ccc6d6c95a84c7. Report an issue: GitHub.