Est.

Tagging LLM Requests by Feature and Team at the Gateway Layer

Tagging at the gateway layer lets teams finally see which features and teams are driving LLM costs.

Correspondent · · 9 min read
Cover illustration for “Tagging LLM Requests by Feature and Team at the Gateway Layer”
Cost Attribution · September 26, 2026 · 9 min read · 2,081 words

Model calls pile up fast, and most companies have no shared label for any of them. A support team ships a copilot feature, a data team wires up a summarizer, a growth team bolts an agent onto onboarding. Each one fires requests at a provider, and none of those requests carry any marker showing who sent them or why.

Check a native usage dashboard from a provider like OpenAI, and spend appears in aggregate. Total tokens, total cost, maybe a breakdown by API key or project. What it won't show is which feature burned through the budget, or which customer's usage is driving the bill. That gap, between "here's the number" and "here's who's responsible for the number", is the core problem.

It gets worse as the provider list grows. Different providers use different authentication schemes, different request formats, different rate limits, and pricing that can swing 10 to 20 times between one model and another. Stitch three or four providers together without a shared tagging layer, and cost data turns into a pile of incompatible spreadsheets.

The timing makes this urgent, not theoretical. Enterprise LLM adoption crossed 80% in 2026. Gartner projects that by the end of 2026, 40% of enterprise applications will run task-specific AI agents, up from under 5% in 2025, and each of those agents can issue dozens of model calls per task. Agentic workflows already burn 5 to 30 times more tokens than a single request-response call, and multi-agent setups have been known to blow past initial cost projections by 3 to 10 times. Usage that used to be small enough to eyeball becomes, at that volume, completely invisible without a system built to track it.

What does "operational liability" actually look like day to day? A cost spike with no owner. A compliance request asking who sent what data to which model, on what date, that can't be answered because nobody logged it that way. No lever to pull when one team's feature quietly eats the whole month's budget, because usage arrives as one undifferentiated stream. In 2025, 60% of AI projects ran 30 to 50% over their original cost estimates, the direct, measurable consequence of exactly this blind spot. That's the direct, measurable consequence of exactly this blind spot: in 2025, 60% of AI projects ran 30 to 50% over their original cost estimates. It's the direct, measurable consequence of exactly this blind spot.

More dashboards won't fix it. What fixes it is structured metadata attached to the request itself, at the one point in the system every request has to pass through.

Request tagging and what a tag represents

A tag is metadata attached to a request the moment it's made, not something bolted on afterward during a log review. It rides along with the request from the start, so every token it consumes, every millisecond of latency it produces, and every routing decision made on its behalf gets recorded against that tag.

That's a meaningful distinction from a dashboard filter or a provider-side label. Filtering a dashboard after the fact only works if the data underneath already has the right structure. Tagging happens before the request ever leaves your infrastructure. The structure exists from the beginning.

A few dimensions tend to matter most:

Model and provider, which lets teams compare cost and performance across vendors on equal footing

Beyond those five, teams add whatever custom labels make sense for their own business: an experiment ID, a release version, a priority tier.

Tags aren't just labels sitting next to a log line. They're the unit of measurement itself. Once a request is tagged, every downstream number, token count, latency, cost, error rate, can be sliced along that tag. A single LLM request can cost anywhere from $0.0001 to several dollars, depending on the model, the input length, the output length, and how many reasoning tokens got burned along the way. At that range, tagging at the request level is essential. It's the only unit fine-grained enough to mean anything.

Without tags, cost data only tells a story at the provider level: "we spent $40,000 on OpenAI last month." With tags, that same data tells a story at the feature level, the team level, the customer level. The question left is where in the system that tagging needs to happen for it to actually hold up.

The gateway layer as the only place tagging holds at scale

Tag inside application code, and consistency depends on every engineer, on every team, remembering to do it right, every time. Tag inside application code, and consistency depends on every engineer, on every team, remembering to do it right, every time, and that dependence breaks down in practice.

A team renames a feature and forgets to update the tag attached to it. A new endpoint ships without any tag. Nobody notices, because the gap is invisible right up until someone tries to reconcile a bill and can't figure out where a meaningful chunk of spend actually went. Add in provider-specific SDKs, tagging an OpenAI call one way and an Anthropic call another, and the fragmentation multiplies. Each integration becomes its own island.

A gateway removes that dependency on memory. An LLM gateway sits between the applications and the model providers, exposing one API that every request has to pass through, regardless of which service sent it or which provider will serve it. Set the tagging schema once at that layer, and it applies to everything, automatically. No team can skip it by accident, because skipping it isn't an option built into the path.

That single choke point does more than tag things. It's where the request actually terminates from the client's side, gets checked against policy, gets routed to a model, gets normalized across provider quirks, and gets its telemetry emitted, all before a response goes back out. That telemetry becomes the system of record: which team called which model, at what cost, under which limits.

A plain proxy just forwards requests along. It doesn't apply policy, and it doesn't produce that same record. Route traffic through something that only proxies, and the compliance gap doesn't close, it just moves to whoever has to fill it in by hand later.

The mechanism that makes this enforceable rather than just a suggestion is the virtual key. A virtual key carries its own metadata, team, project, environment, and every request made using that key gets stamped with that metadata automatically. Keys can inherit attributes from a team or a customer above them, or override them where needed, so fine-grained attribution happens without asking a developer to remember anything at request time. A policy that's enforced works; a policy that's merely suggested in a wiki page nobody reads does not.

Structuring a maintainable tagging schema

The instinct on day one is to tag everything. Resist it. Teams that try to build a full taxonomy up front end up with tags applied inconsistently, half-filled-in fields, and data nobody trusts by month three.

Start smaller. Three tiers, mandatory, cover most of what matters:

Environment, production or not

Everything past that gets added once a team proves it'll actually keep the tag current. Adding a dimension is easy. Getting people to maintain it is the hard part: a team should test that before expanding the schema.

Each mandatory tier does a specific job. Team maps straight to budget ownership, and that mapping makes per-team spend tracking and chargeback possible. Feature is the unit that answers "does this feature cost what it was supposed to." Environment keeps a developer's staging experiments from getting billed against the production budget, which happens more often than it should when this tag is missing. Model and provider get captured automatically by the gateway with no developer action needed, but the schema should still treat that as a first-class field, not an afterthought.

Once a deployment matures, a few more dimensions earn their place. Customer or tenant ID enables per-customer chargeback in a multi-tenant product, stamped straight from the inbound request context. Priority or tier lets routing logic send cheap batch work to a cheaper model while reserving the strongest model for real-time, user-facing calls. Experiment or rollout ID keeps cost attribution intact during an A/B test, so a model swap doesn't quietly blow up the numbers for a week. Agent trace ID matters most in agentic setups, where one user action can kick off dozens of model calls, and without a trace ID there's no way to link them back to the task that caused them.

Ownership matters here as much as the schema itself. Tags defined loosely in application code drift over time; tags enforced through gateway-level virtual key configuration don't, because there's a single place they live. That argues for a platform team owning the taxonomy, not each feature team defining its own conventions. Naming has to be consistent too: "team:platform-eng" and "team:platform_eng" read as two different tags in most systems, so normalization needs to happen at the configuration layer, not left to whoever's typing that day. And the schema needs a real process for adding new values, an approval step, a rollout plan, rather than letting tags multiply ad hoc every time a new feature launches.

Tagged requests powering real-time cost visibility and budget enforcement

The scale of the spend problem is already visible in the numbers. Model API spending more than doubled, from $3.5 billion to $8.4 billion, between late 2024 and mid-2025. CloudZero's State of AI Costs 2025 report, based on a survey of 500 software professionals at manager level and above, put average enterprise monthly AI spend at $85,521 in 2025, up 36% year over year. Yet only 34% of companies had a mature cost management process in place to handle that growth. That gap, fast-rising spend paired with immature governance, is where the operational risk actually sits.

Leaders' talk about AI adoption reflects the same pattern. Jellyfish's survey of 636 engineering leaders found rising AI tool costs ranked as the top adoption challenge. And the FinOps Foundation's State of FinOps report found that 98% of respondents now actively manage AI spend, up from 63% just a year before. Managing AI cost is standard practice now. It's standard practice.

Tagged requests are what makes that management possible in real time rather than after the invoice arrives. Every tagged request produces a cost record, token count multiplied by the model's price, stamped with team, feature, environment, and customer dimensions. Aggregate those records as they come in, and spend-by-team, spend-by-feature, spend-by-customer, and spend-by-model views build themselves, no manual reconciliation required. Custom tag grouping lets a team slice that same data by user, by model, by whatever dimension actually matters to them that week.

Compare that to the old approach: waiting for the monthly invoice, then trying to reverse-engineer which feature caused the spike. Tagged data is actionable the second it's generated. Invoice data is a history lesson, and by the time it arrives, the budget's already gone.

Tags also make actual enforcement possible, not just visibility:

Rate limits, per-key or per-team caps on requests and tokens, which stop a runaway agent loop from draining a budget in an afternoon

Attribution has to sit underneath those four levers, because without it none of them can function.

That same attribution is what makes showback and chargeback possible for organizations running multiple teams or serving multiple customers. Showback, just showing a team its own share of spend so it can self-correct, needs team-level tags to function. Chargeback, actually billing a customer or an internal team for what they used, needs customer ID tags plus a per-request cost record to back it up. Neither is achievable from aggregate provider billing. Both become close to routine once tagging sits at the gateway.

Tagging for production observability that can't be reconstructed after the fact

Strip the tags away, and what's left for an on-call engineer is aggregate error rates and aggregate latency numbers, averaged across every model call in the system. A latency spike appears on a graph, but there's no way to tell whether it's coming from the document summarizer, the support copilot, or some agent loop nobody's watched closely in weeks.

That's the real cost of skipping this layer. It's not just a billing inconvenience. It's a debugging problem that gets harder, not easier, the longer it goes unsolved, because by the time someone needs the answer, the untagged traffic that would have given it to them is long gone, already averaged into a number that tells nobody anything.

Sources

  1. truefoundry.com
  2. dev.to
  3. truefoundry.com
Filed underCost Attribution

More in Cost Attribution