> For the complete documentation index, see [llms.txt](https://docs.onelens.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onelens.cloud/observe-visibility-and-insights/ai-unit-costs.md).

# AI Unit Costs

> Detect abnormal AI spend before it becomes a billing surprise.

AI Cost Anomalies continuously monitors your AI spending and automatically detects unusual cost patterns across providers, models, projects, API keys, and teams. Every anomaly includes root cause analysis to help you understand what changed and where to investigate.

***

### Why use AI Cost Anomalies?

AI costs can increase unexpectedly due to:

* Traffic spikes
* Incorrect model routing
* Prompt changes
* Agent loops
* Misconfigured applications
* New deployments
* Shadow AI usage

Manually monitoring dashboards isn't scalable. AI Cost Anomalies proactively identifies unusual spending so your team can respond before costs escalate.

***

### How It Works

OneLens uses statistical models to learn your historical spending patterns and establish dynamic baselines for every monitored dimension.

When spend deviates significantly from expected behavior, an anomaly is generated automatically.

No manual threshold configuration is required.

***

### Detection Dimensions

Detect anomalies across multiple business and technical dimensions.

Supported dimensions include:

* Provider
* Region
* Service
* Model
* Caller (User or API Key)

This helps quickly isolate whether a spike is caused by infrastructure, an application, or a specific workload.

***

### Root Cause Analysis

Every anomaly includes an automatically generated root cause summary.

Understand:

* What changed
* Which dimension contributed most
* Estimated cost impact
* Timeline of the anomaly
* Recommended investigation path

Instead of simply notifying you that costs increased, OneLens explains where the increase originated.

***

### Token Contribution Analysis

Understand what actually drove the additional cost.

Depending on the provider, OneLens breaks down cost contribution across:

* Input Tokens
* Output Tokens
* Cached Tokens
* Reasoning Tokens

This helps determine whether increased costs were caused by larger prompts, longer responses, reduced cache efficiency, or reasoning-heavy workloads.

***

### Anomaly Lifecycle

Track the complete lifecycle of every anomaly.

Available states include:

* Open
* Acknowledged
* Investigating
* Resolved

This allows teams to collaborate, avoid duplicate investigations, and maintain an audit trail of incident resolution.

***

### Alerting & Notifications

Receive anomaly alerts through your existing communication channels.

Supported notification channels include:

* Email
* Slack
* Microsoft Teams
* ServiceNow

Notifications include a summary of the anomaly along with a direct link to investigate further.

***

### Investigate Faster

Each anomaly provides enough context to begin troubleshooting immediately.

Quickly answer questions like:

* Which model caused the spike?
* Which API key generated the spend?
* Which team owns the workload?
* Is this affecting one provider or multiple?
* Is the increase temporary or ongoing?

From the anomaly page, you can drill directly into the AI Cost & Usage Analyzer for deeper analysis.

***

### Example Scenarios

#### Unexpected Model Upgrade

An application starts routing requests from GPT-4o Mini to GPT-4. OneLens detects the sudden increase in cost and highlights the affected model.

***

#### Agent Loop

An autonomous workflow repeatedly calls an LLM, generating thousands of unnecessary requests. The abnormal spending pattern is detected within the reporting cycle.

***

#### Cache Miss Spike

A prompt update reduces cache effectiveness, causing a significant increase in input token costs. Token contribution analysis highlights the drop in cache efficiency.

***

#### Shadow AI Usage

A newly created API key begins generating significant spend outside approved projects. The anomaly identifies the caller responsible for the increase.

***

### Best Practices

* Review anomalies daily to identify issues before invoices arrive.
* Route alerts to the teams responsible for the affected workloads.
* Investigate recurring anomalies to identify long-term optimization opportunities.
* Use anomaly insights alongside AI Budgets to proactively manage spending.
* Track resolution status to ensure every anomaly is investigated and closed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.onelens.cloud/observe-visibility-and-insights/ai-unit-costs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
