Building RAG over your own content usually means standing up a vector DB, mirroring every source system's ACLs into it, and keeping that mirror in sync forever — get any of that wrong and you leak documents. Glean is already the permission-aware index of your company's content. Use its Platform API as retrieval and skip all three problems.
Pick a language
Both variants implement the same flow — pick whichever fits your app's stack.
- Python
- TypeScript
Scaffold the project
npx tiged --mode=git gleanwork/glean-cookbook/recipes/permissions-aware-rag/python permissions-aware-ragInstall dependencies
cd permissions-aware-rag && pip install -r requirements.txtSet credentials
Fill in GLEAN_API_TOKEN, GLEAN_INSTANCE, and ANTHROPIC_API_KEY, then export them into your shell — unlike the TypeScript variant, this one reads the environment directly and does not load .env automatically.
cp .env.example .envRun it
python main.py "What's our PTO policy?"Verify
Confirm the printed answer carries numbered citations with real titles and URLs. Re-run with --act-as <restricted-user-email> (requires a global/admin token) and confirm an HR-only query returns no fabricated answer for that user.
Scaffold the project
npx tiged --mode=git gleanwork/glean-cookbook/recipes/permissions-aware-rag/typescript permissions-aware-ragInstall dependencies
cd permissions-aware-rag && npm installSet credentials
Fill in GLEAN_API_TOKEN, GLEAN_INSTANCE, and ANTHROPIC_API_KEY — loaded automatically via dotenv in this variant.
cp .env.example .envRun it
npm start -- "What's our PTO policy?"Verify
Confirm the printed answer carries numbered citations with real titles and URLs. Re-run with -- "<question>" --act-as <restricted-user-email> (requires a global/admin token) and confirm an HR-only query returns no fabricated answer for that user.
Copies a prompt your AI assistant can build from.