{"record":{"id":"ffd0690769c496de","repo":"Graphify-Labs/graphify","slug":"azure-openai-requires-the-openai-package-run-pip","errorCode":null,"errorMessage":"Azure OpenAI requires the openai package. Run: pip install openai","messagePattern":"Azure OpenAI requires the openai package\\. Run: pip install openai","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"graphify/llm.py","lineNumber":1621,"sourceCode":"    result[\"model\"] = next(iter(model_usage), \"claude-code-plan\")\n    stop_reason = envelope.get(\"stop_reason\", \"\")\n    result[\"finish_reason\"] = \"length\" if stop_reason == \"max_tokens\" else \"stop\"\n    if _response_is_hollow(raw_content, result) and result[\"finish_reason\"] != \"length\":\n        print(\n            \"[graphify] claude-cli returned a hollow response; treating as \"\n            \"truncation so adaptive retry can bisect the chunk.\",\n            file=sys.stderr,\n        )\n        result[\"finish_reason\"] = \"length\"\n    return result\n\n\ndef _azure_client(api_key: str, endpoint: str):\n    \"\"\"Construct an AzureOpenAI client with env-driven api_version and timeout.\"\"\"\n    try:\n        from openai import AzureOpenAI\n    except ImportError as exc:\n        raise ImportError(\n            \"Azure OpenAI requires the openai package. Run: pip install openai\"\n        ) from exc\n    api_version = os.environ.get(\"AZURE_OPENAI_API_VERSION\", \"2024-12-01-preview\").strip()\n    timeout_raw = os.environ.get(\"GRAPHIFY_API_TIMEOUT\", \"\").strip()\n    timeout_s: float = 600.0\n    if timeout_raw:\n        try:\n            v = float(timeout_raw)\n            if v > 0:\n                timeout_s = v\n        except ValueError:\n            pass\n    return AzureOpenAI(api_key=api_key, azure_endpoint=endpoint, api_version=api_version, timeout=timeout_s,\n                       max_retries=_resolve_max_retries())\n\n\ndef _call_azure(\n    api_key: str,","sourceCodeStart":1603,"sourceCodeEnd":1639,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/llm.py#L1603-L1639","documentation":"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`.","triggerScenarios":"Running `extract_files_direct(..., backend=\"azure\")` with AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT set, in an environment lacking the `openai` package.","commonSituations":"Minimal installs of graphify without extras; Azure-only setups where the developer assumed the openai SDK was optional; Docker images trimmed of 'unused' dependencies.","solutions":["Install the SDK: `pip install openai` (or `uv tool install \"graphifyy[openai]\" --force`).","Verify `python -c \"from openai import AzureOpenAI\"` passes in the running interpreter.","Pin openai to a recent version — older SDKs lack AzureOpenAI."],"exampleFix":"# before\npip install graphifyy\n\n# after\npip install graphifyy openai","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"openai\") is None:\n    raise SystemExit(\"azure backend needs the openai SDK: pip install openai\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include `openai` in the dependency set whenever AZURE_OPENAI_* env vars are deployed.","Pin a recent openai SDK — AzureOpenAI exists only in newer versions."],"tags":["dependency","import-error","azure","openai","installation"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}