{"record":{"id":"21f0608a271c9ba4","repo":"HKUDS/DeepTutor","slug":"pageindex-api-key-is-not-configured-add-it-under-21f060","errorCode":null,"errorMessage":"PageIndex API key is not configured. Add it under Knowledge → RAG pipeline settings before using a PageIndex knowledge base.","messagePattern":"PageIndex API key is not configured\\. Add it under Knowledge → RAG pipeline settings before using a PageIndex knowledge base\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/rag/pipelines/pageindex/config.py","lineNumber":30,"sourceCode":"\n\n@dataclass(frozen=True)\nclass PageIndexConfig:\n    api_key: str\n\n\ndef get_pageindex_config(*, require_key: bool = True) -> PageIndexConfig:\n    \"\"\"Load the active PageIndex credential.\n\n    Raises when ``require_key`` and the key is empty, so callers fail with a\n    clear, actionable message instead of an opaque 401 from the API.\n    \"\"\"\n    from deeptutor.services.config import get_runtime_settings_service\n\n    settings = get_runtime_settings_service().load_pageindex()\n    api_key = str(settings.get(\"api_key\") or \"\").strip()\n    if require_key and not api_key:\n        raise RuntimeError(\n            \"PageIndex API key is not configured. Add it under \"\n            \"Knowledge → RAG pipeline settings before using a PageIndex knowledge base.\"\n        )\n    return PageIndexConfig(api_key=api_key)\n\n\ndef is_pageindex_configured() -> bool:\n    \"\"\"Best-effort check used to flag the provider as ready in the UI.\"\"\"\n    try:\n        return bool(get_pageindex_config(require_key=False).api_key)\n    except Exception:\n        return False\n\n\n__all__ = [\n    \"PageIndexConfig\",\n    \"get_pageindex_config\",\n    \"is_pageindex_configured\",","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/rag/pipelines/pageindex/config.py#L12-L48","documentation":"PageIndexConfig creation failed because the PageIndex API key is empty. get_pageindex_config(require_key=True) loads settings via the runtime settings service and raises when no api_key is set, since cloud PageIndex KBs cannot authenticate without it.","triggerScenarios":"Calling get_pageindex_config(require_key=True) or any code path that preflights/creates a cloud PageIndex knowledge base (is_pageindex_configured, _pageindex_preflight) before an api_key has been saved in Knowledge → RAG pipeline settings.","commonSituations":"Fresh installs where PageIndex was never configured; settings JSON under data/user/settings missing the pageindex.api_key entry; switching from OSS/local library mode to cloud mode without adding a key; key stored under a different profile.","solutions":["Open Knowledge → RAG pipeline settings and enter the PageIndex API key (or set pageindex.api_key in data/user/settings/*.json / process-env override)","Verify with is_pageindex_configured() / get_pageindex_config(require_key=False) before attempting cloud operations","If you intend to run fully local, use the OSS provider path instead of the cloud client"],"exampleFix":"// before\ncfg = get_pageindex_config()  # RuntimeError\n// after\nif not is_pageindex_configured():\n    raise SystemExit(\"Configure PageIndex API key first\")\ncfg = get_pageindex_config()","handlingStrategy":"validation","validationCode":"from deeptutor.services.rag.pipelines.pageindex.config import get_pageindex_config\ncfg = get_pageindex_config(require_key=False)\nif not cfg.api_key:\n    raise SystemExit(\"Configure the PageIndex API key first\")","typeGuard":null,"tryCatchPattern":"try:\n    cfg = get_pageindex_config()\nexcept RuntimeError as e:\n    if \"PageIndex API key\" in str(e):\n        # prompt user to configure, degrade, or abort\n        ...","preventionTips":["Check is_pageindex_configured() before exposing PageIndex KB options in the UI","Store the api_key via the settings UI rather than hand-editing JSON","Fail fast at app startup when PageIndex is the default pipeline"],"tags":["pageindex","rag","api-key","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}