Tagging requests for per-feature cost attribution
The single most important habit for getting value out of Flaxxa AI's cost ledger is tagging every request. The tags are how spend gets attributed.
What to tag
At minimum, every request should carry:
feature— the product feature or use case the call belongs to (e.g.support-bot,doc-summary,code-completion).tenant— if you're running multi-tenant SaaS, the tenant id of the customer the call serves.user— the end user id, if relevant. Useful for per-user rate limiting and cost charge-back.
Anything else useful — region, language, plan_tier, experiment_id. The schema is open; the dashboard pivots on whatever you set.
How to send tags
Two equivalent options:
Option 1: header (recommended)
X-Flaxxa-Tags: feature=support-bot,tenant=tenant_42,user=u_1842
Option 2: request body
{
"model": "auto",
"messages": [...],
"tags": {
"feature": "support-bot",
"tenant": "tenant_42",
"user": "u_1842"
}
}
Both land in the ledger identically. The header form is slightly easier to add via a SDK middleware — the SDK can derive tags from the request context once and stop product squads from forgetting.
What appears in the dashboard
The cost ledger pivots by any tag. From AI → Ledger you can:
- Group by
feature— see per-feature spend over time - Group by
tenant— for white-label SaaS, see per-customer spend (and charge back if pricing is metered) - Group by
user— find the heaviest users - Cross-pivot — feature × tenant tells you which features are big drivers per customer
Budget alerts on tags
Set budgets at any tag granularity. AI → Budgets → New. Common patterns:
- Total workspace daily budget (kill switch if anything goes wrong)
- Per-feature monthly budget (so a runaway feature can't drain the workspace)
- Per-tenant daily budget (for multi-tenant SaaS — isolates noisy tenants)
Alerts at 80% of cap (Slack/email); 429 responses at 100%. Soft caps recover at midnight in the budget's timezone.
Common tag-discipline mistakes
- Forgetting to tag legacy code paths. Every untagged call lands as
(untagged)on the dashboard. If that bucket is more than 10%, you have squads not tagging. - Tagging at the wrong granularity. If
feature=appfor everything, you can't pivot. Usefeature=support-bot, notfeature=app. - Mixing case + spelling.
support-botandSupportBotare different tags. Pick a convention; lint for it in CI.
Was this article helpful?
