This post is for Snowflake admins and data engineering leads whose teams use Cortex Code. It explains how Cortex Code is billed on each surface, the per-user credit limit parameters Snowflake provides, how to set account defaults and per-user overrides, how to audit overrides, and how to watch actual usage.

When I first started using Cortex Code, cost was the last thing on my mind. It’s right there in the Snowsight UI, it feels like a built-in feature, and nothing in the interface tells you that tokens are being consumed behind the scenes.

Then I read the official docs properly, not just the feature overview but the cost controls section, and found something I hadn’t seen covered anywhere: Snowflake has a native, dedicated cost control system for Cortex Code that most people don’t know exists. Two parameters, per user, per surface, which an ACCOUNTADMIN can configure in seconds. If you run Cortex Code in your account, especially with a team, you need to set these up.

Tracking Cortex Code consumption before applying per-user credit limits.

How Cortex Code Billing Works

If you’re new to Cortex Code, read my earlier post What Is Snowflake Cortex Code and How I Taught Myself to Use It first. It covers what the tool does and how to access it in Snowsight. This post picks up at the cost control layer.

Cortex Code runs on two surfaces, each with its own billing model:

  • Cortex Code in Snowsight, the browser-based UI. Token-based billing tied to your existing Snowflake account. Snowflake will notify users before charges formally begin, but AI service costs are already accumulating underneath.
  • Cortex Code CLI, the command-line agent. Already billing on token consumption: pay-as-you-go for existing Snowflake accounts, or a subscription for individual sign-ups.

The key point: unlike virtual warehouses, where you can set a Resource Monitor with a credit quota, Cortex Code has its own cost control parameters that Resource Monitors don’t cover. You have to set them explicitly.

For the full official breakdown, see Snowflake’s Cortex Code billing documentation.

The two parameters

Snowflake provides exactly two parameters for Cortex Code cost control. Both are set by ACCOUNTADMIN only, work on a rolling 24-hour window per user, and are independent of each other.

ParameterSurface ControlledDefault
CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USERCortex Code CLI-1 (unlimited)
CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USERCortex Code in Snowsight-1 (unlimited)

What the values mean:

ValueBehaviour
-1 (default)No limit, unlimited access
0Access blocked entirely for that user
Any positive numberAccess blocked once estimated credits exceed that number in the past 24 hours

Full parameter reference: Cost controls for Cortex Code (Snowflake docs).

Cortex code two surfaces

Setting the limits

Account-level limits

This is the first thing I’d do: set a sensible default for every user at the account level. Anyone who goes over it is blocked until the rolling window resets. No silent runaway spend.

SQL 5 lines

SQL account parameter — sets an account-level limit for every user.

-- Cap all users at 20 credits per day for CLIALTER ACCOUNT SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 20; -- Cap all users at 20 credits per day in SnowsightALTER ACCOUNT SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 20;

To remove an account-level limit and restore unlimited access:

SQL 2 lines

SQL account parameter — clears an account-level setting and restores the default.

ALTER ACCOUNT UNSET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER;ALTER ACCOUNT UNSET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER;

For the full syntax, see ALTER ACCOUNT (Snowflake docs).

Per-user overrides

A user-level setting overrides the account-level setting for that user. Everyone else keeps the account default.

SQL 8 lines

SQL user parameter — overrides the account default for one user.

-- Power user gets a higher CLI limit than the account defaultALTER USER power_user SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 50; -- Junior analyst gets a tighter Snowsight limitALTER USER junior_analyst SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 5; -- Block a service account or contractor from Snowsight entirelyALTER USER contractor_account SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 0;

Setting the value to 0 blocks that user completely on that surface, which is useful for service accounts that should never use Cortex Code interactively.

To remove a user-level override and fall back to the account default:

SQL 1 line

SQL user parameter — removes one user override so the account default applies.

ALTER USER junior_analyst UNSET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER;

For the full syntax, see ALTER USER (Snowflake docs).

A Practical Setup for a Team

Here’s how I’d configure this for a typical data engineering team with senior engineers, analysts and a few service accounts. The script sets a 20-credit default on both surfaces, raises the CLI limit to 50 for named senior engineers, and blocks the Airflow and dbt service users on both surfaces. Replace the user names with your own.

SQL 14 lines

SQL account parameter — sets an account-level limit for every user.

-- Step 1: Set sensible defaults for the whole accountALTER ACCOUNT SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 20;ALTER ACCOUNT SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 20; -- Step 2: Give senior engineers more headroom on CLIALTER USER senior_eng_1 SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 50;ALTER USER senior_eng_2 SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 50; -- Step 3: Block service accounts from both surfacesALTER USER airflow_svc SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 0;ALTER USER airflow_svc SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 0; ALTER USER dbt_svc SET CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER = 0;ALTER USER dbt_svc SET CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER = 0;

If you run dbt projects natively inside Snowflake, you’ll already have dedicated service accounts; I covered that setup in How I Wired Snowflake’s Native dbt Projects to Airflow. Those same service accounts should be blocked from Cortex Code with a 0 limit.

Service accounts should never use Cortex Code. Setting them to 0 explicitly means that even if someone accidentally grants CORTEX_AGENT_USER to a service role, the credit limit acts as a safety net.

Cortex code cost

Auditing who has custom limits

The official docs include a script that lists every user with a per-user override, which is what you need for a quarterly governance review. It runs SHOW USERS, loops over each user, runs SHOW PARAMETERS for the CLI limit in that user’s scope, and keeps only rows where the level is USER, meaning a real override rather than the inherited account value.

shell 28 lines

CLI command, run it in a terminal with your own credentials and environment.

-- Audit all users with a custom CLI credit limit overrideEXECUTE IMMEDIATE $$DECLARE  current_user STRING;  rs_users RESULTSET;  res      RESULTSET;BEGIN  CREATE OR REPLACE TEMPORARY TABLE _param_overrides (user_name STRING, param_value STRING);   SHOW USERS;  rs_users := (SELECT "name" FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())));   FOR record IN rs_users DO    current_user := record."name";     EXECUTE IMMEDIATE      'SHOW PARAMETERS LIKE ''CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER'' IN USER "' || :current_user || '"';     INSERT INTO _param_overrides (user_name, param_value)      SELECT :current_user, "value"      FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))      WHERE "level" = 'USER';  END FOR;   res := (SELECT * FROM _param_overrides);  RETURN TABLE(res);END;$$;

To audit Snowsight overrides instead, swap CORTEX_CODE_CLI_DAILY_EST_CREDIT_LIMIT_PER_USER for CORTEX_CODE_SNOWSIGHT_DAILY_EST_CREDIT_LIMIT_PER_USER in the SHOW PARAMETERS LIKE clause. Run both regularly. The script is taken directly from the official Snowflake cost controls page; I haven’t modified it.


What happens when a user hits the limit

When a user’s rolling 24-hour usage goes over the threshold, that surface returns an error saying the daily credit limit has been reached. They can’t use it again until enough time passes for their usage to drop below the limit. The other surface is unaffected: hitting the CLI limit doesn’t lock them out of Snowsight.

Admins can raise or remove the limit at any time to restore access immediately, without waiting for the window to roll.

Cortex code limit

Tell your team before you set limits, because nobody likes a sudden block mid-workflow. Set the limits, tell people what they are, and tell them who to contact for a temporary increase.


Monitoring actual usage

The credit limits control access and stop runaway spend. You also want visibility into consumption before anyone hits a limit, so pair the limits with a monitoring query:

SQL 10 lines

Snowflake metadata query — inspects execution history, storage, or credit telemetry.

SELECT    DATE_TRUNC('day', start_time)   AS usage_day,    function_name,    model_name,    SUM(tokens_used)                AS total_tokens,    SUM(credits_used)               AS total_creditsFROM snowflake.account_usage.cortex_functions_usage_historyWHERE start_time >= CURRENT_DATE - 30GROUP BY 1, 2, 3ORDER BY usage_day DESC, total_credits DESC;

This shows which models and functions are driving cost across the account over the last 30 days, by day. The credit limits stop the bleeding; this query tells you where it’s coming from.

For more on how Snowflake bills AI functions in general (token rates, model pricing differences, and what output tokens mean for your bill), see my post Snowflake Cortex Pricing: What Every Data Engineer Should Know and the official Snowflake Service Consumption Table, which is the source of truth for current credit rates.


The setup in five steps

A sensible Cortex Code cost control setup takes about 10 minutes:

  1. Set account-level daily limits for both CLI and Snowsight. 20 credits is a reasonable starting default.
  2. Override upward for power users who need more headroom.
  3. Override to 0 for all service accounts.
  4. Run the audit script quarterly to catch drift as people join or leave the team.
  5. Monitor cortex_functions_usage_history for spend patterns alongside your limits.

The alternative is the default: -1 for every user, unlimited spend, and a bill that arrives before anyone realized the meter was running.

Question this article answers

The short answer first. Open it to read the working note.

What happens when a user hits the limit?

When a user's rolling 24-hour usage goes over the threshold, that surface returns an error saying the daily credit limit has been reached. They can't use it again until enough time passes for their usage to drop below the limit. The other surface is unaffected: hitting the CLI limit doesn't lock them out of Snowsight. Admins can raise or remove the limit at any time to restore access immediately, without waiting for the window to roll.