This dbt package transforms data from Fivetran's Claude connector into analytics-ready tables covering API cost reporting, message usage, Claude Code activity, and enterprise user management.
- Number of materialized models¹: 30
- Connector documentation
- dbt package documentation
- dbt Core™ supported versions
>=1.3.0, <3.0.0
This package enables you to understand Claude API cost and usage, Claude Code developer activity, and enterprise user cost and engagement at your company. It allocates organization-level cost down to the API key that consumed it, joins per-user enterprise cost to per-user token usage, and rolls up cost, usage, and product activity into a single summary per enterprise user.
This package is also designed to roll up alongside Fivetran's OpenAI dbt package into the AI Reporting package, which combines Claude and OpenAI data into unified, cross-vendor AI usage and cost reporting models.
Final output tables are generated in the following target schema:
<your_database>.<connector/schema_name>_claude
By default, this package materializes the following final tables:
| Table | Description |
|---|---|
| claude__platform_cost_usage_report | Organization cost allocated down to the API key that consumed it, joined with API message usage. One row per API key, day, model, cost type and token type. Example Analytics Questions:
|
| claude__enterprise_cost_usage_report | Enterprise per-user cost joined to per-user token usage. One row per actor, day, product, model, cost type and token type. Example Analytics Questions:
|
| claude__code_report | Claude Code activity, one row per actor, day, terminal type and customer type. Example Analytics Questions:
|
| claude__user_summary | One row per enterprise actor, summarizing cost, usage and product activity over two windows: all time and the current calendar month. 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.
To use this dbt package, you must have the following:
- At least one Fivetran Claude connection syncing data into your destination.
- A BigQuery, Snowflake, Redshift, PostgreSQL, Databricks, or DuckDB destination.
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 in the dbt package's README file to use this package.
Include the following claude package version in your packages.yml file if you are not also using the upstream AI Reporting combination package:
TIP: Check dbt Hub for the latest installation instructions or read the dbt docs for more information on installing packages.
packages:
- package: fivetran/claude
version: [">=0.1.0", "<0.2.0"]By default, this package runs using your destination and the anthropic_claude schema. If this is not where your Claude data is (for example, if your Claude schema is named claude_fivetran), add the following configuration to your root dbt_project.yml file:
vars:
claude_database: your_destination_name
claude_schema: your_schema_nameIf you have multiple Claude connections in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. For each source table, the package will union all of the data together and pass the unioned table into the transformations. The source_relation column in each model indicates the origin of each record.
To use this functionality, you will need to set the claude_sources variable in your root dbt_project.yml file:
# dbt_project.yml
vars:
claude:
claude_sources:
- database: connection_1_destination_name # Required
schema: connection_1_schema_name # Required
name: connection_1_source_name # Required only if following the step in the following subsection
- database: connection_2_destination_name
schema: connection_2_schema_name
name: connection_2_source_nameIf you use Fivetran Transformations for dbt Core™ and are unioning multiple Claude connections, you can define your sources in a property .yml file, using this as a template. Set the variable has_defined_sources: true under the Claude namespace in your dbt_project.yml. Otherwise, your Claude connections won't appear in your DAG. See the union_connections macro documentation for full configuration details.
Your Claude connection might not sync every table that this package expects. If your syncs exclude certain tables, it is because you either do not use that functionality in Claude or have actively excluded some tables from your syncs.
To disable the corresponding functionality in the package, you must set the relevant config variables to false. By default, all variables are set to true. Alter variables only for the tables you want to disable:
vars:
claude__using_cost_report: false # Disable if you do not have COST_REPORT synced.
claude__using_enterprise_user_cost_report: false # Disable if you do not have ENTERPRISE_USER_COST_REPORT synced.
claude__using_message_usage_report: false # Disable if you do not have MESSAGE_USAGE_REPORT synced.
claude__using_enterprise_user_usage_report: false # Disable if you do not have ENTERPRISE_USER_USAGE_REPORT synced.
claude__using_claude_code_usage_report: false # Disable if you do not have CLAUDE_CODE_USAGE_REPORT synced.
claude__using_claude_code_usage_report_model_breakdown: false # Disable if you do not have CLAUDE_CODE_USAGE_REPORT_MODEL_BREAKDOWN synced.
claude__using_users: false # Disable if you do not have USERS synced.
claude__using_enterprise_user_actor: false # Disable if you do not have ENTERPRISE_USER_ACTOR synced.
claude__using_api_key: false # Disable if you do not have API_KEY synced.
claude__using_enterprise_user_activity: false # Disable if you do not have ENTERPRISE_USER_ACTIVITY synced.
claude__using_organization: false # Disable if you do not have ORGANIZATION synced. Removes the organization_name column and the join to it from the claude__code_report and claude__enterprise_cost_usage_report transform models.
claude__using_workspace: false # Disable if you do not have WORKSPACE synced. Removes the workspace_name column and the join to it from int_claude__api_key, claude__platform_cost_usage_report, and claude__user_summary.
claude__using_workspace_member: false # Disable if you do not have WORKSPACE_MEMBER synced. Removes the count_workspaces, workspace_names, is_workspace_admin, and is_workspace_developer columns from claude__user_summary.Expand/Collapse details
This package includes all source columns defined in the macros folder. You can add more columns using our pass-through column variables. These variables allow for the pass-through fields to be aliased (alias) and casted (transform_sql) if desired, but not required. Datatype casting is configured via a sql snippet within the transform_sql key. You may add the desired sql while omitting the as field_name at the end and your custom pass-through fields will be casted accordingly. Use the below format for declaring the respective pass-through variables:
# dbt_project.yml
vars:
claude__enterprise_user_activity_pass_through_metrics:
- name: "that_field"
alias: "renamed_to_this_field"
transform_sql: "cast(renamed_to_this_field as string)"
- name: "this_field"claude__enterprise_user_activity_pass_through_metrics fields are expected to be numeric metrics; they are summed into the lifetime_<field>/month_to_date_<field> columns of claude__user_summary alongside the default activity metrics.
Please create an issue if you'd like to see passthrough column support for other tables in the Claude schema.
The Claude API reports cost-based fields, such as amount and estimated_cost_amount, in the smallest denomination of the currency (cents, or fractional cents on some endpoints, for USD). By default, this package divides these fields by 100 in staging so every downstream cost column is in major currency units (dollars for USD) instead.
If you'd rather keep these fields in their raw, undivided form, set claude__convert_cost to false in your dbt_project.yml:
vars:
claude__convert_cost: false # default is trueClaude cost is currently always reported in USD, so this conversion is safe and enabled by default. If Claude later reports cost in a currency with no minor unit, this variable lets you turn the conversion off without editing the package.
By default this package will build the Claude staging models within a schema titled (<target_schema> + _claude_staging) and the final transform models within a schema titled (<target_schema> + _claude_reports) in your target database. If this is not where you would like your Claude staging and final models to be written to, add the following configuration to your dbt_project.yml file:
models:
claude:
+schema: my_new_schema_name # Leave +schema: blank to use the default target_schema.
staging:
+schema: my_new_schema_name # Leave +schema: blank to use the default target_schema.If an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable:
IMPORTANT: See this project's
src_claude.ymlsource declarations to see the expected names.
vars:
claude_<default_source_table_name>_identifier: your_table_nameBy default, the package applies case-insensitive comparisons when resolving source_relation values. If your destination is case-sensitive and you want downstream transformations to respect the exact casing of your source database and schema names, set the following variable:
vars:
fivetran_using_source_casing: trueExpand for details
Fivetran offers the ability for you to orchestrate your dbt project through Fivetran Transformations for dbt Core™. Learn how to set up your project for orchestration through Fivetran in our Transformations for dbt Core setup guides.
This dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the dbt hub site.
IMPORTANT: If you have any of these dependent packages in your own
packages.ymlfile, we highly recommend that you remove them from your rootpackages.ymlto avoid package version conflicts.
packages:
- package: fivetran/fivetran_utils
version: [">=0.4.12", "<0.5.0"]
- package: dbt-labs/dbt_utils
version: [">=1.0.0", "<2.0.0"]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.
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.
- If you have questions or want to reach out for help, see the GitHub Issue section to find the right avenue of support for you.
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our Feedback Form.