{"record":{"id":"c742814090c9fc80","repo":"HKUDS/DeepTutor","slug":"pageindex-api-key-is-not-configured-add-it-under","errorCode":null,"errorMessage":"PageIndex API key is not configured. Add it under Knowledge → RAG pipeline settings before creating a PageIndex knowledge base.","messagePattern":"PageIndex API key is not configured\\. Add it under Knowledge → RAG pipeline settings before creating a PageIndex knowledge base\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":655,"sourceCode":"    Empty / legacy / unknown strings coerce to the default (so a stale config or\n    a removed engine never selects a missing pipeline). Returning the real,\n    canonical provider is what makes the per-KB lock meaningful: the upload route\n    compares the requested provider against the KB's bound provider, so asking to\n    add to a ``pageindex`` KB with ``llamaindex`` (or vice versa) is rejected.\n    \"\"\"\n    return normalize_provider_name(raw_provider)\n\n\ndef _assert_provider_ready(provider: str) -> None:\n    \"\"\"Block creating/using a KB whose engine isn't ready.\n\n    PageIndex needs an API key; GraphRAG needs the optional package installed.\n    \"\"\"\n    if provider == PAGEINDEX_PROVIDER:\n        from deeptutor.services.rag.pipelines.pageindex.config import is_pageindex_configured\n\n        if not is_pageindex_configured():\n            raise HTTPException(\n                status_code=400,\n                detail=(\n                    \"PageIndex API key is not configured. Add it under \"\n                    \"Knowledge → RAG pipeline settings before creating a PageIndex \"\n                    \"knowledge base.\"\n                ),\n            )\n\n    if provider == PAGEINDEX_OSS_PROVIDER:\n        from deeptutor.services.rag.preflight import engine_preflight\n\n        report = engine_preflight(provider)\n        failed_checks = [\n            check\n            for check in report.get(\"checks\", [])\n            if not check.get(\"optional\") and not check.get(\"ok\")\n        ]\n        if failed_checks:","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L637-L673","documentation":"Raised by the provider preflight _assert_provider_ready when the selected RAG provider is PageIndex and is_pageindex_configured() returns False — no API key is present in the runtime settings. Creation/upload/reindex for PageIndex KBs is blocked with HTTP 400 before any work starts.","triggerScenarios":"Creating a KB, uploading files, or reindexing with provider=pageindex when the PAGEINDEX_API_KEY (or equivalent settings entry) is missing from data/user/settings/*.json or env overrides.","commonSituations":"Fresh installs that never configured RAG pipeline settings; key configured in a .env file (which this project ignores by design); key set in a different settings profile than the one the server loaded.","solutions":["Add the PageIndex API key via Knowledge → RAG pipeline settings in the UI","Or write it into the active data/user/settings/*.json runtime settings file / process env override","Restart/reload the server process so settings are re-read, then retry"],"exampleFix":"# before\n# no key configured\ncurl -X POST /api/v1/knowledge -d '{\"provider\":\"pageindex\"}'\n# after\n# settings.json: {\"pageindex\": {\"api_key\": \"pk-...\"}}\ncurl -X POST /api/v1/knowledge -d '{\"provider\":\"pageindex\"}'","handlingStrategy":"validation","validationCode":"from deeptutor.services.rag.pipelines.pageindex.config import is_pageindex_configured\nassert is_pageindex_configured(), 'configure PageIndex key first'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run provider readiness checks before showing the provider as selectable","Centralize API keys in runtime settings, not .env files","Health-check configuration on server startup"],"tags":["pageindex","rag","missing-api-key","config","http-400"],"backgroundTag":"missing-api-key","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}