- Query governed metrics sliced by dimensions and time grains
- Discover the metrics and dimensions defined in your dbt project with metadata queries
- Filter, order, and limit results
- Read the same metric definitions used across your BI stack
- Power dashboards, embedded analytics, and metric explorers
Common use cases and example apps
How dbt Semantic Layer connections work
- Queries: Your app queries metrics through the GraphQL API at your Semantic Layer’s
/api/graphqlendpoint. dbt’s MetricFlow generates the warehouse SQL from your metric definitions. - Gateway: Requests are proxied through Lovable’s connector gateway, which injects your dbt service token. The token is never exposed in app code.
- Environment: Every Semantic Layer query includes an
environmentIdargument. Lovable syncs the environment ID from the connection to linked projects so app code can use it.
Semantic Layer queries run through your dbt Cloud account and your data warehouse. Usage counts toward your dbt Cloud plan, and warehouse compute is billed by your warehouse provider, not by Lovable.
How to connect the dbt Semantic Layer
Who can connect the dbt Semantic Layer depends on your plan and workspace settings. See Who can create connections and clients for details. Each connection queries one dbt environment. You can create multiple connections with different environment IDs or service tokens, for example to separate staging and production environments.Prerequisites
Before connecting the dbt Semantic Layer, make sure you have:- A dbt Cloud account on a plan that includes the dbt Semantic Layer (Starter, Enterprise, or Enterprise+)
- The dbt Semantic Layer configured for the environment you want to query, with MetricFlow metrics defined in your dbt project
- Permission to create connections in your Lovable workspace
Step 1: Get your credentials in dbt Cloud
You need three values from dbt Cloud: the Semantic Layer host, the environment ID, and a service token.1
Open the Semantic Layer settings
Sign in to dbt Cloud, open Account settings, select your project, and open its Semantic Layer settings.
2
Copy the Semantic Layer host
Copy the GraphQL API host shown in the Semantic Layer settings, for example
semantic-layer.cloud.getdbt.com. Hosts are region-specific, so copy the exact value dbt shows for your account.3
Copy the environment ID
Copy the numeric ID of the environment the Semantic Layer is configured for. This is the environment whose metrics your app queries.
4
Create a service token
Go to Account settings → API tokens → Service tokens and create a token with the Semantic Layer Only and Metadata Only permission sets. Copy the token; it starts with
dbtc_.Step 2: Connect the dbt Semantic Layer to Lovable
1
Open dbt Semantic Layer in Connectors
Go to Connectors and select dbt Semantic Layer.
2
Add a connection
Click Add connection.
3
Configure the connection
- Display name: name the connection, for example
dbt Semantic Layer Prod. - Semantic Layer host: enter the GraphQL API host from your Semantic Layer settings, for example
semantic-layer.cloud.getdbt.com. Enter the bare hostname only, withouthttps://or a path. - Environment ID: enter the numeric dbt environment ID from the Semantic Layer settings.
- Service token: paste your dbt service token (it starts with
dbtc_).
4
Choose who can use this connection
Under Who can use this connection, decide who in your workspace can use the connection:
- Only you (default): only the person creating the connection can use it and its associated data.
- Invite specific people: only you and explicitly added workspace members can use the connection and its associated data.
- Invite entire workspace: click Invite entire workspace to make the connection available to everyone in your Lovable workspace.
5
Connect
Click Connect. Lovable validates the credentials against your dbt environment, so the connection fails if the host, environment ID, or service token is wrong.
Limitations
The dbt Semantic Layer connector is read-only. It cannot:- Create or modify dbt models, metrics, or jobs, or trigger dbt runs
- Query data outside the metrics and dimensions defined in your dbt project
- Connect to dbt Core alone (it requires dbt Cloud with the Semantic Layer enabled)
- Query more than one dbt environment per connection (create a separate connection for each environment)
- Support per-end-user dbt authentication (each connection uses a single service token shared by its linked projects)
Manage your connection
Connections are managed from Connectors: select , then open the connection.- Unlink projects to remove access from specific projects while keeping the connection available for others. See Unlink projects from a connection for the steps.
- Delete the connection to remove it from the workspace entirely. Deleting is permanent. It removes the credentials from all linked projects, and app features that use stop working until a new connection is added. See Delete a connection for the steps and who can delete.