Graphify-Labs/graphify · error · ValueError
No LLM backend configured. Set one of: GEMINI_API_KEY, ANTHR
Error message
No LLM backend configured. Set one of: GEMINI_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY, AZURE_OPENAI_API_KEY+AZURE_OPENAI_ENDPOINT, OLLAMA_BASE_URL, or AWS credentials. Pass backend= explicitly to select a provider.
What it means
Raised by `extract_files_direct` when `backend=None` and `detect_backend()` also returns None: no backend could be inferred from the environment. graphify discovers backends purely from env vars (GEMINI/ANTHROPIC/OPENAI/DEEPSEEK/MOONSHOT/AZURE keys, AZURE key+endpoint, OLLAMA_BASE_URL, or AWS credentials); with none present and no explicit backend=, it refuses to guess.
Source
Thrown at graphify/llm.py:1761
deep_mode: bool = False,
) -> dict:
"""Extract semantic nodes/edges from a list of files using the given backend.
Returns dict with nodes, edges, hyperedges, input_tokens, output_tokens.
Raises ValueError for unknown backends or when no API key is configured.
Raises ImportError if SDK missing.
Accepts ``str`` paths as well as ``Path``; string entries are coerced up
front so downstream helpers (``_partition_semantic_files``, ``_read_files``,
``_build_image_refs``) can rely on ``Path`` semantics (#1386). FileSlice units
(from extract_corpus_parallel's oversized-doc slicing, #1369) pass through
untouched — Path(FileSlice) would raise (#1397/#1399).
"""
files = [f if isinstance(f, (Path, FileSlice)) else Path(f) for f in files]
if backend is None:
backend = detect_backend()
if backend is None:
raise ValueError(
"No LLM backend configured. Set one of: GEMINI_API_KEY, ANTHROPIC_API_KEY, "
"OPENAI_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY, "
"AZURE_OPENAI_API_KEY+AZURE_OPENAI_ENDPOINT, OLLAMA_BASE_URL, "
"or AWS credentials. Pass backend= explicitly to select a provider."
)
if backend not in BACKENDS:
raise ValueError(f"Unknown backend {backend!r}. Available: {sorted(BACKENDS)}")
cfg = BACKENDS[backend]
key = api_key or _get_backend_api_key(backend)
if not key and backend == "ollama":
# Ollama ignores auth but the OpenAI client library requires a non-empty
# string. Use a placeholder and surface a visible warning so this never
# silently routes traffic without the user realising — see F-029.
ollama_url = _resolve_ollama_base_url(cfg.get("base_url", ""))
_validate_ollama_base_url(ollama_url)
print(
"[graphify] WARNING: ollama backend selected with no OLLAMA_API_KEY set; "View on GitHub (pinned to 7fe58b0b0f)
Solutions
- Export one of the listed variables, e.g. `export OPENAI_API_KEY=...` (or ANTHROPIC_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY, AZURE_OPENAI_API_KEY+AZURE_OPENAI_ENDPOINT, OLLAMA_BASE_URL, or AWS creds).
- Or pass the backend explicitly: `extract_files_direct(..., backend="ollama", api_key="...")`.
- Check for typos and that the variable is visible to the graphify process (`env | grep -i api_key`).
- In docker-compose/CI, ensure the env block actually passes the variable into the container.
Example fix
# before result = extract_files_direct(files, root) # after result = extract_files_direct(files, root, backend="openai", api_key=os.environ["OPENAI_API_KEY"])
Defensive patterns
Strategy: validation
Validate before calling
from graphify.llm import detect_backend
if detect_backend() is None:
raise SystemExit("set OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY / "
"DEEPSEEK_API_KEY / MOONSHOT_API_KEY / AZURE_OPENAI_* / "
"OLLAMA_BASE_URL / AWS creds, or pass backend=") Prevention
- Call `detect_backend()` as a preflight in pipelines instead of relying on the ValueError.
- Centralize provider env vars in one sourced env file and verify with `env | grep -E '(API_KEY|OLLAMA_BASE_URL|AWS_)'`.
- Pass `backend=` explicitly in scripts so behavior doesn't depend on ambient environment.
When it happens
Trigger: Calling `extract_files_direct(files)` with no `backend=` argument in a shell/process where none of the listed env vars are set — fresh machines, subshells that dropped the env, CI runners, containers.
Common situations: API key exported in an interactive shell but graphify run from an IDE/service/cron that doesn't inherit it; `.env` file never sourced; typos in variable names (e.g. OPENAI_KEY instead of OPENAI_API_KEY).
Related errors
- No API key for backend '{backend}'. Set {_format_backend_env
- No API key for backend '{backend}'. Set {_format_backend_env
- Azure OpenAI backend requires AZURE_OPENAI_ENDPOINT to be se
- Unknown backend {backend!r}. Available: {sorted(BACKENDS)}
- Unknown backend {backend!r}
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/04295a397e241d95.
Report an issue: GitHub.