dbt-cost
Estimate BigQuery costs for dbt models before you run them.
dbt-cost uses BigQuery's free dry-run API to predict bytes scanned for each model, converts that to dollars, and gives you a clear cost breakdown — in your terminal, as JSON for CI, or as a markdown comment on your PR.
Install
pip install dbt-cost
Requires Python 3.9+ and a compiled dbt manifest (dbt compile).
Quick Start
# Cost of a single model
dbt-cost estimate dim_customers
# Cost of a model + all downstream
dbt-cost estimate stg_orders+
# Full project cost report
dbt-cost report
# Compare costs between two branches (for PRs)
dbt-cost diff --base-manifest base_manifest.json --pr-manifest pr_manifest.json
Commands
estimate
Estimate the cost of specific models using dbt selector syntax.
# Single model
dbt-cost estimate dim_customers
# Model + downstream
dbt-cost estimate stg_orders+
# Model + 2 levels downstream
dbt-cost estimate stg_orders+2
# Upstream + model + downstream
dbt-cost estimate +dim_customers+
# By tag
dbt-cost estimate --selector tag:marketing
# Top 5 most expensive, JSON output
dbt-cost --format json estimate stg_orders+ --top 5
Options:
| Flag | Default | Description |
|---|---|---|
--price |
6.25 |
Price per TB in USD (BigQuery on-demand) |
--concurrency |
10 |
Number of concurrent dry-runs |
--top |
all | Show only the N most expensive models |
report
Full project cost breakdown by layer.
dbt-cost report
dbt-cost report --top 20
dbt-cost report --layer staging
dbt-cost --format json report
Options:
| Flag | Default | Description |
|---|---|---|
--top |
10 |
Show top N most expensive models |
--layer |
all | Filter to a specific layer |
--price |
6.25 |
Price per TB in USD |
--concurrency |
10 |
Concurrent dry-runs (max 50) |
diff
Compare costs between two manifests — designed for CI pipelines and PR reviews.
# Basic diff
dbt-cost diff --base-manifest target/base.json --pr-manifest target/pr.json
# Markdown output for PR comments
dbt-cost --format markdown diff --base-manifest base.json --pr-manifest pr.json
# Fail CI if cost increase exceeds $50
dbt-cost diff --base-manifest base.json --pr-manifest pr.json --threshold 50
Example markdown output:
dbt-cost: Cost Impact of this PR
| Model | Before | After | Change |
|-------|--------|-------|--------|
| dim_customers | $0.80 | $45.00 | +$44.20 (+5,525%) |
| stg_orders | $2.10 | $2.10 | no change |
Total: $2.90 -> $47.10 (+$44.20)
2 models changed, 0 added, 0 removed
Options:
| Flag | Default | Description |
|---|---|---|
--base-manifest |
required | Path to base branch manifest.json |
--pr-manifest |
required | Path to PR branch manifest.json |
--threshold |
none | Max allowed cost increase in USD; exit 1 if exceeded |
--include-unchanged |
false |
Include unchanged models in output |
--price |
6.25 |
Price per TB in USD |
--concurrency |
10 |
Concurrent dry-runs |
Global Options
These apply to all commands:
| Flag | Default | Description |
|---|---|---|
--manifest |
target/manifest.json |
Path to dbt manifest |
--credentials |
ADC | Path to GCP service account key JSON |
--format |
table |
Output format: table, json, or markdown |
GitHub Actions
Add automated cost checks to your PRs. Copy examples/dbt-cost-pr.yml to your project's .github/workflows/ directory.
The workflow:
- Compiles dbt on both the base and PR branches
- Runs
dbt-cost diffto compare costs - Posts a sticky PR comment with the cost impact
- Fails the check if cost increase exceeds your threshold
Authentication
dbt-cost needs read-only BigQuery access to run dry-runs. It supports:
- Application Default Credentials (recommended) — run
gcloud auth application-default login - Service account key — pass
--credentials /path/to/key.json
Required IAM permissions: bigquery.jobs.create (BigQuery Job User role) and read access to referenced tables.
Safety: dry-run mode is hardcoded — dbt-cost can never execute queries.
How It Works
manifest.json (from dbt compile)
|
dbt-lens parses the manifest + dependency graph
|
Selector resolves which models to estimate
|
BigQuery dry-run API returns bytes_processed (free, no execution)
|
bytes / 1 TB * $6.25 = estimated cost
|
Table, JSON, or Markdown output
Development
git clone https://github.com/ishanyash/dbt-cost.git
cd dbt-cost
pip install -e ".[dev]"
# Run checks
ruff check src/ tests/
mypy src/dbt_cost/
pytest tests/ -v
License
MIT
Metadata
Release files for dbt-cost 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dbt_cost-0.2.0.tar.gz | 21.7 kB | With provenance | Details for dbt_cost-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dbt_cost-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for dbt_cost-0.2.0-py3-none-any.whl |
Total release size: 40.5 kB
Release files / dbt_cost-0.2.0.tar.gz
| Download URL | dbt_cost-0.2.0.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29a491076838a4ec6ca9fde00cb6c2c8f6fa6a7e87a3c3e0a2318112beec33f4
|
|
BLAKE2b-256 checksum How to use checksums |
4b053941973d489771eff2346a834384cd71419e5d1585ed44307caedb27e4fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.
Transparency logRelease files / dbt_cost-0.2.0-py3-none-any.whl
| Download URL | dbt_cost-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6773733e830eacabc585a82e6dd7594de7c35bcf931d5a0417009f9066dff9d
|
|
BLAKE2b-256 checksum How to use checksums |
fdd0eb091836d149495753acfd25fa7ca7090138eb28266fd4750e8247fe4a6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.
Transparency logSecurity for dbt-cost 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for dbt_cost-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.