Skip to content

Run several products in one workspace

Say your company runs two products on Limitry, a writing assistant and a support bot, and both pay per token for their AI features. Each of your users gets a monthly AI budget in each product, and each product has a monthly total you don’t want to go over. You can do all of this in one workspace, with one team and one bill.

Limitry has no separate “project” to set up. A product is one more subject, and your action names say which product a check is for.

Prefix each action with the product, so the two never share a limit by accident: writer.ai-call and support.ai-call. Action names are your own text, and a limit matches an action by its exact name (or * for every action). Count in cents, so Limitry charges each call at its price:

import { createClient } from "@limitry/sdk";
const limitry = createClient();
await limitry.limits.create({
name: "Writer AI budget",
subjectKind: "user",
action: "writer.ai-call",
amount: 200,
unit: "cents",
window: "month",
});
await limitry.limits.create({
name: "Support AI budget",
subjectKind: "user",
action: "support.ai-call",
amount: 100,
unit: "cents",
window: "month",
});

A product’s total is a limit on a subject of kind product, with the product’s id. Use * as the action, so it counts every check made for that product. Here the writing assistant may spend $5,000 a month on its AI features:

import { createClient } from "@limitry/sdk";
const limitry = createClient();
await limitry.limits.create({
name: "Writer total",
subjectKind: "product",
subjectId: "writer",
action: "*",
amount: 500000,
unit: "cents",
window: "month",
});

3. Check with the product as a shared subject

Section titled “3. Check with the product as a shared subject”

Name the user as the subject and the product in shared. Limitry allows the call only if the estimate fits the user’s monthly budget and the product’s monthly total, and then charges what the call actually cost to both:

import { createClient } from "@limitry/sdk";
const limitry = createClient(); // reads LIMITRY_API_KEY
const draft = await limitry.hold(
{
subject: { kind: "user", id: user.id },
shared: [{ kind: "product", id: "writer" }],
action: "writer.ai-call",
estimate: 5,
},
async (held) => {
const res = await callModel(prompt);
held.cost(priceCents(res.usage));
return res.text;
},
);

A check has one cost, and Limitry charges it to every limit that applies. Give a product’s total the same unit as the limits under it, here cents, so the numbers add up. priceCents is your own price table, as in Limit AI spend per user of your product.

The product’s total is a limit like any other, so the Usage page shows what each product used this month. Through the API, ask for that limit’s usage:

import { createClient } from "@limitry/sdk";
const limitry = createClient();
const usage = await limitry.usage.query({ limitId: "lim_3f0c…" });

For one user in one product, read the user’s limit for that product’s action, with subjectKind=user&subjectId=….

A workspace holds your team, your bill and your two environments, test and live. Everything below that is data you choose: subject kinds, ids and action names. A product, a region or a feature fits the same pattern as a team pool, so you learn one idea instead of two. One check can then enforce a user’s cap and a product’s total together.

If two products need different people or different bills, give each its own workspace.

Related: Checks, Pools, balances and budgets.