OpenAI dbt Package
This dbt package transforms data from Fivetran's OpenAI Platform/Enterprise connector into analytics-ready tables.
Resources
- Number of materialized models¹: 49
- Connector documentation
- dbt package documentation
- dbt Core™ supported versions
>=1.3.0, <3.0.0
What does this dbt package do?
This package enables you to analyze OpenAI Platform spend, usage, and Codex Enterprise productivity across your organization. It creates enriched models with metrics focused on daily cost by project and model, per-user activity across every OpenAI product, Codex Enterprise coding productivity, and per-user usage summaries.
This package is also designed to roll up alongside Fivetran's Claude dbt package into the AI Reporting package, which combines Claude and OpenAI data into unified, cross-vendor AI usage and cost reporting models.
Output schema
Final output tables are generated in the following target schema:
<your_database>.<connector/schema_name>_openai_reports
Final output tables
By default, this package materializes the following final tables:
| Table | Description |
|---|---|
| openai__cost_usage_report | Daily OpenAI Platform spend and token usage by project and model. One row per source relation, day, project, and model, plus one org-level row per source relation/day for cost that can't be attributed to a project (cost_type = 'other', e.g. aggregate feature charges like "Assistants API", or token-type cost with no matching completion volume). Cost is inferred by applying an implied per-token rate (Costs endpoint spend ÷ completion token volume) to each project's token share, since the Costs endpoint doesn't report a project breakdown directly. Still useful with only openai__using_cost or only openai__using_completion enabled — see Additional configurations. Example Analytics Questions:
|
| openai__enterprise_user_report | Daily OpenAI Platform activity by user, project, model, and product (completions, embeddings, audio transcription, audio speech, image generation, moderation, web search, and file search). Cost is not available at this grain — the Costs endpoint doesn't report per-user attribution. Example Analytics Questions:
|
| openai__code_report | Daily Codex Enterprise productivity (lines of code added/removed, threads, turns) plus credit and token consumption, one row per source relation, day, and user. Per-model and per-speed detail is rolled up onto this grain rather than fanned out into separate rows. Example Analytics Questions:
|
| openai__user_summary | One row per source relation and user, with organization role, project membership, project-level custom roles, API key ownership, invite status, and all-time/month-to-date usage totals. Example Analytics Questions:
|
| openai__compliance_cost_report | Daily ChatGPT Enterprise (Compliance Platform) spend by user, product, surface, model, and SKU. Only its codex-product rows cover the same activity as openai__code_report, and from a cost angle rather than that report's productivity angle — see Opinionated Modelling Decisions for the double-counting caution if you query both. Example Analytics Questions:
|
¹ Each Quickstart transformation job run materializes these models if all components of this data model are enabled. This count includes all staging, intermediate, and final models materialized as view, table, or incremental.
Prerequisites
To use this dbt package, you must have the following:
- At least one Fivetran OpenAI Platform/Enterprise connection syncing data into your destination.
- A BigQuery, Snowflake, Redshift, Databricks, PostgreSQL, or DuckDB destination.
How do I use the dbt package?
You can either add this dbt package in the Fivetran dashboard or import it into your dbt project:
- To add the package in the Fivetran dashboard, follow our Quickstart guide.
- To add the package to your dbt project, follow the setup instructions below.
How is this package maintained and can I contribute?
Package Maintenance
The Fivetran team maintaining this package only maintains the latest version of the package. We highly recommend you stay consistent with the latest version of the package and refer to the CHANGELOG and release notes for more information on changes across versions.
Contributions
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.
We highly encourage and welcome contributions to this package. Learn how to contribute to a package in dbt's Contributing to an external dbt package article.
Opinionated Modelling Decisions
This dbt package takes an opinionated stance on a few points worth knowing before you build on top of it — most notably, openai__compliance_cost_report and openai__code_report both cover Codex activity from different angles (spend versus productivity), and summing spend/credits across the two double-counts Codex. See the DECISIONLOG for this and the rest of our opinionated modeling choices, along with the reasoning behind them.