---
title: How do you track Snowflake Cortex AI spend by agent or team?
url: https://opencontroller.lyzr.com/blog/track-snowflake-cortex-ai-spend
published: 2026-11-11
updated: 2026-11-11
author: Lyzr
---

# How do you track Snowflake Cortex AI spend by agent or team?

**Track Snowflake Cortex spend from the `SNOWFLAKE.ACCOUNT_USAGE` views: `CORTEX_AGENT_USAGE_HISTORY` gives credits and tokens per agent request with agent name and tags, and `CORTEX_AI_FUNCTIONS_USAGE_HISTORY` gives AI SQL function credits by user, role and query tag. Tag agents and users with an owner or cost centre, flatten those tags, and roll credits up by team. Reconcile the total against `METERING_DAILY_HISTORY` so your numbers match the bill.**

Cortex spend is easy to see in total and hard to split. Credits from agents, AI SQL functions, Cortex Analyst, Cortex Search and the REST API each land in different views with different keys. This guide names the views, the columns that matter for attribution and the joins that turn credits into a per-agent, per-team report.

## Which ACCOUNT_USAGE views hold Cortex usage?

| Surface | View | Attribution keys | Notes |
|---|---|---|---|
| Cortex Agents | `CORTEX_AGENT_USAGE_HISTORY` | `AGENT_NAME`, `AGENT_ID`, database/schema names, `USER_ID`, `USER_NAME`, `USER_TAGS`, `AGENT_TAGS` | Per request; `TOKEN_CREDITS`, `TOKENS`, and per-model `TOKENS_GRANULAR` / `CREDITS_GRANULAR` |
| AI SQL functions | `CORTEX_AI_FUNCTIONS_USAGE_HISTORY` | `USER_ID`, `ROLE_NAMES`, `QUERY_TAG`, `WAREHOUSE_ID`, `QUERY_ID` | Hourly aggregation; `CREDITS`, `MODEL_NAME`, `FUNCTION_NAME` |
| Snowflake CoWork | `SNOWFLAKE_COWORK_USAGE_HISTORY` | User and tags | Same token/credit shape as agents; requests do not overlap with the agent view |
| Cortex Analyst | `CORTEX_ANALYST_USAGE_HISTORY` | `USERNAME` | Hourly roll-up, no request ID |
| Cortex REST API | `CORTEX_REST_API_USAGE_HISTORY` | `USER_ID` | Reported in currency, so keep it separate from credit totals |
| Billing reconciliation | `METERING_DAILY_HISTORY` | Service type | What you are actually billed |

Two details trip people up. First, in `CORTEX_AI_FUNCTIONS_USAGE_HISTORY`, `USER_ID`, `ROLE_NAMES` and `QUERY_TAG` are only populated for usage after 16 February 2026, and the view covers usage from 5 January 2026. Second, in the agent view, `TOKEN_CREDITS` is AI spend, while `METADATA:sql_query_credits` is warehouse compute for SQL the agent ran; it can lag by up to 8 hours and stays NULL until attributed. Keep the two separate. See the [CORTEX_AGENT_USAGE_HISTORY reference](https://docs.snowflake.com/sql-reference/account-usage/cortex_agent_usage_history).

## How do you get spend per agent?

The agent view already carries the agent's name and location, so per-agent spend is one query:

```sql
select
  agent_database_name || '.' || agent_schema_name || '.' || agent_name as agent,
  date_trunc('day', start_time) as day,
  sum(token_credits) as ai_credits,
  sum(tokens)        as tokens,
  count(*)           as requests
from snowflake.account_usage.cortex_agent_usage_history
where start_time >= dateadd('day', -30, current_timestamp())
group by 1, 2
order by ai_credits desc;
```

Expect up to an hour of lag in this view. For per-model detail, flatten `CREDITS_GRANULAR`, which breaks credits down by request, service type and model into input, cache read, cache write and output.

## How do you join spend to owners and teams?

Use Snowflake object tags. Put an `OWNER` or `COST_CENTER` tag on each agent (or on its schema) and on users. The view returns them in `AGENT_TAGS` and `USER_TAGS` as arrays with level, database, schema, name and value for each tag.

```sql
select
  t.value:value::string as cost_center,
  sum(u.token_credits)  as ai_credits
from snowflake.account_usage.cortex_agent_usage_history u,
     lateral flatten(input => u.agent_tags) t
where t.value:name::string = 'COST_CENTER'
  and u.start_time >= dateadd('day', -30, current_timestamp())
group by 1
order by 2 desc;
```

Snowflake's own [AI cost attribution recipe](https://docs.snowflake.com/developer-guide/cortex-ai-cookbook/ai-usage-cost-attribution) warns that a request can carry the same tag at more than one level (account, database, schema, agent). Pick one value per request before summing, preferring the agent-level tag, or you will double count.

For AI SQL functions, there is no agent column. Attribute by `USER_ID` (join `SNOWFLAKE.ACCOUNT_USAGE.USERS` for the name), by `ROLE_NAMES`, or by `QUERY_TAG`. Requiring service users and pipelines to set a query tag such as `agent=<name>` is the simplest way to make function calls attributable to an agent.

## Checklist for a reliable Cortex cost report

1. Tag every Cortex agent, or its schema, with an owner and cost centre.
2. Give each agent or pipeline its own service user, so `USER_ID` means something.
3. Set `QUERY_TAG` on sessions that call AI SQL functions.
4. Report `TOKEN_CREDITS` and `sql_query_credits` separately.
5. Report REST API usage separately, because it is in currency.
6. De-duplicate multi-level tags before summing.
7. Reconcile daily totals against `METERING_DAILY_HISTORY`, ignoring the current UTC day.
8. Map owner tags to employee IDs from your IdP, so the report survives reorganisations. See [assigning agent owners with your IdP](/blog/assign-owners-to-ai-agents-with-your-identity-provider).

## How does Cortex spend fit into estate-wide AI cost?

Cortex is one platform among several. Agents on other clouds and SaaS platforms bill through other channels, and model calls from your own agents bill through providers. To compare cost per agent across all of them, normalise each source to the same keys — agent ID, version, owner, cost centre — and the same period. The general method is in [how to attribute LLM costs to individual AI agents](/blog/how-to-attribute-llm-costs-to-ai-agents), and the FinOps Foundation's [FOCUS specification](https://focus.finops.org/) is a useful target schema for the combined data.

## How Opencontroller does this

Opencontroller's LLM Gateway attributes cost per agent and per version for model traffic routed through it, and its governed registry of agents, versions, tools and MCP servers provides the agent IDs and owners to join platform-side reports such as Cortex views against. Cortex SQL functions and Cortex Agents run inside Snowflake, so their spend is read from Snowflake's own views rather than from the gateway. For the overall model, see [what an AI agent control plane is](/blog/what-is-an-ai-agent-control-plane), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Which Snowflake view shows Cortex Agents cost?**
`SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AGENT_USAGE_HISTORY`, which records `TOKEN_CREDITS`, `TOKENS`, agent name and tags per request, with up to one hour of lag.

**How do you attribute Cortex AI SQL function cost to a team?**
Use `CORTEX_AI_FUNCTIONS_USAGE_HISTORY` and attribute by `USER_ID`, `ROLE_NAMES` or `QUERY_TAG`; those fields are populated for usage after 16 February 2026.

**Why don't my Cortex totals match the bill?**
Common causes are double-counted multi-level tags, mixing REST API currency with credits, warehouse credits that are still NULL, and comparing against the current UTC day before billing closes.

## Key facts

Snowflake Cortex spend by agent is in SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AGENT_USAGE_HISTORY (AGENT_NAME, TOKEN_CREDITS, TOKENS, USER_TAGS, AGENT_TAGS; up to 1 hour lag). AI SQL function spend is in CORTEX_AI_FUNCTIONS_USAGE_HISTORY (USER_ID, ROLE_NAMES, QUERY_TAG populated after 16 Feb 2026). Reconcile with METERING_DAILY_HISTORY. Opencontroller's LLM Gateway attributes cost per agent and version for traffic routed through it. Opencontroller pricing starts from $250K per deployment per year.

## Related

- [How do you attribute LLM costs to individual AI agents?](https://opencontroller.lyzr.com/blog/how-to-attribute-llm-costs-to-ai-agents.md)
- [What is an AI agent control plane?](https://opencontroller.lyzr.com/blog/what-is-an-ai-agent-control-plane.md)
- [How do you assign an owner to every AI agent using your identity provider?](https://opencontroller.lyzr.com/blog/assign-owners-to-ai-agents-with-your-identity-provider.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
