# Cortex AI Cost Skill

Analyze credit and token usage for Snowflake's Cortex AI products.

---

## Step 1: Identify the Product

Match the user's question to a product and its reference file:

| Product | Keywords | Reference File |
|---------|----------|----------------|
| **Cortex Agents** | "cortex agents", "agent credits", "agent usage", "agent cost" | `references/cortex-ai/cortex-agents.md` |
| **Cortex AI Functions** | "COMPLETE", "TRANSLATE", "AI functions", "LLM function", "cortex functions", "AISQL" | `references/cortex-ai/cortex-ai-functions.md` |
| **Cortex Analyst** | "cortex analyst", "NL to SQL", "natural language query", "analyst credits" | `references/cortex-ai/cortex-analyst.md` |
| **Cortex Code (CLI)** | "cortex code CLI", "code CLI", "code generation CLI" | `references/cortex-ai/cortex-code-cli.md` |
| **Cortex Code (Snowsight)** | "cortex code snowsight", "code in snowsight", "code generation UI" | `references/cortex-ai/cortex-code-snowsight.md` |
| **Cortex Model Training** | "fine-tuning", "fine tuning", "model training", "custom model", "training credits" | `references/cortex-ai/cortex-model-training.md` |
| **Cortex Provisioned Throughput** | "provisioned throughput", "PTU", "dedicated capacity", "reserved throughput" | `references/cortex-ai/cortex-provisioned-throughput.md` |
| **Cortex Search** | "cortex search", "vector search", "search service", "embedding costs", "search credits" | `references/cortex-ai/cortex-search.md` |
| **Snowflake Intelligence** | "snowflake intelligence", "SI", "intelligence agent", "SI credits" | `references/cortex-ai/snowflake-intelligence.md` |

If the user mentions **Cortex Code** without specifying CLI or Snowsight, ask:
```
Are you asking about Cortex Code usage from the CLI or from Snowsight?
```

If the product is unclear from context, ask:
```
Which Cortex AI product are you asking about? For example:
- Cortex Agents, Cortex Analyst, Cortex AI Functions (COMPLETE/TRANSLATE)
- Cortex Search, Cortex Code, Snowflake Intelligence
- Cortex Provisioned Throughput, Cortex Model Training
```

---

## Step 2: Read the Reference File and Pick a Query

Read the identified reference file. Match the user's specific question to the most relevant query section using the **Triggered by** phrases in each section header.

If the user's question is general (e.g. "how much am I spending on Cortex Agents?"), default to the **Cost per User** query for the identified product.

Ask the user for `<START_TIME>` and `<END_TIME>` if not already provided. Remind them the window must be at most one month.

---

## Step 3: Run the Query

Execute the selected query with the user's time window substituted for `<START_TIME>` and `<END_TIME>`.

Present results clearly. If the result set is large, summarize the top entries and note the total row count.

---

## Step 4: Suggest Follow-Up Queries

After showing results, suggest 2–3 other queries available in the **same reference file** or a **related file**. Frame them as natural follow-up questions. For example:

> **Want to dig deeper?**
> - "Which models drove the most cost?" → runs *Cortex AI Function Cost per Model*
> - "How has this trended day over day?" → runs *Cortex AI Function Daily Cost Trend*
> - "How does this break down by team?" → runs *Cortex AI Function Cost per Team*
>
> Or explore a related product:
> - "How much am I spending on Cortex Agents?" → `cortex-agents.md`
> - "What's my Snowflake Intelligence spend?" → `snowflake-intelligence.md`
