{"canonicalLink":"https://www.snowflake.com/en/developers/guides/cortex-code-control-hub-chargeback/","robotsTags":[],"allowedRenditionsWidth":["320","480","640","768","960","1200","1440","1920"],"templateName":"quickstart-page-template","cssClassNames":"page basicpage summit-page","language":"en","description":"Add cost attribution and chargeback to Snowflake CoCo. Attribute CoCo spend to the teams, customers, or partners who generated it, then generate an itemized internal showback or external invoice — as a branded PDF, all native to Snowflake.","title":"CoCo Control Hub and Chargeback Solution","analyticsPageType":"quickstart-page-template","analyticsCategory":"general","analyticsSubCategory":"","excludeFromAnalytics":false,":hierarchyType":"page",":path":"/content/snowflake-site/global/en/developers/guides/cortex-code-control-hub-chargeback","analyticsEnabled":true,"analyticsContentTags":["snowflake-site:taxonomy/solution-center/certification/quickstart","snowflake-site:taxonomy/snowflake-feature/cortex-llm-functions","snowflake-site:taxonomy/product/ai","snowflake-site:taxonomy/product/applications-and-collaboration"],":mappedPath":"/en/developers/guides/cortex-code-control-hub-chargeback/",":type":"snowflake-site/components/structure/page",":items":{"root":{"gridClassNames":"aem-Grid aem-Grid--12 aem-Grid--default--12","columnClassNames":{"markup_editor_1950346551":"aem-GridColumn aem-GridColumn--default--12","experiencefragment-banner":"aem-GridColumn aem-GridColumn--default--12","experiencefragment-header":"aem-GridColumn aem-GridColumn--default--12","responsivegrid":"aem-GridColumn aem-GridColumn--default--12","experiencefragment-footer":"aem-GridColumn aem-GridColumn--default--12","modal_container":"aem-GridColumn aem-GridColumn--default--12","markup_editor":"aem-GridColumn aem-GridColumn--default--12"},"columnCount":12,":items":{"experiencefragment-banner":{"id":"experiencefragment-5e3db2bfaf","localizedFragmentVariationPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/pushdown-banner/master/jcr:content","configured":true,"xfModelPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/pushdown-banner/master.xfmodel.json",":type":"snowflake-site/components/experiencefragment"},"experiencefragment-header":{"id":"experiencefragment-6f40cc141a","localizedFragmentVariationPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/mega-nav-header/master/jcr:content","configured":true,"xfModelPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/mega-nav-header/master.xfmodel.json","languageNavPath":"/content/snowflake-site/global/en/developers/guides/cortex-code-control-hub-chargeback.languagenav.json",":type":"snowflake-site/components/experiencefragment"},"markup_editor_1950346551":{"id":"markup-editor-a260a208a7","title":" ","cssContent":".snowflake-markdown-table code[class*=language-],.snowflake-markdown-table code[class*=language-],.snowflake-markdown .snowflake-text code[class*=language-],.snowflake-markdown .snowflake-text pre[class*=language-]{background-color:rgba(var(--ui-12-rgb),.5);color:var(--text-01);text-shadow:none;padding:var(--spacing-00);border-radius:var(--spacing-00);font-size:smaller}","isGSAPEnabled":false,":type":"snowflake-site/components/markup-editor"},"responsivegrid":{"gridClassNames":"aem-Grid aem-Grid--12 aem-Grid--default--12","columnClassNames":{"quickstart_hero":"aem-GridColumn aem-GridColumn--default--12","flexible_column_cont":"aem-GridColumn aem-GridColumn--default--12","markup_editor":"aem-GridColumn aem-GridColumn--default--12"},"columnCount":12,":items":{"quickstart_hero":{"id":"quickstart-hero-b9499ecfbb","quickstartHeroFirstCertifiedTag":{"tagText":"Quickstart","tagColor":"#29B5E8","tagPath":"/content/cq:tags/snowflake-site/taxonomy/solution-center/certification/quickstart","tagIcon":""},"quickstartHeroTitle":{"lines":["CoCo Control Hub and Chargeback Solution"],"type":"heading2",":type":"snowflake-site/components/title-v2"},"quickstartHeroAuthor":"Sam Gupta","quickstartHeroFirstSnowflakeFeatureTag":{"tagText":"Cortex LLM","tagColor":"#29B5E8","tagPath":"/content/cq:tags/snowflake-site/taxonomy/snowflake-feature/cortex-llm-functions","tagIcon":""},"quickstartHeroForkRepoLink":{"id":"button-7eb915b9ad","showOutboundIcon":false,"buttonLink":{"valid":true,"attributes":{"target":"_blank"},"url":"https://github.com/Snowflake-Labs/sfquickstarts/tree/master/site/sfguides/src/cortex-code-control-hub-chargeback"},"linkTargetContentType":"GENERIC","linkType":"SNOWFLAKE_EXTERNAL",":type":"snowflake-site/components/button","text":"Fork Repo"},"quickstartHeroBreadcrumbs":[{"title":"CoCo Control Hub and Chargeback Solution","url":"https://www.snowflake.com/content/snowflake-site/global/en/developers/guides/cortex-code-control-hub-chargeback","currentPage":true},{"title":"Guides","url":"https://www.snowflake.com/content/snowflake-site/global/en/developers/guides","currentPage":false},{"title":"Snowflake for Developers","url":"https://www.snowflake.com/content/snowflake-site/global/en/developers","currentPage":false}],"fragmentPath":"/content/dam/snowflake-site/en/content-fragments/quickstarts/cortex-code-control-hub-chargeback",":type":"snowflake-site/components/quickstart/quickstart-hero","isDeveloperGuidesPage":false},"flexible_column_cont":{"id":"flexible-column-container-4ad1c57152","propertiesId":"quickstart-template-main-flexible-container","type":"2-column-75-25","alignColumns":"top","containerMaxWidth":"extra-large","topPadding":"none","bottomPadding":"none","spaceBetween":"small","reverseOnMobile":false,"carouselOnMobile":false,"backgroundImageOption":"none","flexible_column_content_container_1":{"layout":"SIMPLE","id":"container-95eef88812",":type":"snowflake-site/components/flexible-column-container/flexible-column-content-container",":items":{"contentfragment":{"id":"contentfragment-1b40eae458","paragraphs":["&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EOverview\u003C/h2\u003E\n","\u003Cp\u003EDuration: 3\u003C/p\u003E\n","\u003Cp\u003EGovernance tells you \u003Cem\u003Ehow much\u003C/em\u003E Snowflake CoCo costs. \u003Cstrong\u003EChargeback answers \u003Cem\u003Ewho owes what\u003C/em\u003E &mdash; and lets you recover it.\u003C/strong\u003E\u003C/p\u003E\n","\u003Cp\u003EIn this quickstart you'll deploy the \u003Cstrong\u003Echargeback and cost-attribution layer\u003C/strong\u003E of \u003Ca href=\"https://developers.snowflake.com/guides/cortex-code-control-hub/\"\u003ECoCo Control Hub\u003C/a\u003E &mdash; a Streamlit-in-Snowflake app &mdash; and produce a real, itemized bill for CoCo usage. You'll attribute usage with a confidence-labeled waterfall, pick the adoption model that matches your engagement, and export an internal \u003Cstrong\u003Eshowback\u003C/strong\u003E statement or an external \u003Cstrong\u003Einvoice\u003C/strong\u003E as a branded PDF. No data leaves Snowflake.\u003C/p\u003E\n","\u003Ch3\u003EWhat You'll Build\u003C/h3\u003E\n","\u003Cp\u003EBy the end you will have generated, from your own account's data:\u003C/p\u003E\n\u003Cul\u003E\u003Cli\u003EAn \u003Cstrong\u003Eitemized bill\u003C/strong\u003E grouped by team, user, or engagement\u003C/li\u003E\u003Cli\u003EAn \u003Cstrong\u003Einternal showback\u003C/strong\u003E PDF (at cost) and an \u003Cstrong\u003Eexternal invoice\u003C/strong\u003E PDF (with margin)\u003C/li\u003E\u003Cli\u003EA \u003Cstrong\u003Ecost-tag\u003C/strong\u003E mapping that drives vertical/partner attribution\u003C/li\u003E\u003C/ul\u003E\n","\u003Ch3\u003EPrerequisites\u003C/h3\u003E\n\u003Cul\u003E\u003Cli\u003ESnowflake account with \u003Cstrong\u003EACCOUNTADMIN\u003C/strong\u003E (one-time setup only)\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003ECoCo enabled\u003C/strong\u003E, with \u003Cstrong\u003Eat least a few days of real CLI / Snowsight / Desktop usage\u003C/strong\u003E on the account &mdash; the bill is generated from actual \u003Ccode\u003EACCOUNT_USAGE\u003C/code\u003E history, so an account with no CoCo usage will produce an empty bill\u003C/li\u003E\u003Cli\u003ESnowflake CLI installed: \u003Ccode\u003Ecurl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh\u003C/code\u003E\u003C/li\u003E\u003Cli\u003EAny warehouse (XSMALL is sufficient)\u003C/li\u003E\u003C/ul\u003E\n","\u003Ch3\u003EWhat You'll Learn\u003C/h3\u003E\n\u003Cul\u003E\u003Cli\u003EHow CoCo usage is attributed to an identity with a fallback waterfall\u003C/li\u003E\u003Cli\u003EWhy per-query/session tags don't work for CoCo &mdash; and what to use instead\u003C/li\u003E\u003Cli\u003EHow to express three cross-charge scenarios as configuration, not code\u003C/li\u003E\u003Cli\u003EHow to price LLM token credits and warehouse compute independently\u003C/li\u003E\u003Cli\u003EHow to produce a showback vs an invoice from the same underlying data\u003C/li\u003E\u003C/ul\u003E\n","\u003Ch3\u003ESource Code\u003C/h3\u003E\n","\u003Cp\u003E\u003Cstrong\u003EGitHub (Snowflake-Labs):\u003C/strong\u003E https://github.com/Snowflake-Labs/sfquickstarts/tree/master/site/sfguides/src/cortex-code-control-hub-chargeback/assets/code\u003C/p\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EArchitecture\u003C/h2\u003E\n","\u003Cp\u003EDuration: 3\u003C/p\u003E\n","\u003Ch3\u003EOne Configurable App, Not Three\u003C/h3\u003E\n","\u003Cp\u003EThe three adoption models are \u003Cstrong\u003Epresets of two knobs\u003C/strong\u003E &mdash; \u003Cem\u003Ewhat you group by\u003C/em\u003E (attribution dimension) and \u003Cem\u003Ewho you're billing\u003C/em\u003E (internal vs external) &mdash; not separate code paths.\u003C/p\u003E\n","\u003Cp\u003E\u003Cimg src=\"https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/architecture_flow.png\" alt=\"Attribution and billing flow: ACCOUNT_USAGE through the attribution waterfall to an itemized table, CSV, and branded PDF\"\u003E\u003C/p\u003E\n","\u003Ch3\u003EThe Attribution Waterfall\u003C/h3\u003E\n","\u003Cp\u003EEach usage row is attributed by the \u003Cstrong\u003Ehighest-confidence signal available\u003C/strong\u003E; anything left over is quarantined rather than billed:\u003C/p\u003E\n","\u003Cp\u003E\u003Cimg src=\"https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/attribution_waterfall.png\" alt=\"Attribution waterfall: L3 service account (HIGH) to L4 user cost tag to L5 role (MEDIUM) to an Unattributed Queue that is never billed\"\u003E\u003C/p\u003E\n\u003Ctable\u003E\u003Cthead\u003E\u003Ctr\u003E\u003Cth colspan=\"1\" rowspan=\"1\"\u003ELevel\u003C/th\u003E\u003Cth colspan=\"1\" rowspan=\"1\"\u003ESignal\u003C/th\u003E\u003Cth colspan=\"1\" rowspan=\"1\"\u003EConfidence\u003C/th\u003E\u003C/tr\u003E\u003C/thead\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EL3\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EService-account identity\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EHIGH\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EL4\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EUser cost tag (vertical / partner flag)\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EMEDIUM\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EL5\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003ESnowflake role / cohort\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003EMEDIUM\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003E&mdash;\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003E\u003Cstrong\u003EUnattributed queue\u003C/strong\u003E\u003C/td\u003E\u003Ctd colspan=\"1\" rowspan=\"1\"\u003Enever billed until resolved\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\n\u003Cblockquote\u003E\n","\u003Cp\u003Easide negative\nPer-query and per-session query tags do \u003Cstrong\u003Enot\u003C/strong\u003E work for CoCo &mdash; it overwrites the session query tag. Attribution uses identity-level signals (L3&ndash;L5), not L1/L2 tags.\u003C/p\u003E\n\u003C/blockquote\u003E\n","\u003Ch3\u003ETwo-Rate Pricing\u003C/h3\u003E\n","\u003Cp\u003ELLM token credits are priced at a flat AI list rate (April 2025: \u003Cstrong\u003E$2.00 global / $2.20 in-region\u003C/strong\u003E, editable); warehouse compute is priced at your \u003Cstrong\u003Econtract credit rate\u003C/strong\u003E &mdash; so the bill reflects the true blended cost of CoCo.\u003C/p\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EDeploy the App\u003C/h2\u003E\n","\u003Cp\u003EDuration: 8\u003C/p\u003E\n","\u003Ch3\u003EStep 1: Download and set your deploy target\u003C/h3\u003E\n","\u003Cp\u003EDownload the \u003Ccode\u003Eassets/code\u003C/code\u003E folder from the Source Code link above. Set your target in \u003Cstrong\u003E\u003Ccode\u003Esnowflake.yml\u003C/code\u003E\u003C/strong\u003E (the only file you edit &mdash; or ask CoCo to fill it):\u003C/p\u003E\n\u003Cpre\u003E\u003Ccode class=\"language-yaml\"\u003Eidentifier:\n  name: CORTEX_CODE_CREDIT_MANAGER\n  database: MY_DATABASE       # your target database\n  schema: MY_SCHEMA           # your target schema\nquery_warehouse: MY_WAREHOUSE # your warehouse\n\u003C/code\u003E\u003C/pre\u003E\n\u003Cblockquote\u003E\n","\u003Cp\u003Easide positive\nLeave \u003Ccode\u003Econfig.yaml\u003C/code\u003E's deployment fields blank &mdash; the app self-resolves database/schema at runtime (sidebar override, then \u003Ccode\u003Econfig.yaml\u003C/code\u003E, then \u003Ccode\u003ECURRENT_DATABASE()\u003C/code\u003E/\u003Ccode\u003ECURRENT_SCHEMA()\u003C/code\u003E). There is nothing else to configure.\u003C/p\u003E\n\u003C/blockquote\u003E\n","\u003Ch3\u003EStep 2: Deploy\u003C/h3\u003E\n\u003Cpre\u003E\u003Ccode class=\"language-bash\"\u003Esnow streamlit deploy --connection YOUR_CONNECTION --replace\n\u003C/code\u003E\u003C/pre\u003E\n","\u003Cp\u003E\u003Cstrong\u003EExpected result:\u003C/strong\u003E the command prints a URL to the deployed Streamlit app under your database/schema.\u003C/p\u003E\n","\u003Ch3\u003EStep 3: Run in-app Setup\u003C/h3\u003E\n","\u003Cp\u003EOpen the app in Snowsight and go to \u003Cstrong\u003ESetup\u003C/strong\u003E. Run each phase in order (all idempotent):\u003C/p\u003E\n\u003Col\u003E\u003Cli\u003E\u003Cstrong\u003ERun Check\u003C/strong\u003E &mdash; verifies required objects\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003ECreate Missing Objects\u003C/strong\u003E &mdash; runs \u003Ccode\u003Eprerequisites.sql\u003C/code\u003E; creates all \u003Ccode\u003ECC_*\u003C/code\u003E tables, stored procedures, and tasks (including the chargeback tables and the cost-tag sync procedure)\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003ESeed Default Settings\u003C/strong\u003E &mdash; pricing + config defaults\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003ERun Initial Data Refresh\u003C/strong\u003E &mdash; backfills usage and warehouse-attribution summaries\u003C/li\u003E\u003C/ol\u003E\n","\u003Cp\u003E\u003Cstrong\u003EExpected result:\u003C/strong\u003E Setup shows all checks green, and the \u003Cstrong\u003ECost Attribution\u003C/strong\u003E page shows usage for the last 30 days. If it's empty, confirm the account has recent CoCo usage (see Prerequisites).\u003C/p\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003ETag Users for Attribution\u003C/h2\u003E\n","\u003Cp\u003EDuration: 5\u003C/p\u003E\n","\u003Cp\u003EOpen \u003Cstrong\u003EAttribution &amp; Tags\u003C/strong\u003E.\u003C/p\u003E\n\u003Col\u003E\u003Cli\u003EReview the \u003Cstrong\u003Ewaterfall\u003C/strong\u003E panel &mdash; see how each signal (service account, then user tag, then role) is applied and what lands in the \u003Cstrong\u003EUnattributed\u003C/strong\u003E queue.\u003C/li\u003E\u003Cli\u003EIn the \u003Cstrong\u003Ecost-tag editor\u003C/strong\u003E, assign each active CoCo user a \u003Cstrong\u003EVertical\u003C/strong\u003E (e.g., \u003Ccode\u003EData Platform\u003C/code\u003E, \u003Ccode\u003EMarketing\u003C/code\u003E) and set the \u003Cstrong\u003EPartner\u003C/strong\u003E flag where relevant.\u003C/li\u003E\u003Cli\u003EClick \u003Cstrong\u003ESave\u003C/strong\u003E.\u003C/li\u003E\u003C/ol\u003E\n","\u003Cp\u003E\u003Cstrong\u003EExpected result:\u003C/strong\u003E the grid persists to \u003Ccode\u003ECC_COST_TAGS\u003C/code\u003E, and the \u003Cstrong\u003EVertical\u003C/strong\u003E and \u003Cstrong\u003EPartner flag\u003C/strong\u003E dimensions become selectable on the Chargeback page (they're greyed out until at least one tag exists).\u003C/p\u003E\n\u003Cblockquote\u003E\n","\u003Cp\u003Easide positive\nIf your account already tags users natively, enable auto-sync &mdash; the nightly \u003Ccode\u003ESP_CC_SYNC_COST_TAGS\u003C/code\u003E mirrors \u003Ccode\u003EACCOUNT_USAGE.TAG_REFERENCES\u003C/code\u003E into \u003Ccode\u003ECC_COST_TAGS\u003C/code\u003E read-only. The app never modifies account objects.\u003C/p\u003E\n\u003C/blockquote\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EGenerate an Internal Showback\u003C/h2\u003E\n","\u003Cp\u003EDuration: 6\u003C/p\u003E\n","\u003Cp\u003EOpen \u003Cstrong\u003EChargeback\u003C/strong\u003E. First pick an adoption model, then walk the four steps.\u003C/p\u003E\n","\u003Cp\u003E\u003Cstrong\u003EChoose a model\u003C/strong\u003E &mdash; click the \u003Cstrong\u003EM1 &middot; Internal Cross-Charge\u003C/strong\u003E card. This pre-fills \u003Cem\u003EBill by = Vertical\u003C/em\u003E and \u003Cem\u003EAudience = Internal showback\u003C/em\u003E.\u003C/p\u003E\n\u003Col\u003E\u003Cli\u003E\u003Cstrong\u003EBill by\u003C/strong\u003E &mdash; leave as \u003Cstrong\u003EVertical\u003C/strong\u003E (or choose User/Role to try without tags).\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EScope\u003C/strong\u003E &mdash; set \u003Cstrong\u003ELookback = 30 days\u003C/strong\u003E.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EAudience\u003C/strong\u003E &mdash; \u003Cstrong\u003EInternal &middot; showback\u003C/strong\u003E is selected; enter a \u003Cstrong\u003EPrepared for\u003C/strong\u003E value (e.g., \u003Ccode\u003EData Platform team\u003C/code\u003E).\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EGenerate.\u003C/strong\u003E\u003C/li\u003E\u003C/ol\u003E\n","\u003Cp\u003E\u003Cstrong\u003EExpected result:\u003C/strong\u003E\u003C/p\u003E\n\u003Cul\u003E\u003Cli\u003EKPI tiles populate: \u003Cstrong\u003ETotal Credits\u003C/strong\u003E, \u003Cstrong\u003ECost (USD)\u003C/strong\u003E, \u003Cstrong\u003EShowback (at cost)\u003C/strong\u003E, \u003Cstrong\u003ELine Items\u003C/strong\u003E.\u003C/li\u003E\u003Cli\u003EAn itemized table lists one row per vertical with credits and USD.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EDownload Chargeback PDF\u003C/strong\u003E produces a one-page \u003Cstrong\u003ESHOWBACK\u003C/strong\u003E statement whose header reads \u003Cstrong\u003EPREPARED FOR: Data Platform team\u003C/strong\u003E.\u003C/li\u003E\u003C/ul\u003E\n\u003Cblockquote\u003E\n","\u003Cp\u003Easide positive\nToggle \u003Cstrong\u003EInclude SQL / warehouse cost\u003C/strong\u003E to add the warehouse compute CoCo consumed (priced at your contract rate) &mdash; the KPI and composition bar update to show the AI-vs-warehouse split.\u003C/p\u003E\n\u003C/blockquote\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EGenerate an External Invoice\u003C/h2\u003E\n","\u003Cp\u003EDuration: 5\u003C/p\u003E\n","\u003Cp\u003ENow bill an outside party from the same data.\u003C/p\u003E\n","\u003Cp\u003E\u003Cstrong\u003EChoose a model\u003C/strong\u003E &mdash; click \u003Cstrong\u003EM3 &middot; Partner on Customer Account\u003C/strong\u003E (pre-fills \u003Cem\u003EBill by = User\u003C/em\u003E, \u003Cem\u003EAudience = External invoice\u003C/em\u003E).\u003C/p\u003E\n\u003Col\u003E\u003Cli\u003E\u003Cstrong\u003EAudience\u003C/strong\u003E &mdash; confirm \u003Cstrong\u003EExternal &middot; invoice\u003C/strong\u003E; set \u003Cstrong\u003EMargin %\u003C/strong\u003E = \u003Ccode\u003E15\u003C/code\u003E.\u003C/li\u003E\u003Cli\u003EFill \u003Cstrong\u003EBill to\u003C/strong\u003E (e.g., \u003Ccode\u003EAcme Corp\u003C/code\u003E), an \u003Cstrong\u003EInvoice #\u003C/strong\u003E, and \u003Cstrong\u003EPrepared by\u003C/strong\u003E.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EGenerate.\u003C/strong\u003E\u003C/li\u003E\u003C/ol\u003E\n","\u003Cp\u003E\u003Cstrong\u003EExpected result:\u003C/strong\u003E\u003C/p\u003E\n\u003Cul\u003E\u003Cli\u003EThe \u003Cstrong\u003EBilled\u003C/strong\u003E KPI now exceeds \u003Cstrong\u003ECost (USD)\u003C/strong\u003E by your margin.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EDownload Chargeback PDF\u003C/strong\u003E produces an \u003Cstrong\u003EINVOICE\u003C/strong\u003E with a \u003Cstrong\u003EBILL TO\u003C/strong\u003E block, a subtotal, a margin line, and a total.\u003C/li\u003E\u003C/ul\u003E\n","\u003Cp\u003E\u003Cimg src=\"https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/invoice_pdf.png\" alt=\"Sample branded invoice PDF generated by the app\"\u003E\u003C/p\u003E\n\u003Cblockquote\u003E\n","\u003Cp\u003Easide positive\nSame data, two outputs: internal cross-charge is at-cost showback; external delivery is an invoice with margin. That's the &quot;one configurable app&quot; design &mdash; you changed audience, not code.\u003C/p\u003E\n\u003C/blockquote\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EOptional: Optimize with Model Bake-off\u003C/h2\u003E\n","\u003Cp\u003EDuration: 3\u003C/p\u003E\n","\u003Cp\u003EOpen \u003Cstrong\u003EModel Bake-off\u003C/strong\u003E to keep spend efficient:\u003C/p\u003E\n\u003Cul\u003E\u003Cli\u003E\u003Cstrong\u003EHistorical Optimization\u003C/strong\u003E &mdash; per-model credit spend and token efficiency, with downgrade recommendations for expensive tiers carrying heavy volume.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EInteractive Bake-off\u003C/strong\u003E &mdash; run one prompt across models discovered live from your account (\u003Ccode\u003ESHOW CORTEX BASE MODELS\u003C/code\u003E) and compare cost, latency, and an LLM-judged quality score.\u003C/li\u003E\u003C/ul\u003E\n&lt;!-- ------------------------ --&gt;\n","\u003Ch2\u003EConclusion And Resources\u003C/h2\u003E\n","\u003Cp\u003EDuration: 2\u003C/p\u003E\n","\u003Ch3\u003EWhat You Built\u003C/h3\u003E\n\u003Cul\u003E\u003Cli\u003EAttributed CoCo spend with a confidence-labeled waterfall\u003C/li\u003E\u003Cli\u003EGenerated both an \u003Cstrong\u003Einternal showback\u003C/strong\u003E and an \u003Cstrong\u003Eexternal invoice\u003C/strong\u003E from the same period\u003C/li\u003E\u003Cli\u003EExported branded PDF bills &mdash; with data never leaving Snowflake\u003C/li\u003E\u003C/ul\u003E\n","\u003Ch3\u003EThe Pattern\u003C/h3\u003E\n","\u003Cp\u003EAttribution-as-configuration &mdash; one app, two knobs (dimension x audience) &mdash; generalizes beyond CoCo to any usage you need to split across teams, customers, or partners.\u003C/p\u003E\n","\u003Ch3\u003ETroubleshooting\u003C/h3\u003E\n\u003Cul\u003E\u003Cli\u003E\u003Cstrong\u003EEmpty bill / &quot;No billable usage found&quot;\u003C/strong\u003E &mdash; the account has no CoCo usage in the selected window, or the refresh task hasn't run. Re-run \u003Cstrong\u003ESetup, then Run Initial Data Refresh\u003C/strong\u003E and widen the lookback.\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EVertical/Partner greyed out\u003C/strong\u003E &mdash; no cost tags yet; add at least one in \u003Cstrong\u003EAttribution &amp; Tags\u003C/strong\u003E.\u003C/li\u003E\u003C/ul\u003E\n","\u003Ch3\u003EResources\u003C/h3\u003E\n\u003Cul\u003E\u003Cli\u003E\u003Cstrong\u003ESource Code (Snowflake-Labs):\u003C/strong\u003E https://github.com/Snowflake-Labs/sfquickstarts/tree/master/site/sfguides/src/cortex-code-control-hub-chargeback/assets/code\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003ECoCo Docs:\u003C/strong\u003E https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code\u003C/li\u003E\u003Cli\u003E\u003Cstrong\u003EStreamlit in Snowflake:\u003C/strong\u003E https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit\u003C/li\u003E\u003C/ul\u003E"],"description":"","title":"Base Quickstart CF","elements":{"quickstartArticleBody":{"title":"Quickstart Article Body","dataType":"string","value":"\u003C!-- ------------------------ --\u003E\n## Overview\nDuration: 3\n\nGovernance tells you *how much* Snowflake CoCo costs. **Chargeback answers *who owes what* — and lets you recover it.**\n\nIn this quickstart you'll deploy the **chargeback and cost-attribution layer** of [CoCo Control Hub](https://developers.snowflake.com/guides/cortex-code-control-hub/) — a Streamlit-in-Snowflake app — and produce a real, itemized bill for CoCo usage. You'll attribute usage with a confidence-labeled waterfall, pick the adoption model that matches your engagement, and export an internal **showback** statement or an external **invoice** as a branded PDF. No data leaves Snowflake.\n\n### What You'll Build\nBy the end you will have generated, from your own account's data:\n- An **itemized bill** grouped by team, user, or engagement\n- An **internal showback** PDF (at cost) and an **external invoice** PDF (with margin)\n- A **cost-tag** mapping that drives vertical/partner attribution\n\n### Prerequisites\n- Snowflake account with **ACCOUNTADMIN** (one-time setup only)\n- **CoCo enabled**, with **at least a few days of real CLI / Snowsight / Desktop usage** on the account — the bill is generated from actual `ACCOUNT_USAGE` history, so an account with no CoCo usage will produce an empty bill\n- Snowflake CLI installed: `curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh`\n- Any warehouse (XSMALL is sufficient)\n\n### What You'll Learn\n- How CoCo usage is attributed to an identity with a fallback waterfall\n- Why per-query/session tags don't work for CoCo — and what to use instead\n- How to express three cross-charge scenarios as configuration, not code\n- How to price LLM token credits and warehouse compute independently\n- How to produce a showback vs an invoice from the same underlying data\n\n### Source Code\n**GitHub (Snowflake-Labs):** https://github.com/Snowflake-Labs/sfquickstarts/tree/master/site/sfguides/src/cortex-code-control-hub-chargeback/assets/code\n\n\u003C!-- ------------------------ --\u003E\n## Architecture\nDuration: 3\n\n### One Configurable App, Not Three\nThe three adoption models are **presets of two knobs** — *what you group by* (attribution dimension) and *who you're billing* (internal vs external) — not separate code paths.\n\n![Attribution and billing flow: ACCOUNT_USAGE through the attribution waterfall to an itemized table, CSV, and branded PDF](https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/architecture_flow.png)\n\n### The Attribution Waterfall\nEach usage row is attributed by the **highest-confidence signal available**; anything left over is quarantined rather than billed:\n\n![Attribution waterfall: L3 service account (HIGH) to L4 user cost tag to L5 role (MEDIUM) to an Unattributed Queue that is never billed](https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/attribution_waterfall.png)\n\n| Level | Signal | Confidence |\n|---|---|---|\n| L3 | Service-account identity | HIGH |\n| L4 | User cost tag (vertical / partner flag) | MEDIUM |\n| L5 | Snowflake role / cohort | MEDIUM |\n| — | **Unattributed queue** | never billed until resolved |\n\n\u003E aside negative\n\u003E Per-query and per-session query tags do **not** work for CoCo — it overwrites the session query tag. Attribution uses identity-level signals (L3–L5), not L1/L2 tags.\n\n### Two-Rate Pricing\nLLM token credits are priced at a flat AI list rate (April 2025: **$2.00 global / $2.20 in-region**, editable); warehouse compute is priced at your **contract credit rate** — so the bill reflects the true blended cost of CoCo.\n\n\u003C!-- ------------------------ --\u003E\n## Deploy the App\nDuration: 8\n\n### Step 1: Download and set your deploy target\nDownload the `assets/code` folder from the Source Code link above. Set your target in **`snowflake.yml`** (the only file you edit — or ask CoCo to fill it):\n\n```yaml\nidentifier:\n  name: CORTEX_CODE_CREDIT_MANAGER\n  database: MY_DATABASE       # your target database\n  schema: MY_SCHEMA           # your target schema\nquery_warehouse: MY_WAREHOUSE # your warehouse\n```\n\n\u003E aside positive\n\u003E Leave `config.yaml`'s deployment fields blank — the app self-resolves database/schema at runtime (sidebar override, then `config.yaml`, then `CURRENT_DATABASE()`/`CURRENT_SCHEMA()`). There is nothing else to configure.\n\n### Step 2: Deploy\n\n```bash\nsnow streamlit deploy --connection YOUR_CONNECTION --replace\n```\n\n**Expected result:** the command prints a URL to the deployed Streamlit app under your database/schema.\n\n### Step 3: Run in-app Setup\nOpen the app in Snowsight and go to **Setup**. Run each phase in order (all idempotent):\n\n1. **Run Check** — verifies required objects\n2. **Create Missing Objects** — runs `prerequisites.sql`; creates all `CC_*` tables, stored procedures, and tasks (including the chargeback tables and the cost-tag sync procedure)\n3. **Seed Default Settings** — pricing + config defaults\n4. **Run Initial Data Refresh** — backfills usage and warehouse-attribution summaries\n\n**Expected result:** Setup shows all checks green, and the **Cost Attribution** page shows usage for the last 30 days. If it's empty, confirm the account has recent CoCo usage (see Prerequisites).\n\n\u003C!-- ------------------------ --\u003E\n## Tag Users for Attribution\nDuration: 5\n\nOpen **Attribution & Tags**.\n\n1. Review the **waterfall** panel — see how each signal (service account, then user tag, then role) is applied and what lands in the **Unattributed** queue.\n2. In the **cost-tag editor**, assign each active CoCo user a **Vertical** (e.g., `Data Platform`, `Marketing`) and set the **Partner** flag where relevant.\n3. Click **Save**.\n\n**Expected result:** the grid persists to `CC_COST_TAGS`, and the **Vertical** and **Partner flag** dimensions become selectable on the Chargeback page (they're greyed out until at least one tag exists).\n\n\u003E aside positive\n\u003E If your account already tags users natively, enable auto-sync — the nightly `SP_CC_SYNC_COST_TAGS` mirrors `ACCOUNT_USAGE.TAG_REFERENCES` into `CC_COST_TAGS` read-only. The app never modifies account objects.\n\n\u003C!-- ------------------------ --\u003E\n## Generate an Internal Showback\nDuration: 6\n\nOpen **Chargeback**. First pick an adoption model, then walk the four steps.\n\n**Choose a model** — click the **M1 · Internal Cross-Charge** card. This pre-fills *Bill by = Vertical* and *Audience = Internal showback*.\n\n1. **Bill by** — leave as **Vertical** (or choose User/Role to try without tags).\n2. **Scope** — set **Lookback = 30 days**.\n3. **Audience** — **Internal · showback** is selected; enter a **Prepared for** value (e.g., `Data Platform team`).\n4. **Generate.**\n\n**Expected result:**\n- KPI tiles populate: **Total Credits**, **Cost (USD)**, **Showback (at cost)**, **Line Items**.\n- An itemized table lists one row per vertical with credits and USD.\n- **Download Chargeback PDF** produces a one-page **SHOWBACK** statement whose header reads **PREPARED FOR: Data Platform team**.\n\n\u003E aside positive\n\u003E Toggle **Include SQL / warehouse cost** to add the warehouse compute CoCo consumed (priced at your contract rate) — the KPI and composition bar update to show the AI-vs-warehouse split.\n\n\u003C!-- ------------------------ --\u003E\n## Generate an External Invoice\nDuration: 5\n\nNow bill an outside party from the same data.\n\n**Choose a model** — click **M3 · Partner on Customer Account** (pre-fills *Bill by = User*, *Audience = External invoice*).\n\n1. **Audience** — confirm **External · invoice**; set **Margin %** = `15`.\n2. Fill **Bill to** (e.g., `Acme Corp`), an **Invoice #**, and **Prepared by**.\n3. **Generate.**\n\n**Expected result:**\n- The **Billed** KPI now exceeds **Cost (USD)** by your margin.\n- **Download Chargeback PDF** produces an **INVOICE** with a **BILL TO** block, a subtotal, a margin line, and a total.\n\n![Sample branded invoice PDF generated by the app](https://www.snowflake.com/content/dam/snowflake-site/developers/guides/cortex-code-control-hub-chargeback/invoice_pdf.png)\n\n\u003E aside positive\n\u003E Same data, two outputs: internal cross-charge is at-cost showback; external delivery is an invoice with margin. That's the \"one configurable app\" design — you changed audience, not code.\n\n\u003C!-- ------------------------ --\u003E\n## Optional: Optimize with Model Bake-off\nDuration: 3\n\nOpen **Model Bake-off** to keep spend efficient:\n- **Historical Optimization** — per-model credit spend and token efficiency, with downgrade recommendations for expensive tiers carrying heavy volume.\n- **Interactive Bake-off** — run one prompt across models discovered live from your account (`SHOW CORTEX BASE MODELS`) and compare cost, latency, and an LLM-judged quality score.\n\n\u003C!-- ------------------------ --\u003E\n## Conclusion And Resources\nDuration: 2\n\n### What You Built\n- Attributed CoCo spend with a confidence-labeled waterfall\n- Generated both an **internal showback** and an **external invoice** from the same period\n- Exported branded PDF bills — with data never leaving Snowflake\n\n### The Pattern\nAttribution-as-configuration — one app, two knobs (dimension x audience) — generalizes beyond CoCo to any usage you need to split across teams, customers, or partners.\n\n### Troubleshooting\n- **Empty bill / \"No billable usage found\"** — the account has no CoCo usage in the selected window, or the refresh task hasn't run. Re-run **Setup, then Run Initial Data Refresh** and widen the lookback.\n- **Vertical/Partner greyed out** — no cost tags yet; add at least one in **Attribution & Tags**.\n\n### Resources\n- **Source Code (Snowflake-Labs):** https://github.com/Snowflake-Labs/sfquickstarts/tree/master/site/sfguides/src/cortex-code-control-hub-chargeback/assets/code\n- **CoCo Docs:** https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code\n- **Streamlit in Snowflake:** https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit\n","multiValue":false,":type":"text/x-markdown"},"quickstartArticleLogoImage":{"title":"Quickstart Article Logo Image","dataType":"string","multiValue":false,":type":"text/plain"}},"elementsOrder":["quickstartArticleBody","quickstartArticleLogoImage"],":type":"snowflake-site/components/contentfragment",":items":{},":itemsOrder":[],"isDeveloperGuidesPage":false,"model":"snowflake-site/models/quickstart-article"},"flexible_column_cont":{"id":"flexible-column-container-fffe8e73ca","type":"2-column-75-25","alignColumns":"top","containerMaxWidth":"extra-large","topPadding":"none","bottomPadding":"none","spaceBetween":"none","reverseOnMobile":false,"carouselOnMobile":false,"backgroundImageOption":"none","flexible_column_content_container_1":{"layout":"SIMPLE","id":"container-ef1a2907dd",":type":"snowflake-site/components/flexible-column-container/flexible-column-content-container",":items":{"quickstart_last_modi":{"id":"quickstart-last-modified-fead2e386a","icon":{"id":"icon","icon":"calendar",":type":"snowflake-site/components/icon","appliedCssClassNames":"snowflake-icon-blue"},"lastModifiedDatePrefix":"Updated","lastModifiedDate":"2026-08-18",":type":"snowflake-site/components/quickstart/quickstart-last-modified","appliedCssClassNames":"snowflake-responsive-component-top-padding-small"},"text":{"id":"text-1716f7fb2b","additionalClasses":"qs-disclaimer-text","text":"\u003Cp\u003E\u003Cspan style=\"color: #666;\"\u003EThis content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances\u003C/span\u003E\u003C/p\u003E\r\n","richText":true,":type":"snowflake-site/components/text","appliedCssClassNames":"snowflake-responsive-component-top-padding-small"}},":itemsOrder":["quickstart_last_modi","text"]},"flexible_column_content_container_2":{"layout":"SIMPLE","id":"container-ee5c346223",":type":"snowflake-site/components/flexible-column-container/flexible-column-content-container",":items":{},":itemsOrder":[]},"isActiveTOC":false,":type":"snowflake-site/components/flexible-column-container","isBlogPage":false}},":itemsOrder":["contentfragment","flexible_column_cont"]},"flexible_column_content_container_2":{"layout":"SIMPLE","id":"container-a57277185e",":type":"snowflake-site/components/flexible-column-container/flexible-column-content-container",":items":{"quickstart_table_of_":{"layout":"SIMPLE","id":"container-0ddee9849f","isDeveloperGuidesPage":false,":type":"snowflake-site/components/quickstart/quickstart-table-of-content/quickstart-table-of-content-container",":items":{"quickstart_table_of_":{"id":"quickstart-table-of-content-f20a026ef4","fragmentPath":"/content/dam/snowflake-site/en/content-fragments/quickstarts/cortex-code-control-hub-chargeback",":type":"snowflake-site/components/quickstart/quickstart-table-of-content","headings":["\u003Ch2\u003EOverview\u003C/h2\u003E","\u003Ch2\u003EArchitecture\u003C/h2\u003E","\u003Ch2\u003EDeploy the App\u003C/h2\u003E","\u003Ch2\u003ETag Users for Attribution\u003C/h2\u003E","\u003Ch2\u003EGenerate an Internal Showback\u003C/h2\u003E","\u003Ch2\u003EGenerate an External Invoice\u003C/h2\u003E","\u003Ch2\u003EOptional: Optimize with Model Bake-off\u003C/h2\u003E","\u003Ch2\u003EConclusion And Resources\u003C/h2\u003E"]},"quickstart_button":{"id":"quickstart-button-99016f83e1","fragmentPath":"/content/dam/snowflake-site/en/content-fragments/quickstarts/cortex-code-control-hub-chargeback",":type":"snowflake-site/components/quickstart/quickstart-button","appliedCssClassNames":"snowflake-responsive-component-top-padding-none"}},":itemsOrder":["quickstart_table_of_","quickstart_button"]}},":itemsOrder":["quickstart_table_of_"]},"isActiveTOC":false,":type":"snowflake-site/components/flexible-column-container","isBlogPage":false},"markup_editor":{"id":"markup-editor-713550ec54","title":"Page CSS","cssContent":"#quickstart-template-main-flexible-container{padding:24px}#quickstart-template-main-flexible-container \u003E .snowflake-flexible-column-container-items{grid-template-columns:1fr 0}.qs-disclaimer-text p \u003E span{font-size:15px !important}@media (min-width:768px){#quickstart-template-main-flexible-container{padding:24px 32px}#quickstart-template-main-flexible-container \u003E .snowflake-flexible-column-container-items{grid-template-columns:7fr 3fr;gap:48px}}@media (max-width:767px){#quickstart-template-main-flexible-container \u003E .snowflake-flexible-column-container-items{gap:0}}@media (min-width:1024px){#quickstart-template-main-flexible-container{padding:0 92px 48px 92px}#quickstart-template-main-flexible-container \u003E .snowflake-flexible-column-container-items{gap:117px}}","isGSAPEnabled":false,":type":"snowflake-site/components/markup-editor"}},":itemsOrder":["quickstart_hero","flexible_column_cont","markup_editor"],":type":"wcm/foundation/components/responsivegrid"},"modal_container":{"layout":"SIMPLE","id":"container-4c6c794b49",":type":"snowflake-site/components/modal/modal-container",":items":{},":itemsOrder":[]},"experiencefragment-footer":{"id":"experiencefragment-1a389e5301","localizedFragmentVariationPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/footer/master/jcr:content","configured":true,"xfModelPath":"/content/experience-fragments/snowflake-site/language-masters/en/site/footer/master.xfmodel.json",":type":"snowflake-site/components/experiencefragment"},"markup_editor":{"id":"markup-editor-53eaaebb08","title":"Quickstarts Overrides","cssContent":".snowflake-markdown blockquote{padding:24px 32px;background:#f6f9fa;border:1px solid #29b5e8;border-radius:16px}.snowflake-markdown .snowflake-image-container img{width:auto !important;max-width:100%}.snowflake-markdown .snowflake-text ol{padding-left:20px !important}.snowflake-markdown .snowflake-text li{margin:0 0 12px 0 !important}.snowflake-markdown h3.snowflake-markdown-h3{font-size:20px !important;font-family:Texta,sans-serif !important}@media (min-width:768px){.snowflake-markdown h3.snowflake-markdown-h3{font-size:28px !important}}","isGSAPEnabled":false,":type":"snowflake-site/components/markup-editor"}},":itemsOrder":["experiencefragment-banner","experiencefragment-header","markup_editor_1950346551","responsivegrid","modal_container","experiencefragment-footer","markup_editor"],":type":"wcm/foundation/components/responsivegrid"}},":itemsOrder":["root"],"coveoConfig":{"apiKey":"xx335921a6-2a0a-40f2-a167-e390b4766c3d","organizationId":"snowflakecomputingproduction8neljofn","searchHub":"snowflake.com","pipeline":"snowflake.com"},"locale":"en","analyticsDebugMode":false,"analyticsData":{"excludeFromAnalytics":false,"subCategory":"","pageType":"quickstart-page-template","templateName":"quickstart-page-template","siteName":"snowflake","pageUrl":"/content/snowflake-site/global/en/developers/guides/cortex-code-control-hub-chargeback","language":"en","category":"general","pageName":"CoCo Control Hub and Chargeback Solution","contentTags":["snowflake-site:taxonomy/solution-center/certification/quickstart","snowflake-site:taxonomy/snowflake-feature/cortex-llm-functions","snowflake-site:taxonomy/product/ai","snowflake-site:taxonomy/product/applications-and-collaboration"]},"isPasswordProtected":false}
  