Graphify-Labs/graphify · error · ImportError

Azure OpenAI requires the openai package. Run: pip install o

Error message

Azure OpenAI requires the openai package. Run: pip install openai

What it means

Raised by `_azure_client` when `from openai import AzureOpenAI` fails. The Azure backend rides the `openai` SDK (AzureOpenAI class), so even if you never call plain OpenAI, the package is required. Unlike errors 40/42 this hint does not use `_backend_pkg_hint`, it hardcodes `pip install openai`.

Source

Thrown at graphify/llm.py:1621

    result["model"] = next(iter(model_usage), "claude-code-plan")
    stop_reason = envelope.get("stop_reason", "")
    result["finish_reason"] = "length" if stop_reason == "max_tokens" else "stop"
    if _response_is_hollow(raw_content, result) and result["finish_reason"] != "length":
        print(
            "[graphify] claude-cli returned a hollow response; treating as "
            "truncation so adaptive retry can bisect the chunk.",
            file=sys.stderr,
        )
        result["finish_reason"] = "length"
    return result


def _azure_client(api_key: str, endpoint: str):
    """Construct an AzureOpenAI client with env-driven api_version and timeout."""
    try:
        from openai import AzureOpenAI
    except ImportError as exc:
        raise ImportError(
            "Azure OpenAI requires the openai package. Run: pip install openai"
        ) from exc
    api_version = os.environ.get("AZURE_OPENAI_API_VERSION", "2024-12-01-preview").strip()
    timeout_raw = os.environ.get("GRAPHIFY_API_TIMEOUT", "").strip()
    timeout_s: float = 600.0
    if timeout_raw:
        try:
            v = float(timeout_raw)
            if v > 0:
                timeout_s = v
        except ValueError:
            pass
    return AzureOpenAI(api_key=api_key, azure_endpoint=endpoint, api_version=api_version, timeout=timeout_s,
                       max_retries=_resolve_max_retries())


def _call_azure(
    api_key: str,

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Install the SDK: `pip install openai` (or `uv tool install "graphifyy[openai]" --force`).
  2. Verify `python -c "from openai import AzureOpenAI"` passes in the running interpreter.
  3. Pin openai to a recent version — older SDKs lack AzureOpenAI.

Example fix

# before
pip install graphifyy

# after
pip install graphifyy openai
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

if importlib.util.find_spec("openai") is None:
    raise SystemExit("azure backend needs the openai SDK: pip install openai")

Prevention

When it happens

Trigger: Running `extract_files_direct(..., backend="azure")` with AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT set, in an environment lacking the `openai` package.

Common situations: Minimal installs of graphify without extras; Azure-only setups where the developer assumed the openai SDK was optional; Docker images trimmed of 'unused' dependencies.

Related errors


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