{"record":{"id":"f01aee6ac197b0ff","repo":"Graphify-Labs/graphify","slug":"the-anthropic-package-is-required-for-this-backe","errorCode":null,"errorMessage":"the 'anthropic' package is required for this backend but is not installed. Install it with:  uv tool install \"graphifyy[anthropic]\" --force  (uv tool), or  pip install anthropic  (pip/venv install).","messagePattern":"the 'anthropic' package is required for this backend but is not installed\\. Install it with:  uv tool install \"graphifyy\\[anthropic\\]\" --force  \\(uv tool\\), or  pip install anthropic  \\(pip/venv install\\)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"graphify/llm.py","lineNumber":1320,"sourceCode":"    if output_tokens < 50 and backend == \"ollama\":\n        print(\n            \"[graphify] warning: ollama returned very few tokens — likely causes: \"\n            \"(1) VRAM pressure: check `nvidia-smi` and reduce chunk size with \"\n            \"--token-budget (e.g. --token-budget 4096) or set \"\n            \"GRAPHIFY_OLLAMA_NUM_CTX to a smaller value; \"\n            \"(2) model too small for JSON instruction following — \"\n            \"try a larger model with --model (e.g. --model qwen2.5-coder:14b).\",\n            file=sys.stderr,\n        )\n    return result\n\n\ndef _call_claude(api_key: str, model: str, user_message: str, max_tokens: int = 8192, *, deep_mode: bool = False, images: list[_ImageRef] | None = None) -> dict:\n    \"\"\"Call Anthropic Claude directly (not via OpenAI compat layer).\"\"\"\n    try:\n        import anthropic\n    except ImportError as exc:\n        raise ImportError(_backend_pkg_hint(\"anthropic\", \"anthropic\")) from exc\n\n    client = anthropic.Anthropic(\n        api_key=api_key,\n        base_url=BACKENDS[\"claude\"][\"base_url\"],\n        timeout=_resolve_api_timeout(),\n        max_retries=_resolve_max_retries(),\n    )\n    resp = client.messages.create(\n        model=model,\n        max_tokens=max_tokens,\n        system=_extraction_system(deep=deep_mode),\n        messages=[{\"role\": \"user\", \"content\": _anthropic_content(user_message, images or [])}],\n    )\n    raw_content = resp.content[0].text if resp.content else None\n    result = _parse_llm_json(raw_content or \"{}\")\n    result[\"input_tokens\"] = resp.usage.input_tokens if resp.usage else 0\n    result[\"output_tokens\"] = resp.usage.output_tokens if resp.usage else 0\n    result[\"model\"] = model","sourceCodeStart":1302,"sourceCodeEnd":1338,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/llm.py#L1302-L1338","documentation":"Raised by `_call_claude` when `import anthropic` fails. The native `claude` backend (not the OpenAI compat layer, not claude-cli) calls Anthropic's SDK directly, so the `anthropic` package must be present. The message comes from `_backend_pkg_hint(\"anthropic\", \"anthropic\")` and includes the exact uv/pip install command.","triggerScenarios":"Calling `extract_files_direct(..., backend=\"claude\")` (or `detect_backend()` returning `claude` because ANTHROPIC_API_KEY is set) in an environment without the `anthropic` package installed.","commonSituations":"Installing graphify without the `[anthropic]` extra but having ANTHROPIC_API_KEY exported, so auto-detection selects `claude`; venv drift after a reinstall; CI images that trim optional dependencies.","solutions":["Install the extra: `uv tool install \"graphifyy[anthropic]\" --force` or `pip install anthropic` in the active venv.","Confirm with `python -c \"import anthropic\"` using the same interpreter that runs graphify.","Alternatively switch to `backend=\"claude-cli\"` if you have the Claude Code CLI installed and don't want the SDK."],"exampleFix":"# before\npip install graphifyy\n\n# after\npip install \"graphifyy[anthropic]\"","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"anthropic\") is None:\n    raise SystemExit(\"graphify's claude backend needs: pip install graphifyy[anthropic]\")","typeGuard":null,"tryCatchPattern":"try:\n    extract_files_direct(files, root, backend=\"claude\")\nexcept ImportError as e:\n    if \"anthropic\" in str(e):\n        subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"anthropic\"], check=True)\n        extract_files_direct(files, root, backend=\"claude\")\n    else:\n        raise","preventionTips":["Install `graphifyy[anthropic]` whenever ANTHROPIC_API_KEY is part of your standard env, since auto-detection will pick the claude backend.","Prefer `backend=\"claude-cli\"` on machines where you don't want the SDK dependency."],"tags":["dependency","import-error","installation","anthropic","backend"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}