Cost Analysis
Cost Analysis shows where an organization's usage and spend come from across environments, teams, members, caller API keys, models, target models, days, and cost attribution tags. Filter the usage first, then group the result by the dimension you want to compare.
Tags are optional: configure cost attribution tags when the organization needs custom dimensions such as department, subsidiary, project, or cost center.
Prerequisites
Before starting, prepare the following:
- Permission to read usage in the organization.
- Recorded gateway usage in at least one environment.
- For a current tag grouping or filter, a declared tag key and recorded usage that carries it. A deleted key remains available for time ranges whose usage still carries it. See Cost Attribution Tags.
With the prerequisites ready, start by narrowing the usage you want to analyze.
Filter and Group Usage
The organization-level Cost Analysis page groups usage from every environment in the organization by one dimension at a time. The Filter section selects the usage to analyze, and Statistics breaks it down. For example, filter on business_group=cloud, then group by the department tag to see how that business group's spend splits across departments.
The Filter section comes first:
- Time range: the last 24 hours, 7 days, or 30 days, or a custom range. The page reads whole hours, so the start is rounded down and the end up to the hour.
- Filters: environments, team, member, model, and any number of tag
key=valuefilters. Filters on different tag keys must all match, and several values of one key match any of them. A drill-down from an API key row adds that key as a filter. Each active filter shows as a chip below the controls, and Clear filters removes them all.
The Statistics section then breaks the filtered usage down:
- Group by: a tag key, team, member, API key, model, environment, day, or target model. See Compare a Model's Targets. Grouping by day shows a daily bar chart; other groupings show horizontal bars.
- Sort by: cost, total tokens, input tokens, output tokens, requests, or successful requests. Groups are listed largest first.
- Refresh: reloads the figures, together with the tag keys and the names of teams, members, and environments.
Select a row to drill down. The page applies that group as a filter and chooses the next grouping not already fixed by the filters. Use the breadcrumb to return to an earlier step.
When grouping by team or by a tag key, a Budget (current period) column shows the matching team or tag budget's current-period spend and limit. When grouping by API key, each key row links to the request logs of the environment the key belongs to, filtered to that key.
After a control-plane upgrade, the page shows the same backfill notice as the Usage view. The figures remain incomplete until the backfill finishes. Cost is in the organization's currency.
Interpret Special Groups and Labels
Cost Analysis preserves historical usage even when its current resource or tag metadata has changed. The following labels explain how that history appears:
| Label or row | Meaning | What you can do |
|---|---|---|
| Not set | The usage has no value for the selected grouping. | Review the row as a whole; it cannot be drilled into. |
| Day row | Usage from one UTC day. | Change the time range or grouping; day rows cannot be drilled into. |
| Other N groups | The sum of groups beyond the first 50. The listed groups and this row add up to the total. | Narrow the filters to bring a group into the first 50. |
| Deleted | A tag key or resource no longer exists, but selected usage still refers to it. Resources show the first eight characters of their ID. | Select the badge to view and copy the full resource ID. For a deleted tag key, type a value or drill down from a group because value suggestions are unavailable. |
| Removed | A member no longer belongs to the organization. | Select the badge to view and copy the member ID. |
| Name unavailable | The dashboard could not load enough metadata to confirm the resource's current state. | Retry the view; this label does not mean the resource was deleted. |
Tag controls offer every declared key and any deleted key present in the selected usage. Value suggestions come from current caller API keys, teams, members, and recent usage. When the organization has no declared tag keys, the controls link to Tag Keys, and tag filtering remains unavailable until a key is declared.
Compare a Model's Targets
A model row groups usage by the name the caller addressed. To see how a model group's traffic was distributed, select Show targets on its row, or select Target model in Group by.
Each target row shows its Provider key, the Billed amount, and the Platform cost. Platform cost prices the usage at the target's own price, without the group's price or off-peak discount. Usage with no target price appears beside the amount as a number of unpriced attempts.
The counts are attempts on each target, including failed attempts and fallbacks. They can therefore add up to more than the model's request count.
Usage of a model called directly stays on that model's row, including responses served from the gateway's cache. Usage of a model group that reached no target falls in Not set. This includes a group response served from the cache and a request that failed before target selection.
Target rows and platform cost cover only usage recorded after the control-plane release that added them, so an earlier range can show less than the model row. Show targets and the grouping are unavailable while filtering by team, member, API key, or tag.
For example, suppose the chat model group distributes requests across several targets. The following query compares what each target served, what it billed, and what it cost at its own price:
GET /usage_analysis?group_by=target_model&model=chat
The endpoint takes the same permission as other usage reads. A target comparison cannot be combined with team, member, caller API key, or tag filters; such a request returns 400. Each group carries:
| Field | Meaning |
|---|---|
key | The target model's ID. It is null for usage of a model group that reached none of its targets, such as a cache hit. |
name | The target model's current name, or null once it no longer exists. |
environment_id | The environment the target model belongs to. It is absent once the model no longer exists. |
provider, provider_key_name | The vendor ID and display name of the target's provider key, or null once the model or the key no longer exists. |
cost_usd | The billed amount, in the organization's currency. |
prompt_tokens, completion_tokens, total_tokens | Token counts of the attempts. |
request_count | Attempts on this target, counting each failed attempt and fallback. |
success_count | Attempts on this target that succeeded. |
upstream_cost | The summed platform cost, or null when every attempt was unpriced. |
unpriced_request_count | Attempts on this target whose upstream_cost is null. An attempt that reached no target is not counted. |
remainder and total also carry upstream_cost and unpriced_request_count.
For broader automation, GET /usage_analysis returns the dashboard's figures, and GET /usage_analysis/tag_keys returns the tag keys present in a time range, including deleted keys. See the AISIX Enterprise / Cloud Admin API.
Next Steps
Configure Cost Attribution Tags for organization-defined allocation dimensions, or review Model Pricing when a cost is missing or differs from the provider's pricing basis. Use Usage Reporting for organization-wide totals and reporting behavior.