AI and Compute Cost Visibility per Customer
Query per-customer AI and compute costs broken down by period and customer type using the cost economics API.
AI and Compute Cost Visibility per Customer
The cost economics API gives teams direct, queryable access to per-customer AI and compute cost data. Costs are segmented by time period and customer type, eliminating the need for bespoke analysis to understand what Guard costs to run for a given customer.
Overview
The API returns itemised cost figures for any customer across a chosen time period. Each response includes:
Supported period granularities
You can retrieve costs at the following granularities:
- Daily
- Weekly
- Monthly
- Quarterly
- Yearly
Specify the period using either an anchor date (Guard resolves the surrounding window automatically) or an explicit date range (a start date and an end date).
Customer-type segmentation
Customers can change classification over time (for example, moving from one customer type to another). The API handles these transitions by splitting cost reporting at type-transition boundaries. Periods during which a customer's classification changed are reported as separate segments, each covering only the portion of time the customer held that type. This ensures cost figures are accurate and attributable.
Querying costs
To retrieve costs for a customer, call the cost economics endpoint with the following parameters:
Provide either anchor_date or a date_range; supplying both is not supported.
Example: query monthly costs with an anchor date
GET /api/cost-economics/customer/{customer_id}?period=monthly&anchor_date=2025-06-01
The response will include the resolved monthly window containing 2025-06-01, with separate compute_cost and ai_cost figures.
Example: query costs for an explicit date range
GET /api/cost-economics/customer/{customer_id}?period=weekly&date_range.start=2025-05-01&date_range.end=2025-05-31
The response will return one or more weekly segments covering the specified range, with per-segment cost breakdowns.
Interpreting results
- Compute cost and AI cost are reported independently, allowing you to attribute spend to infrastructure usage versus AI model consumption separately.
- When a customer's type changed within the queried period, the response will contain multiple segments. Each segment corresponds to a contiguous window during which the customer held a single type.
- Periods with no attributable activity will return zero values for both cost fields rather than being omitted.
Access and permissions
Access to the cost economics API is governed by your organisation's existing role-based permissions. Contact your Praetorian account team if you do not have access and believe you should.