---
title: AI Costs
description: >-
  Gain unified visibility into AI spend across providers, normalize cost data,
  and attribute usage to users and teams.
breadcrumbs: Docs > Cloud Cost Management > AI Costs
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# AI Costs

## Overview{% #overview %}

AI Costs in Cloud Cost Management gives FinOps and engineering teams a unified destination for analyzing AI spend across providers, including Amazon Bedrock, Anthropic, Google Gemini, OpenAI, Vertex AI, GitHub Copilot, and Cursor. View total AI spend alongside your existing cloud infrastructure costs, analyze it with normalized tags, track cost anomalies, identify optimization opportunities, and attribute usage to the specific users and API keys driving it.

## Prerequisites{% #prerequisites %}

To use AI Costs, you must have at least one of the following supported providers set up for [Cloud Cost Management](https://docs.datadoghq.com/cloud_cost_management.md):

| AI provider            | Setup method                                                                                                                         |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Amazon Bedrock         | [AWS integration](https://docs.datadoghq.com/cloud_cost_management/setup/aws.md)                                                     |
| Amazon SageMaker       | [AWS integration](https://docs.datadoghq.com/cloud_cost_management/setup/aws.md)                                                     |
| Anthropic              | [SaaS integration](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=anthropic#configure-your-saas-accounts)  |
| Azure Foundry          | [Azure integration](https://docs.datadoghq.com/cloud_cost_management/setup/azure.md?tab=terraform)                                   |
| Google Gemini          | [Google Cloud integration](https://docs.datadoghq.com/cloud_cost_management/setup/google_cloud.md)                                   |
| OpenAI (Platform only) | [SaaS integration](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=openai#configure-your-saas-accounts)     |
| Vertex AI              | [Google Cloud integration](https://docs.datadoghq.com/cloud_cost_management/setup/google_cloud.md)                                   |
| GitHub Copilot         | [GitHub Copilot](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=github#configure-your-saas-accounts)       |
| Cursor                 | [Cursor](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=cursor#configure-your-saas-accounts)               |
| Databricks Mosaic AI   | [SaaS integration](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=databricks#configure-your-saas-accounts) |

## AI cost summary{% #ai-cost-summary %}

After connecting your AI providers, navigate to [**Cloud Cost** > **Summarize** > **AI**](https://app.datadoghq.com/cost/summarize/ai-costs) to view the AI cost summary page.

{% image
   source="https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-costs-overview.20ea73b5f26ec1eff19ddc6d8b5d6fd7.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-costs-overview.20ea73b5f26ec1eff19ddc6d8b5d6fd7.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The AI cost summary dashboard, showing daily spend trends over a one-month period, a list of top spend drivers, and an anomaly graph." /%}

The AI cost summary page provides:

- **Total AI Cost**: Aggregated AI cost and cost change over the selected time frame.
- **Daily AI Cost**: Daily cost trends across the selected providers over the selected time frame. Use the **Filter to** dropdown to define which providers appear in the graph.
- **Top Cost Drivers**: The models, projects, services, and users generating the most spend.
- **Active AI Cost Anomalies**: Cost [anomalies](https://docs.datadoghq.com/cloud_cost_management/cost_changes/anomalies.md) surfaced proactively across all connected providers. Select an anomaly to open a side panel with more details and options for further action.
- **AI Cost Recommendations**: Cost [recommendations](https://docs.datadoghq.com/cloud_cost_management/recommendations.md) and optimization opportunities surfaced across all connected providers. Select a recommendation to open a side panel with more details and options for further action.
- **AI Cost Dashboards**: Out-of-the-box dashboard templates for each supported provider, combining cost data with usage signals such as token consumption, model distribution, and user analytics.

## Normalized AI tags{% #normalized-ai-tags %}

AI cost data from all supported providers is normalized to a consistent set of tags. Use these tags to filter, group, compare, and plan AI spend across dashboards, [monitors](https://docs.datadoghq.com/cloud_cost_management/cost_changes/monitors.md), [budgets](https://docs.datadoghq.com/cloud_cost_management/planning/budgets.md), [forecasts](https://docs.datadoghq.com/cloud_cost_management/planning/forecasting.md), and other Datadog tools. Use [Cloud Cost Explorer](https://app.datadoghq.com/cost/explorer) to query and compare spend across providers without writing per-provider logic.

The following tags are available for all supported AI providers:

| Tag name     | Tag description                                                                                                                                                                                             |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `providername`    | The AI provider.                                                                                                                                                                                            |
| `model`           | The AI model identifier (for example, `claude-opus-4-6`, `gpt-4.1`).                                                                                                                                        |
| `model_name`      | The human-readable model name (for example, `Claude Opus 4.6`).                                                                                                                                             |
| `token_direction` | Whether tokens are being consumed (input) or generated (output) within a service or application.                                                                                                            |
| `token_category`  | The specific category of tokens consumed, such as input tokens, output tokens, or tokens related to caching and search operations (for example, `cached input`, `cache write`, `standard input`, `output`). |
| `project`         | The project, workspace, or environment the AI costs belong to.                                                                                                                                              |

## Attribute AI spend to sources{% #attribute-ai-spend-to-sources %}

[Out-of-the-box (OOTB) allocation rules](https://docs.datadoghq.com/cloud_cost_management/allocation/custom_allocation_rules.md?tab=even) use Datadog observability data to attribute AI costs to the users, API keys, and other sources that generated them. OOTB allocation rules require no configuration and are available for Anthropic and OpenAI. User-level allocation is also supported for Cursor.

The following tags are available through OOTB allocation rules:

{% tab title="Anthropic" %}

- `api_key_id`
- `api_key_name`
- `context_window`
- `model`
- `model_id`
- `org_id`
- `org_name`
- `service_tier`
- `user_email`
- `user_id`
- `user_name`
- `workspace_id`
- `workspace_name`

{% /tab %}

{% tab title="OpenAI" %}

- `account_id`
- `account_name`
- `api_key_id`
- `batch`
- `endpoint`
- `model`
- `org_id`
- `project_id`
- `project_name`
- `user_email`
- `user_id`

{% /tab %}

Configure [Tag Pipelines](https://docs.datadoghq.com/cloud_cost_management/allocation/tag_pipelines.md) to map OOTB tags (such as `user_email`) to teams, services, or business units for aggregate reporting:

{% image
   source="https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-tag-pipeline-ai-costs.dadd5dc5df518f514f310efb69172a0c.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-tag-pipeline-ai-costs.dadd5dc5df518f514f310efb69172a0c.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Tag Pipelines Rule Setup page, showing user_email values mapped to team values through an existing reference table, and additional tag mapping options." /%}

After mapping, attributed spend appears in provider-specific dashboards and [Cost Reports](https://docs.datadoghq.com/cloud_cost_management/reporting.md):

{% image
   source="https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-anthropic-ai-cost-reporting.ff6fa9c8c8472419433157278660c5b9.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-anthropic-ai-cost-reporting.ff6fa9c8c8472419433157278660c5b9.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="A provider-specific dashboard with a stacked bar graph showing daily provider spend attributed by team and model name, and a summary list of the spend attributions." /%}

## Allocating your AI gateway spend{% #allocating-your-ai-gateway-spend %}

{% alert level="info" %}
Custom AI gateway allocation is in Preview.
{% /alert %}

If your teams send LLM requests through a shared AI gateway, the provider bill shows that traffic under a single API key or project. Connect your AI gateway to split that spend across the teams, users, or services that sent the requests, using token usage reported by your gateway.

The **Connect your AI Gateway** flow generates [Custom Allocation Rules](https://docs.datadoghq.com/cloud_cost_management/allocation/custom_allocation_rules.md?tab=even) that divide each provider bill in proportion to the token usage your gateway reports.

### Requirements{% #requirements %}

To connect your AI gateway, you need:

- At least one of the following AI providers set up for Cloud Cost Management:
  - [Anthropic](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=anthropic#configure-your-saas-accounts)
  - [OpenAI](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md?tab=openai#configure-your-saas-accounts)
- A source of gateway token usage:
  - [Agent Observability](https://docs.datadoghq.com/llm_observability.md), which reports `ml_obs.span.llm.*.tokens` metrics
  - The [LiteLLM integration](https://docs.datadoghq.com/integrations/litellm.md), which reports `litellm.*_tokens.metric.count` metrics
- The `cloud_cost_management_write` permission

A provider is available to allocate only if its bill is connected to Cloud Cost Management **and** your usage source reports requests to that provider.

### Create gateway allocation rules{% #create-gateway-allocation-rules %}

1. Navigate to [**Cloud Cost** > **Summarize** > **AI**](https://app.datadoghq.com/cost/summarize/ai-costs) and click **Connect your AI Gateway**.

   {% image
      source="https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-gateway-connect-button.b7613889b66599b182264fd09a3548d1.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-gateway-connect-button.b7613889b66599b182264fd09a3548d1.png?auto=format&fit=max&w=850&dpr=2 2x"
      alt="The AI Costs page header in Cloud Cost Management, with the Connect Your AI Gateway button highlighted." /%}

1. **Select usage metric**: Choose where your usage telemetry comes from.

   - Select **Agent Observability** or **LiteLLM**.
   - Filter the usage metric to your gateway traffic (for example, `service:ai_gateway`). For LiteLLM, you can instead select **Allocate my costs based on the entire metric**.
   - Choose up to three tags to break your AI spend down by, such as `team`, `user`, or `service`.

1. **Match to bills**: Select the provider bills to split. For each provider, add a bill filter that identifies the gateway's spend on that bill (for example, `api_key_name:gateway_api_key` for Anthropic or `project_name:ai_gateway` for OpenAI). Bill filters support the `is` operator.

1. **Confirm coverage**: Review the percentage of provider-reported tokens that your usage source accounts for, for each token type, over a seven-day window. If coverage exceeds 100% for a token type, check that your usage filter and bill filter cover the same API key or project. For more information, see How gateway costs are allocated.

   {% image
      source="https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-gateway-coverage.5f8e535ae643bedc6c11d335b72afa0d.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/cloud_cost/ai_costs/ccm-ai-gateway-coverage.5f8e535ae643bedc6c11d335b72afa0d.png?auto=format&fit=max&w=850&dpr=2 2x"
      alt="The Confirm coverage step of the Connect your AI Gateway flow, showing Anthropic coverage percentages for output, input, cache read, and cache write tokens." /%}

The flow creates one allocation rule for each provider and token type, such as input, output, cache read, and cache write tokens.

After the rules are processed, the tags you selected are added to your provider costs. Use these tags across Cloud Cost Management, including [Cloud Cost Explorer](https://app.datadoghq.com/cost/explorer), dashboards, [Cost Reports](https://docs.datadoghq.com/cloud_cost_management/reporting.md), [monitors](https://docs.datadoghq.com/cloud_cost_management/cost_changes/monitors.md), and [budgets](https://docs.datadoghq.com/cloud_cost_management/planning/budgets.md).

### How gateway costs are allocated{% #how-gateway-costs-are-allocated %}

Gateway allocation rules compare your gateway's token usage against the token usage reported by the provider for the same bill scope. For each model and day, **coverage** is the gateway's tokens divided by the provider-reported tokens. For example, 80,000 output tokens reported by your gateway out of 100,000 output tokens reported by the provider is 80% coverage.

- The covered share of cost is split across the tags you selected in proportion to each tag value's token usage.
- The remaining share of cost is attributed to `uninstrumented`. This represents spend on the bill scope that your gateway did not report, such as requests that bypass the gateway.
- Coverage is capped at 100%. If your gateway reports more tokens than the provider, all of the cost is split across your selected tags.
- If the provider reports no token usage for a model on a given day, those costs are not allocated.

### Manage gateway allocation rules{% #manage-gateway-allocation-rules %}

Rules created by the **Connect your AI Gateway** flow appear in the **AI Gateway Rules** section of the [Custom Allocation Rules](https://docs.datadoghq.com/cloud_cost_management/allocation/custom_allocation_rules.md?tab=even) page, grouped by provider. You can view or delete gateway rules, but you cannot edit or disable them. To change a gateway configuration, delete its rules and run the **Connect your AI Gateway** flow again.

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Cloud Cost Management](https://docs.datadoghq.com/cloud_cost_management.md)
- [SaaS and AI Costs](https://docs.datadoghq.com/cloud_cost_management/setup/saas_costs.md)
- [Custom Allocation Rules](https://docs.datadoghq.com/cloud_cost_management/allocation/custom_allocation_rules.md)
- [Tag Pipelines](https://docs.datadoghq.com/cloud_cost_management/allocation/tag_pipelines.md)
- [Reporting](https://docs.datadoghq.com/cloud_cost_management/reporting.md)
- [Cloud Cost Monitors](https://docs.datadoghq.com/cloud_cost_management/cost_changes/monitors.md)
- [Budgets](https://docs.datadoghq.com/cloud_cost_management/planning/budgets.md)
- [Forecasting](https://docs.datadoghq.com/cloud_cost_management/planning/forecasting.md)
- [Attribute AI costs across providers with Datadog Cloud Cost Management](https://www.datadoghq.com/blog/cloud-cost-management-ai-costs/)
- [Making agentic token costs visible in production](https://www.datadoghq.com/blog/making-agentic-token-costs-visible-in-production/)
- [Answer any cost question faster with the Cloud Cost skill in Bits Chat](https://www.datadoghq.com/blog/cloud-cost-skill-bits-chat/)
- [How Datadog saves over $1 million each month by optimizing AI usage](https://www.datadoghq.com/blog/how-datadog-saves-money-by-optimizing-ai-usage/)
- [Beyond the $1 AI era: How federal agencies can build the evidence for FY27 renewals](https://www.datadoghq.com/blog/federal-agencies-ai-spend-cloud-cost-management/)
- [Manage Cursor costs with Datadog Cloud Cost Management](https://www.datadoghq.com/blog/cursor-cloud-cost-management/)
