← All build notes Engineering

Keeping AI usage costs visible inside a product

Gripz meters AI usage in plain view and alerts the team before it reaches the limit. Here is how to design and build a usage meter like it.

ArcLayer teamBuild notesNov 2, 20263 min read

Gripz is a customer support product we designed and built: live chat, an AI agent and a helpdesk in one product. Every reply the AI agent writes costs money, and a support lead does not want a surprise bill. Gripz meters AI usage in plain view, with an alert before usage reaches the limit.

The same pattern fits any product that runs AI on a customer's behalf. The code in this note is a generic sketch and is not taken from Gripz. The bar chart at the top is an illustration with no real data behind it: daily usage climbing toward a limit line.

Meter every call where it happens

Record usage at the point where the product calls the model, in one shared function, so no feature can skip it. Store the account, the feature, the units used and the time.

ts
// usage.ts: one wrapper for every model call
type Feature = 'chat_reply' | 'summary';

export async function withUsage<T>(
  accountId: string,
  feature: Feature,
  call: () => Promise<{ result: T; units: number }>,
): Promise<T> {
  const { result, units } = await call();
  await db.usage.insert({ accountId, feature, units, at: new Date() });
  return result;
}

Show the meter where people work

A usage figure on a billing page is no help to a support lead in the middle of a shift. Put the meter in the product's main view. Show usage against the limit in plain numbers, with a bar beside them for a quick read.

Alert before the limit

An alert at 100% arrives too late to act on. Send warnings at set points before the limit, and send each one once per billing period.

ts
const THRESHOLDS = [0.75, 0.9]; // example values: warn at 75% and 90%

export function warningsDue(used: number, limit: number, sent: number[]) {
  const share = used / limit;
  return THRESHOLDS.filter((t) => share >= t && !sent.includes(t));
}

The thresholds above are examples. Set them from how fast an account's usage moves: a team that uses a tenth of its allowance each day needs its first warning earlier than one that uses a little each week.

Decide what happens at the limit

This is a product decision, so a person makes it and records it in the decision log. The options include pausing the AI agent and passing chats to people, allowing a small overage, or asking an admin to raise the limit. Each option trades cost control against a customer waiting longer for an answer.

Build it
with
clarity.

Tell us what you are building and where it stands today. We will reply with questions and a first plan. Write to [email protected].

  • RezanCo-founder
  • RanaCo-founder