Learn how Auth for GenAI enables AI agents to implement fine-grained authorization for Retrieval Augmented Generation (RAG).
Create an Auth0 FGA account
Create an Auth0 Account and a Dev Tenant
Create an Auth0 Application
Regular Web
http://localhost:3000/auth/callback
http://localhost:3000
OpenAI Platform
@auth0/ai-langchain
: Auth0 AI SDK for LangChain built for GenAI applications powered by LangChain.@langchain/langgraph
: For building stateful, multi-actor applications with LLMs.langchain
: The LangChain library.@langchain/core
: Core LangChain dependencies.@langchain/openai
: OpenAI provider for LangChain.zod
: TypeScript-first schema validation library.langgraph-nextjs-api-passthrough
: API passthrough for LangGraph..env.example
file to .env.local
and update the variables with your Auth0 credentials. You can find your Auth0 domain, client ID, and client secret in the application you created in the Auth0 Dashboard..env.local
file with the following content to the root directory of the project. Click Continue to see the FGA_API_URL
and FGA_API_AUDIENCE.
The confirmation dialog will provide you with all the information that you need for your environment file.src/app/documents/page.tsx
).src/app/api/documents/upload/route.ts
).src/lib/actions/documents.ts
).src/lib/db
.src/lib/fga
.src/lib/rag/embedding.ts
).<document name>
object.user:*
<document name>
in the ID fieldviewer
FGAFilter
to filter authorized data from the vector database:/src/app/api/chat/[..._path]/route.ts
file with the following code to pass the user credentials to your agent:src/lib/auth0.ts
:/src/lib/agent.ts
file with the following code to add the tool to your agent:npm run all:dev
. Then, navigate to http://localhost:3000
.