Embedding is available to all Lightdash Cloud users and Enterprise On-Prem customers. Get in touch to have this feature enabled in your account.
Overview
AI agent embedding lets you drop a Lightdash AI agent into your own application. Embedded users can start new threads, ask questions in natural language, and view the charts the agent generates — all scoped to a single agent and space that you control with the embed JWT. AI agent embeds use the same JWT-based security model as dashboard and chart embeds, but with a dedicatedcontent.type: "aiAgent" token. Dashboard and chart tokens cannot access AI agent routes, and an AI agent token only grants access to the agent named in the token.
When to use AI agent embedding
- Add a “Chat with your data” experience to your customer-facing app
- Let customers ask ad-hoc questions about their own data without giving them a Lightdash login
- Scope each customer’s AI session to a specific space, so the agent only sees and writes content the customer is allowed to see
Available features
Embedded AI agents support:- Creating and continuing threads with the agent
- Viewing agent-generated charts and tables in the response
- Saving AI-generated charts into a fixed destination space (via write actions)
- Row-level filtering via user attributes
Prerequisites
Before you embed an AI agent, you need:- An AI agent configured in your Lightdash project. See Getting started with AI agents.
- An embed secret for the project. See Embedding quickstart.
- A destination space where AI-generated charts will be saved.
- A service account user (or regular Lightdash user) to act as the writer for AI actions. See Write actions.
Embed an AI agent with the React SDK
The React SDK ships aLightdash.AiAgent component that renders the agent inside an iframe. Use it when you want the agent to live inside a React or Next.js app.
threadUuid to deep-link the embed straight into an existing thread, or omit it to land on the new-thread screen. See Lightdash.AiAgent for the full prop list and styling options.
Generate an AI agent embed token
AI agent embeds require a JWT withcontent.type: "aiAgent" and a writeActions claim. Generate it server-side using your embed secret.
content.type— must be"aiAgent".content.agentUuid— the agent the embed is allowed to use. Tokens cannot switch to a different agent at runtime.writeActions.spaceUuid— the space AI-generated charts are saved into, and the only space the agent can read charts or dashboards from.- One of
writeActions.serviceAccountUserUuidorwriteActions.userUuid— the actor whose permissions are used when the agent runs queries and saves charts. See Write actions.
content.projectUuid— pins the embed to a specific project.userAttributes— applies row-level filters to the agent’s queries, identical to other embed types.user.email/user.externalId— surfaced in audit and analytics for the embedded viewer.
Access control
AI agent embeds enforce a tight scope:- A token issued for agent A cannot access agent B, even within the same project.
- The agent can only read dashboards and saved charts that live in
writeActions.spaceUuid. Other content returns a not-found error. - The agent saves new charts into
writeActions.spaceUuid. Embedded users cannot pick a different destination. - Query results respect the write actor’s permissions and any
userAttributesclaims on the JWT, so embedded viewers only see the rows they’re entitled to. - Dashboard and chart embed tokens are rejected by AI agent routes, and AI agent tokens are rejected by dashboard or chart routes.
Next steps
AI agents overview
Learn how to design and configure agents before embedding them
React SDK reference
Full prop reference for the Lightdash.AiAgent component
Embedding reference
Complete JWT structure for AI agent embed tokens
Write actions
Configure the actor and destination space for embedded writes