Send one extra header on every request and AIgateway aggregates spend per feature, per tenant, or per any free-form string. Read it back from /v1/usage/by-tag.
The most common surprise on an LLM bill is finding out one feature you barely thought about — a background summarizer, a moderator agent, a debug helper — is silently 40% of your spend.
Cost tags fix that with one header. Tag every request with the feature it powers and we aggregate per tag for you.
Add an x-aig-tag header. Free-form string. Use whatever taxonomy you like.
curl https://api.aigateway.sh/v1/chat/completions \
-H "Authorization: Bearer sk-aig-..." \
-H "x-aig-tag: summarize" \
-H "Content-Type: application/json" \
-d '{
"model": "moonshot/kimi-k2.6",
"messages": [...]
}'Most SDKs let you pass extra headers per request.
from openai import OpenAI
client = OpenAI(
base_url="https://api.aigateway.sh/v1",
api_key="sk-aig-...",
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-4.6",
messages=[...],
extra_headers={"x-aig-tag": "summarize"},
)GET the usage endpoint with a window. Optionally filter by a single tag.
curl https://api.aigateway.sh/v1/usage/by-tag?month=2026-04 \
-H "Authorization: Bearer sk-aig-..."
# => [
# { "tag": "summarize", "requests": 8210, "cost_cents": 4210 },
# { "tag": "chat", "requests": 3104, "cost_cents": 9830 },
# { "tag": "rerank", "requests": 912, "cost_cents": 118 }
# ]If a feature must not exceed a budget — say a free-tier user-facing chat — set a hard cap. We enforce it before dispatch, so you never get charged for a request that was going to be over-budget.
curl -X POST https://api.aigateway.sh/v1/budgets \
-H "Authorization: Bearer sk-aig-..." \
-d '{ "tag": "summarize", "monthly_cap_cents": 50000 }'