Grounding your own LLM app in company content — the pattern usually called RAG — normally 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, so use its Platform API as the retrieval layer 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 -y tiged@2.12.8 --mode=git gleanwork/glean-cookbook/recipes/permissions-aware-retrieval/python permissions-aware-retrievalSet credentials
Use the shipped login flow. Then have the user enter ANTHROPIC_API_KEY in ignored .env without exposing it in chat or command output.
cd permissions-aware-retrieval && node scripts/glean-auth.mjs login --scopes search --email "<work-email>"Run it
Dependencies are declared inline in main.py (PEP 723), so uv resolves and installs them into an isolated environment on first run — there's no requirements.txt, venv, or activate step.
cd permissions-aware-retrieval && uv run main.py "<allowed-topic>"Verify
Confirm the printed answer carries numbered citations with real titles and URLs. Then ask for something another team owns: retrieval returns nothing and the app must say so rather than answering from the model's own knowledge.
Scaffold the project
npx -y tiged@2.12.8 --mode=git gleanwork/glean-cookbook/recipes/permissions-aware-retrieval/typescript permissions-aware-retrievalInstall dependencies
cd permissions-aware-retrieval && npm installSet credentials
Use the shipped login flow. Then have the user enter ANTHROPIC_API_KEY in ignored .env without exposing it in chat or command output.
cd permissions-aware-retrieval && npm run login -- --email "<work-email>"Run it
cd permissions-aware-retrieval && npm start -- "<allowed-topic>"Verify
Confirm the printed answer carries numbered citations with real titles and URLs. Then ask for something another team owns: retrieval returns nothing and the app must say so rather than answering from the model's own knowledge.
- Add a re-ranking pass over snippets before they reach the LLM for higher-precision citations.
- Cache retrieval results per session to cut latency on follow-up questions in the same conversation.
- Swap in Glean Chat instead of a raw LLM call if you want Glean to also own the generation step.
What's our PTO policy?
Returns a non-empty answer with at least one citation carrying a real title and URL, drawn from your own indexed content.
Ask for something you personally don't have access to (another team's compensation review, an HR case file)
Retrieval returns nothing, so the app must say it has no information rather than answering from the model's own knowledge. This is the property that matters: your credential is the permission boundary, and an empty retrieval must produce a refusal, not a confident fabrication.