Skip to main content

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.

Your appany LLM app
Glean Platform APIACL-filtered retrieval
Your LLManswers from permitted context only
A work email for tenant discovery and OAuth sign-in; a SEARCH-scoped API token is the fallback
X_GLEAN_INCLUDE_EXPERIMENTAL=true set (the Platform API is Experimental as of its 2026-07 launch)
An LLM API key (any provider; example uses Claude)
uv (for the Python path) or Node 20+
1

Pick a language

Both variants implement the same flow — pick whichever fits your app's stack.

1

Scaffold the project

npx -y tiged@2.12.8 --mode=git gleanwork/glean-cookbook/recipes/permissions-aware-retrieval/python permissions-aware-retrieval
2

Set 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>"
3

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>"
4

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.

Take it further
  • 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.

View source

Runs the recipe through the Glean cookbook plugin.

At a glance
SurfacesPlatform API, API clients
StatusProduction pattern
Time~1 hr
Required scopes
SEARCH