{"slug": "snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and", "title": "Snowflake AI Cost Optimization: Where the Spend Comes From, How to Detect It, and How to Control It", "summary": "Snowflake AI workloads, including Cortex AI Inference and Search, create credit-intensive costs that traditional warehouse dashboards miss because a single application request can bundle LLM inference, document fetches, multiple SQL queries and model evaluations. The article recommends a FinOps architecture that separates anomaly detection from remediation and provides Snowflake Account Usage queries against METERING_DAILY_HISTORY, CORTEX_AI_FUNCTIONS_USAGE_HISTORY and CORTEX_SEARCH_DAILY_USAGE_HISTORY to attribute AI credits by function, model, query and database. It warns that the service-name filter in the metering query is a discovery tool rather than complete billing reconciliation and that combining AI Functions and Cortex Search views risks double-counting embedding credits.", "body_md": "*Understanding and controlling costs of Snowflake AI from Cortex AI Inference & Search, through to experimental development, retries and out-of-control workloads.*\n\nSnowflake AI brings a new complexity to managing costs.\n\nSnowflake has traditionally been optimized around warehouse sizes, query performance, auto suspend, storage and pipeline costs. With AI workloads there are some new complexities.\n\nAn application request could contain many elements including, LLM inference, document fetch, multiple SQL queries and multiple model evaluations. During experimentation a developer could make many AI requests, often without knowing they have created dozens of AI requests.\n\nThe main issue with Snowflake AI is that it is a credit intensive process and can be a bit of a stealth cost. This makes it hard to track with traditional dashboards.\n\n**In this article I will discuss:**\n\nDepending on the feature, deployment type and pricing, there can be a number of costs associated with your AI workloads.\n\nNot all AI costs will be warehouse related. There may be multiple costing elements including AI service usage, warehouse compute and additional service costs. Before you start calculating any costs, please check your current pricing documentation for your region, cloud and contract. The credit rate and metering will depend on the feature.\n\nA good FinOps architecture for AI will allow you to understand where costs are being used, who is using them (project/developer), identify anomalies and allow for the correct remediation.\n\n*Reference Architecture for AI Consumption Monitoring, Attribution, Anomaly Detection and Remediation.*\n\nIt is important to ensure that your detection and remediation are separated. When you identify an anomaly you should investigate. If you want to automatically cancel production AI workloads you need a higher level of protection.\n\nThe queries below utilizeSnowflake Account Usage views. They are a good starting point for building your operational cost monitoring tool.\n\n```\nSELECT    USAGE_DATE,    SERVICE_TYPE,    SUM(CREDITS_USED) AS CREDITS_USEDFROM SNOWFLAKE.ACCOUNT_USAGE.METERING_DAILY_HISTORYWHERE USAGE_DATE >= DATEADD(DAY, -30, CURRENT_DATE())  AND (      SERVICE_TYPE ILIKE '%AI%'      OR SERVICE_TYPE ILIKE '%CORTEX%'      OR SERVICE_TYPE ILIKE '%COCO%'  )GROUP BY 1, 2ORDER BY USAGE_DATE DESC, CREDITS_USED DESC;\n```\n\nThis provides a high-level breakdown of metered AI-related services. Treat the service-name filter as a discovery query, not a complete billing reconciliation: confirm the service types in your account against Snowflake’s current metering documentation.\n\n```\nSELECT    FUNCTION_NAME,    MODEL_NAME,    COUNT(DISTINCT QUERY_ID) AS QUERY_COUNT,    ROUND(SUM(CREDITS), 4) AS AI_CREDITSFROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AI_FUNCTIONS_USAGE_HISTORYWHERE START_TIME >= DATEADD(DAY, -7, CURRENT_TIMESTAMP())GROUP BY 1, 2ORDER BY AI_CREDITS DESC;\n```\n\nThis helps identify which functions and models consume the most AI credits. The view records AI-function credits separately from warehouse credits, and long-running queries can have multiple hourly records.\n\n```\nSELECT    QUERY_ID,    MODEL_NAME,    FUNCTION_NAME,    MIN(START_TIME) AS FIRST_SEEN,    MAX(END_TIME) AS LAST_SEEN,    SUM(CREDITS) AS AI_CREDITSFROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AI_FUNCTIONS_USAGE_HISTORYWHERE START_TIME >= DATEADD(DAY, -7, CURRENT_TIMESTAMP())GROUP BY 1, 2, 3ORDER BY AI_CREDITS DESCLIMIT 25;\n```\n\nThis is particularly useful for finding bulk AI processing queries that invoke a model across many records.\n\n```\nSELECT    DATABASE_NAME,    SCHEMA_NAME,    SERVICE_NAME,    CONSUMPTION_TYPE,    ROUND(SUM(CREDITS), 4) AS CREDITSFROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_SEARCH_DAILY_USAGE_HISTORYWHERE USAGE_DATE >= DATEADD(DAY, -30, CURRENT_DATE())GROUP BY 1, 2, 3, 4ORDER BY CREDITS DESC;\n```\n\nThe consumption categories distinguish serving, embedding, and batch usage. When combining this view with AI Functions usage, avoid double-counting embedding credits.\n\nFirst, assign meaningful query tags in your development sessions:\n\n```\nALTER SESSION SET QUERY_TAG =  'project=ai_cost_monitor;env=dev;team=data_engineering';\n```\n\nThen investigate the most expensive AI queries alongside query history:\n\n```\nWITH AI_COST AS (    SELECT        QUERY_ID,        SUM(CREDITS) AS AI_CREDITS    FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AI_FUNCTIONS_USAGE_HISTORY    WHERE START_TIME >= DATEADD(DAY, -7, CURRENT_TIMESTAMP())    GROUP BY QUERY_ID)SELECT    Q.USER_NAME,    Q.QUERY_TAG,    COUNT(*) AS QUERY_COUNT,    ROUND(SUM(A.AI_CREDITS), 4) AS AI_CREDITSFROM AI_COST AJOIN SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY Q  ON A.QUERY_ID = Q.QUERY_IDGROUP BY 1, 2ORDER BY AI_CREDITS DESC;\n```\n\nThis attributes AI-function spending to the SQL user and query tag where query-history records are available. It does not necessarily identify the end user behind a shared service account.\n\nAn effective monitoring system should distinguish a normal increase in usage from an abnormal one.\n\nFor example, suppose your development environment usually consumes 10 AI credits daily, but suddenly consumes 80.\n\nIllustrative AI credit consumption\n\n*Friday’s eightfold increase deserves investigation, but is not automatically evidence of waste.*\n\nA simple first step is to compare today’s usage with the previous seven days.\n\n```\nWITH DAILY AS (    SELECT        USAGE_DATE,        SUM(CREDITS_USED) AS CREDITS    FROM SNOWFLAKE.ACCOUNT_USAGE.METERING_DAILY_HISTORY    WHERE SERVICE_TYPE = 'AI_FUNCTIONS'      AND USAGE_DATE >= DATEADD(DAY, -8, CURRENT_DATE())    GROUP BY 1),BASELINE AS (    SELECT AVG(CREDITS) AS AVG_CREDITS    FROM DAILY    WHERE USAGE_DATE BETWEEN        DATEADD(DAY, -7, CURRENT_DATE())        AND DATEADD(DAY, -1, CURRENT_DATE()))SELECT    D.USAGE_DATE,    D.CREDITS,    B.AVG_CREDITS,    ROUND(D.CREDITS / NULLIF(B.AVG_CREDITS, 0), 2)        AS BASELINE_MULTIPLIERFROM DAILY DCROSS JOIN BASELINE BWHERE D.USAGE_DATE = CURRENT_DATE();\n```\n\nThis example monitors the AI_FUNCTIONS service type. For a complete AI budget, reconcile all applicable AI service types rather than relying on a single category. Daily metering may also be delayed, so use the appropriate feature-specific views for more timely detection.\n\nDevelopment is one of the easiest places to accumulate AI spending without noticing it.\n\nConsider a developer building a product-review classification pipeline.\n\nThe initial experiment processes 100 customer reviews. Everything works, so the developer runs the same logic against 100,000 records.\n\nBut the SQL query invokes an AI function once per row.\n\nThe result is potentially 100,000 model evaluations from a single SQL statement.\n\nHere are common development scenarios that create unexpected costs.\n\n```\nSELECT    REVIEW_ID,    AI_SENTIMENT(REVIEW_TEXT) AS SENTIMENTFROM CUSTOMER_REVIEWS;\n```\n\nThis is straightforward SQL, but processing a large table can generate substantial AI usage.\n\nA safer development approach:\n\n```\nSELECT    REVIEW_ID,    AI_SENTIMENT(REVIEW_TEXT) AS SENTIMENTFROM CUSTOMER_REVIEWSWHERE REVIEW_TEXT IS NOT NULLORDER BY REVIEW_IDLIMIT 100;\n```\n\nThe second query limits the input to 100 records. It is useful for controlled experimentation, although you should not assume that adding LIMIT to every SQL shape guarantees a corresponding reduction in AI evaluations. For expensive workloads, explicitly materialize the sample before invoking AI.\n\n```\nCREATE OR REPLACE TEMP TABLE REVIEW_SAMPLE ASSELECT REVIEW_ID, REVIEW_TEXTFROM CUSTOMER_REVIEWSWHERE REVIEW_TEXT IS NOT NULLORDER BY REVIEW_IDLIMIT 100;\nSELECT    REVIEW_ID,    AI_SENTIMENT(REVIEW_TEXT) AS SENTIMENTFROM REVIEW_SAMPLE;\n```\n\nThis creates a bounded input dataset before inference begins.\n\nI recommend a five-layer approach.\n\nSnowflake now documents AI-specific resource and shared budgets, as well as per-user quotas for supported features. Budget actions are periodic rather than instantaneous; quotas can block additional requests more quickly.\n\nFor an organization introducing Snowflake AI, I would start with these policies:\n\nThese controls should be applied based on workload criticality. A research experiment and a customer-facing production application should not have identical enforcement rules.\n\nOne of the most useful metrics is not simply total credits.\n\nIt is cost per successful business outcome.\n\nFor example, suppose a document classification application consumes 120 credits to process 40,000 documents, of which 36,000 are successfully classified.\n\nThese are illustrative calculations, not observed Snowflake performance.\n\nAn optimization that reduces total credits but significantly increases classification errors may actually worsen business economics.\n\nTrack inference cost alongside accuracy, latency, retries, and successful outcomes.\n\nA practical Snowflake AI FinOps rollout can be organized into four phases.\n\nAs Snowflake AI adoption grows, cost optimization must extend beyond warehouse sizing and query tuning.\n\nAI workloads introduce new consumption patterns: token processing, document extraction, search serving, multi-step agent execution, and repeated development experimentation.\n\nThe most effective approach is to establish visibility first, identify which workloads drive spending, then introduce controls that preserve useful AI capabilities without allowing uncontrolled consumption.\n\nThe objective is not to minimize every AI credit. It is to ensure that every AI workload delivers measurable value at a predictable cost.\n\nThe question data engineering teams should ask is no longer just, “How much did Snowflake cost?” It is, “Which AI workloads created that cost, why did they consume those resources, and what value did we receive?”\n\n[Snowflake AI Cost Optimization: Where the Spend Comes From, How to Detect It, and How to Control It](https://pub.towardsai.net/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and-how-to-control-it-a31acff1a8de) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and", "canonical_source": "https://pub.towardsai.net/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and-how-to-control-it-a31acff1a8de?source=rss----98111c9905da---4", "published_at": "2026-11-16 04:56:00+00:00", "updated_at": "2026-11-16 05:23:40.987291+00:00", "lang": "en", "topics": ["ai-infrastructure", "mlops", "ai-products"], "entities": ["Snowflake", "Cortex AI", "Cortex Search", "Snowflake Account Usage"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and", "markdown": "https://wpnews.pro/news/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and.md", "text": "https://wpnews.pro/news/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and.txt", "jsonld": "https://wpnews.pro/news/snowflake-ai-cost-optimization-where-the-spend-comes-from-how-to-detect-it-and.jsonld"}}