Graphify-Labs/graphify · error · ValueError

Azure OpenAI backend requires AZURE_OPENAI_ENDPOINT to be se

Error message

Azure OpenAI backend requires AZURE_OPENAI_ENDPOINT to be set (e.g. https://my-resource.openai.azure.com/).

What it means

Raised on the `azure` dispatch path when `os.environ.get("AZURE_OPENAI_ENDPOINT")` is empty. The Azure backend needs BOTH AZURE_OPENAI_API_KEY (checked earlier via key resolution) and AZURE_OPENAI_ENDPOINT (the resource URL) to build the AzureOpenAI client; the key alone is not enough.

Source

Thrown at graphify/llm.py:1814

    vision = _backend_supports_vision(backend)
    # Only base64 (inline) vision backends need the bytes loaded + size-capped;
    # path-based backends (claude-cli) and non-vision backends do not.
    read_bytes = vision and backend not in _PATH_IMAGE_BACKENDS
    image_refs = _build_image_refs(image_files, root, read_bytes=read_bytes) if image_files else []
    if image_refs and not vision:
        image_refs = _strip_pixels(image_refs)
    max_out = _resolve_max_tokens(cfg.get("max_tokens", 8192))

    if backend == "claude":
        result = _call_claude(key, mdl, user_msg, max_tokens=max_out, deep_mode=deep_mode, images=image_refs)
    elif backend == "claude-cli":
        result = _call_claude_cli(user_msg, max_tokens=max_out, deep_mode=deep_mode, images=image_refs)
    elif backend == "bedrock":
        result = _call_bedrock(mdl, user_msg, max_tokens=max_out, deep_mode=deep_mode, images=image_refs)
    elif backend == "azure":
        endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT", "").strip()
        if not endpoint:
            raise ValueError(
                "Azure OpenAI backend requires AZURE_OPENAI_ENDPOINT to be set "
                "(e.g. https://my-resource.openai.azure.com/)."
            )
        result = _call_azure(
            key,
            endpoint,
            mdl,
            user_msg,
            temperature=_resolve_temperature(cfg.get("temperature", 0), mdl),
            max_tokens=max_out,
            deep_mode=deep_mode,
        )
    else:
        result = _call_openai_compat(
            cfg["base_url"],
            key,
            mdl,
            user_msg,

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Export the endpoint: `export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com/` alongside AZURE_OPENAI_API_KEY.
  2. Check for invisible whitespace/newlines — the code strips whitespace but a stray quote stays; verify with `echo "$AZURE_OPENAI_ENDPOINT"`.
  3. If you meant plain OpenAI, use `backend="openai"` instead; azure always requires the resource endpoint.
  4. Confirm the URL is your Azure resource URL, not a deployment path or key-vault URI.

Example fix

# before
export AZURE_OPENAI_API_KEY=...
# AZURE_OPENAI_ENDPOINT unset -> ValueError

# after
export AZURE_OPENAI_API_KEY=...
export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com/
Defensive patterns

Strategy: validation

Validate before calling

import os

endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT", "").strip()
if not endpoint.startswith("https://") or "openai.azure.com" not in endpoint:
    raise SystemExit("set AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com/")

Prevention

When it happens

Trigger: `backend="azure"` with a key present but no AZURE_OPENAI_ENDPOINT exported — the value is fetched with `.strip()`, so a whitespace-only variable also triggers it.

Common situations: Copy-paste config templates that include the key but not the endpoint; endpoint set under a different name (OPENAI_API_BASE, AZURE_OPENAI_BASE_URL) which this code doesn't read; trailing-quote/whitespace mangled values from .env parsers; deploying to a new environment missing one of the pair.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/da6edc4a15ac1ed7. Report an issue: GitHub.