Finance sees a Bedrock bill. Engineers see a PR. FinOps that works bridges those views: cost per merged PR, per squad, per feature flag — in a dashboard people open weekly, not a quarterly surprise.
⚡ TL;DR: Attribute every invoke to
squad,service,pr/ticket, andfeature. Show $ and tokens next to merge metrics. Cap budgets in the gateway (Day 80). Celebrate cost↓ quality↑, not raw usage.
Attribution that survives audits
# ✅ Mandatory dims on every model call
REQUIRED = {"squad", "service", "feature", "env"}
def invoke(client, *, body, dims: dict):
missing = REQUIRED - dims.keys()
if missing:
raise ValueError(f"missing cost dims: {missing}")
# emit EMF / OTel attributes from dims
return client.converse(**body, # plus logging dims
)
Map GitHub CODEOWNERS → squad. Map gateway API keys → service. Refuse untagged traffic in staging first, then prod.
Dashboard engineers open
Three panels only (same spirit as Day 71):
- $ / merged PR (7-day rolling) by squad
- Tokens by feature with budget burn-down
- Quality overlay — revert rate or eval score vs spend
-- warehouse sketch
select squad,
sum(cost_usd) / nullif(count(distinct pr_id), 0) as usd_per_pr,
sum(input_tokens + output_tokens) as tokens
from ai_invokes i
join merges m using (pr_id)
where day >= current_date - 7
group by 1
order by 2 desc;
❌ A single monthly “AI” cost center with no PR join key.
Failure modes
Orphan traffic with squad=unknown always balloons. Make the gateway reject missing dims in prod after a bake period. Shared “platform” buckets hide product spend — force feature tags even for shared RAG.
Closing checklist
- [ ] Required cost dimensions enforced in gateway
- [ ] Join invokes → PRs / tickets in the warehouse
- [ ] Budget alerts at 50/80/100% per squad
- [ ] Weekly review in eng staff, not only FinOps
- [ ] Kill or rewrite features with high $ and flat quality
Series navigation
Day 78: Load Shedding When the Model Is Sick · Day 80: Project: Platform AI Gateway
Last updated September 11, 2026
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.
