Requesty
Back|FEB '26OBSERVABILITY / REQUESTY FEATURES
4 MIN READ|

Label your API keys: the cost-attribution trick most teams miss

Thibault Jaigu
Thibault Jaigu
CEO & Co-Founder
Last updated

A Requesty API key is not just a secret — it's a record with a structure. One of those fields is labels: arbitrary key-value strings you attach to the key itself. That one feature is the cleanest way to attribute LLM spend by team, feature, environment, or customer without adding a single line of instrumentation to your application. This post is the short version of how to use it.

The short version: create one key per deployable unit, label it with the four or five dimensions you care about, and every request that key makes inherits that attribution automatically. Then slice your spend in the dashboard by any label, any time — no code, no migration.

The problem: spend attribution without labels

A typical LLM bill looks like this: $14,219 on Anthropic, $8,603 on OpenAI, $2,145 on Google. Useful for a board slide; useless for decisions. The question you actually need to answer is "which team / feature / customer is burning the budget, and is it working?" That requires attribution.

The naive answer — one key per team — is a start. But teams ship multiple features, across multiple environments, often on behalf of multiple customers. One key per team × feature × env × customer is a combinatorial explosion of credentials to manage.

Labels collapse that explosion into a flat metadata grid.

What the key record actually looks like

Per the API reference for GET /v1/manage/apikey, each key carries:

FieldTypePurpose
idUUIDThe key record identifier
namestringHuman-readable name
monthly_limitdecimalSpend ceiling, admin-set
monthly_spenddecimalCurrent spend in this cycle
permissionsobjectRead/write flags for management + completions
labelsobjectArbitrary key-value string pairs
created_byUser objectWho created the key

The labels field is what makes the rest powerful.

A schema that covers 90% of use cases

Four labels, consistently applied across every key you create:

LabelExample valuesWhy it matters
teamgrowth, support, dataWhich team's budget this belongs to
envprod, staging, devNever conflate the three in analytics
featureautocomplete, summarize, triageProduct-surface attribution
tierinternal, free, paidIdentify revenue-generating vs internal traffic

Add customer_id if you're a SaaS billing per-tenant, or cost_center if your finance team lives in one. Don't sprinkle ad-hoc labels randomly — pick a schema and stick to it.

Creating a labeled key (curl + python)

The key management API docs cover the full endpoint surface. The core flow:

Shell
curl -X POST https://api.requesty.ai/v1/manage/apikey \
  -H "Authorization: Bearer $REQUESTY_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "growth-autocomplete-prod",
    "monthly_limit": 2000,
    "permissions": {
      "completions": "write",
      "manage": "none"
    },
    "labels": {
      "team": "growth",
      "env": "prod",
      "feature": "autocomplete",
      "tier": "paid"
    }
  }'

Python, for when you do this as part of a provisioning flow:

Python
import httpx, os
 
def create_labeled_key(name, monthly_limit, labels):
    return httpx.post(
        "https://api.requesty.ai/v1/manage/apikey",
        headers={"Authorization": f"Bearer {os.environ['REQUESTY_MANAGEMENT_KEY']}"},
        json={
            "name": name,
            "monthly_limit": monthly_limit,
            "permissions": {"completions": "write", "manage": "none"},
            "labels": labels,
        },
    ).json()
 
key = create_labeled_key(
    name="growth-autocomplete-prod",
    monthly_limit=2000,
    labels={"team": "growth", "env": "prod", "feature": "autocomplete", "tier": "paid"},
)
print(key["id"], key["labels"])

That's it. From this point every chat completion made with that key inherits team=growth, env=prod, feature=autocomplete, tier=paid in the analytics — no application-side tagging required.

What you can do once labels are in place

Per-team budgets with automatic attribution. Set monthly_limit on the key, label it team=growth, and you have both the hard cap and the reporting dimension in one place. Growth overspends → they see it on their dashboard, finance sees it on theirs.

Per-feature ROI. Your CFO asks "what did the new autocomplete feature cost last quarter?" — you filter dashboard by feature=autocomplete and answer in 20 seconds. Without labels that question takes a week.

Per-customer pricing for SaaS. Tag every tenant key with customer_id, export monthly spend per tenant, cost-plus markup → invoice. This is the plumbing for usage-based billing of LLM-backed features.

Regression detection. When spend spikes, group by feature and find the culprit immediately. Pair this with alerts and you don't even have to look — the dashboard pings you.

Combine with routing policies for full control

Labels attribute spend. Routing policies control how that spend is generated. Together: you decide per-key which policy applies (e.g. team=support, env=prodpolicy/support-resilient), and the policy decides which model actually serves the request. One key → one policy → one cost centre → one dashboard row.

That's the end-state. Four labels, one policy per key, a dashboard that actually tells your finance team something.

The one-line takeaway

API key labels are the cheapest attribution system you will ever ship. They add zero code to your application, zero latency per request, and turn a flat LLM bill into a spreadsheet your product, finance, and engineering teams can all read. Ship the schema today, thank yourself next quarter.

Frequently asked questions

What are API key labels in Requesty?
Labels are arbitrary key-value string pairs you attach to a Requesty API key. They're stored on the key record (alongside id, name, monthly_limit, permissions, created_by) and surface in analytics, letting you slice spend and usage by any dimension you care about — team, feature, environment, customer, or cost center.
Why not just give each team a separate API key?
You already should. Labels complement that — they let you group and slice across keys. A team can have one key per feature, one per environment, one per customer tenant — and labels ({team: 'growth', env: 'prod', feature: 'autocomplete'}) make the aggregation possible without naming gymnastics.
How do I attach labels to a key?
Via the key management API: POST or PUT to /v1/manage/apikey with a labels object. Labels are key-value strings, set once when the key is created or updated at any time. They do not require application code changes — they live on the key itself.
Can I filter analytics by label?
Yes. The Requesty dashboard lets you group spend, request volume, and latency by any label key. Common slices: spend per team, tokens per feature flag, error rate per customer.
What's a good label schema to start with?
Four labels cover 90% of attribution use cases: team (who owns the key), env (prod/staging/dev), feature (which product surface generates the traffic), tier (internal/free/paid). Add customer_id if you're a SaaS billing per-tenant.
Related reading