Tutorials

Optimizing Snowflake AI Costs by Identifying Spending Sources, Detecting Waste, and Controlling Expenditure

Snowflake AI workloads can create hidden Cortex credit spend. Teams need usage views, attribution, anomaly detection, and controlled remediation.

Optimizing Snowflake AI Costs by Identifying Spending Sources, Detecting Waste, and Controlling Expenditure

Key Takeaways

  • Snowflake AI costs are hard to track because AI workloads add credit-intensive, non-warehouse spend such as Cortex AI Functions, Cortex Search, retries, and experimental development usage.
  • Effective AI cost monitoring should identify where spend occurs, who is responsible, what is abnormal, and what remediation is needed, while keeping detection and automatic cancellation separate.
  • Snowflake Account Usage views, such as METERING_DAILY_HISTORY, CORTEX_AI_FUNCTIONS_USAGE_HISTORY, and CORTEX_SEARCH_DAILY_USAGE_HISTORY, can be used to break down AI credits by service, function, model, query, and Cortex Search usage.
  • Developer and project attribution requires query tags and joins between AI-function usage history and QUERY_HISTORY, though shared service accounts can still obscure the true end user.
  • Anomaly detection should compare current usage against recent baselines to distinguish normal growth from unexpected or out-of-control AI spending, especially in development environments.

Meta description: Snowflake AI cost monitoring helps data teams track Cortex AI Functions, Cortex Search, and hidden credit spend as development experiments grow out of control.

Optimizing Snowflake AI Costs by Identifying Spending Sources, Detecting Waste, and Controlling Expenditure

Tags: Snowflake AI, Cortex AI Functions, Cortex Search, FinOps, cost monitoring

Featured image: Abstract, friendly illustration style of a credit dashboard with charts, query tags, and alert icons; no real people, no logos, no text.

For data engineering teams running Snowflake AI, the core issue is visibility. A single application request can contain LLM inference, document fetch, multiple SQL queries, and multiple model evaluations, while Snowflake AI cost monitoring must track credits that do not sit neatly in warehouse usage. Snowflake has traditionally been optimized around warehouse sizes, query performance, auto suspend, storage, and pipeline costs. AI workloads add new complexity: they are credit intensive, can become stealth costs, and are hard to track with traditional dashboards. During experimentation, a developer can make many AI requests, often without knowing dozens of AI requests have been created.

Why Snowflake AI spend is hard to see

Depending on feature, deployment type, and pricing, AI workloads can create several cost elements: AI service usage, warehouse compute, and additional service costs. Not all AI costs are warehouse related. Before calculating any cost, teams should check the current pricing documentation for their region, cloud, and contract, because the credit rate and metering depend on the feature. Cortex AI Inference & Search, experimental development, retries, and out-of-control workloads are the areas where spend can move fastest.

The source describes a reference architecture for AI consumption monitoring, attribution, anomaly detection, and remediation. A good FinOps architecture should answer four questions: where costs are being used, who is using them at project or developer level, what looks abnormal, and what remediation is appropriate. Detection and remediation should remain separated. When an anomaly appears, investigate it first. Automatically canceling production AI workloads requires a higher level of protection.

SQL and views for cost visibility

The source recommends starting with Snowflake Account Usage views. These queries are a good starting point for building an operational cost monitoring tool, not billing reconciliation.

Optimizing Snowflake AI Costs by Identifying Spending Sources, Detecting Waste, and Controlling Expenditure
  1. Total AI-related credits by service. Query `SNOWFLAKE.ACCOUNT_USAGE.METERING_DAILY_HISTORY` for `USAGE_DATE`, `SERVICE_TYPE`, and `SUM(CREDITS_USED)` over the last 30 days, using a service-name filter such as `ILIKE '%AI%'`, `ILIKE '%CORTEX%'`, or `ILIKE '%COCO%'`. This provides a high-level breakdown of metered AI-related services. Treat the service-name filter as a discovery query and confirm the service types in the account against Snowflake’s current metering documentation.
  1. Most expensive AI functions and models. Query `SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AI_FUNCTIONS_USAGE_HISTORY` for the last 7 days, grouping by `FUNCTION_NAME` and `MODEL_NAME`, counting distinct `QUERY_ID`, and summing `CREDITS` rounded to 4 decimal places. This 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.
  1. Most expensive individual AI queries. Use the same view for the last 7 days, grouping by `QUERY_ID`, `MODEL_NAME`, and `FUNCTION_NAME`, with `MIN(START_TIME)` as `FIRST_SEEN`, `MAX(END_TIME)` as `LAST_SEEN`, and `SUM(CREDITS)` as `AI_CREDITS`. Order by credits and limit the result to 25 rows. This is useful for finding bulk AI processing queries that invoke a model across many records.
  1. Most expensive Cortex Search services. Query `SNOWFLAKE.ACCOUNT_USAGE.CORTEX_SEARCH_DAILY_USAGE_HISTORY` for the last 30 days, grouping by `DATABASE_NAME`, `SCHEMA_NAME`, `SERVICE_NAME`, and `CONSUMPTION_TYPE`, and summing `CREDITS` rounded to 4 decimal places. The consumption categories distinguish serving, embedding, and batch usage. When combining this view with AI Functions usage, avoid double-counting embedding credits.
  1. Developer and project attribution. First assign meaningful query tags in development sessions with `ALTER SESSION SET QUERY_TAG = 'project=ai_cost_monitor;env=dev;team=data_engineering'`. Then join AI-function credits from the last 7 days to `SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY` on `QUERY_ID`, grouping by `USER_NAME` and `QUERY_TAG`. This 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.

Detecting unexpected spend without punishing useful growth

An effective monitoring system should distinguish a normal increase in usage from an abnormal one. For example, if a development environment usually consumes 10 AI credits daily but suddenly consumes 80, that illustrative Friday eightfold increase deserves investigation, but it is not automatically evidence of waste.

A simple first step is to compare current usage with the previous seven days. The example monitors the `AI_FUNCTIONS` service type by taking `METERING_DAILY_HISTORY` credits from the last 8 days, averaging days -7 through -1, and reporting a baseline multiplier for today. 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 feature-specific views for more timely detection.

Development is one of the easiest places to accumulate AI spending without noticing it. Consider a developer building a product-review classification pipeline. The initial experiment processes 100 customer reviews. Everything works, so the developer runs the same logic against 100,000 records. If the SQL query invokes an AI function once per row, a single statement can produce potentially 100,000 model evaluations.

A query such as `SELECT REVIEW_ID, AI_SENTIMENT(REVIEW_TEXT) AS SENTIMENT FROM CUSTOMER_REVIEWS` is straightforward SQL, but processing a large table can generate substantial AI usage. A safer development version adds `WHERE REVIEW_TEXT IS NOT NULL ORDER BY REVIEW_ID LIMIT 100`. That limits the input to 100 records and supports controlled experimentation, but teams 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 inference begins: create a temporary table named `REVIEW_SAMPLE` with the bounded `REVIEW_ID` and `REVIEW_TEXT` rows, then run `AI_SENTIMENT` against that table.

Controls, budgets, and value measurement

The source recommends a practical five-layer cost-control framework. Snowflake 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.

Optimizing Snowflake AI Costs by Identifying Spending Sources, Detecting Waste, and Controlling Expenditure

For an organization introducing Snowflake AI, useful starting policies are: every AI workload must have an identifiable owner and environment; development AI workloads must have defined credit limits; production deployments require a cost estimate per 1,000 requests or records; large-scale AI processing requires an approved input-volume threshold; repeated inference should use persisted results where appropriate; agentic applications must have retry and tool-execution limits; and cost anomalies should be investigated before automatic remediation is enabled. These controls should be applied based on workload criticality. A research experiment and a customer-facing production application should not have identical enforcement rules.

The most useful metric is not simply total credits. It is cost per successful business outcome. For example, if a document classification application consumes 120 credits to process 40,000 documents and 36,000 are successfully classified, those numbers are illustrative calculations, not observed Snowflake performance. An optimization that reduces total credits but significantly increases classification errors may worsen business economics. Track inference cost alongside accuracy, latency, retries, and successful outcomes.

A four-week rollout can move an account from blind spend to governed AI workloads:

  1. Week 1 - Visibility: Identify all active AI services, establish daily usage reporting, and classify development versus production consumption.
  2. Week 2 - Attribution: Add query tags, map service accounts to applications, and create project-level cost reporting.
  3. Week 3 - Detection: Establish rolling baselines, unusual-spend alerts, and high-credit query investigations.
  4. Week 4 - Controls: Configure applicable budgets and quotas, implement development guardrails, and test escalation procedures.

The source article, Snowflake AI Cost Optimization: Where the Spend Comes From, How to Detect It, and How to Control It, was originally published in Towards AI on Medium, where readers continue the conversation by highlighting and responding to the story. Related technical references include Snowflake AI cost management and governance, Cortex AI Functions usage history, Managing Cortex AI Functions costs, and an AI usage and cost attribution reference implementation.

Common mistakes

The main mistakes to avoid are treating the service-name discovery query as billing reconciliation, failing to confirm AI service types against current Snowflake metering documentation, and combining AI Functions and Cortex Search views without watching for double-counted embedding credits. Teams also should not assume `LIMIT` always reduces AI evaluations, should not use a single `AI_FUNCTIONS` category for the whole AI budget, and should not let daily metering delay become a reason to miss timely detection.

Another error is mixing detection and remediation. An eightfold jump from 10 to 80 credits is a trigger to investigate, not proof of waste. Automatic cancellation of production AI workloads needs stronger protection. The final question for data engineering teams is not just how much Snowflake cost. It is which AI workloads created that cost, why they consumed those resources, and what value the organization received. AI cost optimization should extend beyond warehouse sizing and query tuning because token processing, document extraction, search serving, multi-step agent execution, and repeated development experimentation create new consumption patterns. The objective is not to minimize every AI credit. It is to ensure every AI workload delivers measurable value at a predictable cost.

Comments (0)

  1. No comments yet. Be the first to share what worked for you.

Leave a comment

Comments are reviewed before they appear. Your email address is not published.