Dev.to AI 🤖 Ai 👁 0 📖 3 min read

Dex tutorial: how to connect Dex to your warehouse without the surprise bill

Part 4 of a short Dex by Exmergo series. Independent notes, based on the official docs and the open-source engine; not affiliated with Exmergo. Part 1 covered the guardrail design, part 2 walked through your first /dex:e

Part 4 of a short Dex by Exmergo series. Independent notes, based on the official docs and the open-source engine; not affiliated with Exmergo. Part 1 covered the guardrail design, part 2 walked through your first /dex:explore run, part 3 set up the weekly maintain habit — this one is the step people rush: pointing Dex at a billed warehouse.

The DuckDB on-ramp is free and local, and that is where you should prove the loop. But sooner or later the agent needs your real warehouse. That is the moment the second meter starts running — the warehouse bill — and Dex's answer is not "trust the agent". It is a cost guard per connector, in that connector's own billing unit, plus a rule that credentials are discovered, never collected.

Eight connectors, eight billing units

Dex connects to eight sources. Each one discovers its own credentials and carries a cost guard in its own unit:

Connector Credentials discovered from Cost-guard unit
DuckDB Local file path — no credentials Free and local
BigQuery Application Default Credentials (gcloud auth application-default login) Bytes scanned (dry-run estimate + server-side bytes-billed cap)
Snowflake connections.toml, SNOWFLAKE_* env, or a dbt profile Warehouse compute time / credits
Databricks Discovered workspace credentials DBUs
Amazon Redshift Discovered credentials RPU-hours
ClickHouse (Cloud and self-hosted) Discovered credentials Compute seconds
PostgreSQL Discovered credentials Load limit
Trino Discovered cluster credentials Cluster-seconds

Two details matter in practice. First, scope flags can narrow a configured source allowlist, never widen it — you start on the smallest scope that proves the workflow, then widen deliberately. Second, one gap to know before you plan around it: Starburst Galaxy is currently refused on the Trino path, per the engine docs. Use a self-hosted Trino or Starburst Enterprise cluster, or another connector.

How the guard actually works

Before a read runs, Dex produces a dry-run estimate. Reads pass a SQL and cost guard; anything over your ceiling stops at needs_confirmation instead of running. You confirm with an explicit budget, or you narrow the scope — fewer tables, a shorter date range — and try again. That stop is the guard working as designed, not a bug: if every query stops at needs_confirmation, raise the per-command ceiling deliberately and record why, never by pasting credentials or disabling the guard.

After the run, the spend is written to a local ledger, .dex/spend.jsonl. Read it after week one. It is the receipt that tells you whether your ceilings match reality — and it is the habit that keeps a curious agent from becoming a surprise invoice.

The credential rule, stated once more

Dex discovers credentials — Application Default Credentials, a connections.toml file, environment variables, a dbt profile — and never asks for them. If your agent asks for a warehouse password or key, stop: that is the wrong tool, a wrong connector config, or an agent improvising. Fix the local credential setup yourself, outside the chat. Scope those credentials read-only at the warehouse too, so the guard is not the only thing standing between an agent and your production data.

One warehouse at a time

Start every new connector on the smallest scope that proves the workflow. Connect DuckDB first and run the full loop for $0. Then add one billed warehouse, one narrow scope, one ceiling you chose on purpose — and check the ledger before you add the next. The order matters: the guard is only as good as the ceiling you set before the first query, not after the first bill.

Free: the install, the three commands, all 8 connectors, and the 6 safety rules on one page: https://payhip.com/b/zOwsR

Full starter pack: an 18-section tutorial, 12 copy-paste agent prompts, and 3 workflow worksheets (source onboarding, metric requests, weekly drift log): https://payhip.com/b/yUI8Y

Disclosure: the pack is my own independent product, sold on Payhip. The cheat sheet is free and covers the essentials. This article is based on Dex's official documentation and open-source repository — I have no relationship with Exmergo.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.