Skip to Content
MindedDocsGet started

Usage

Prompts sent with a key spend usage like any chat in Minded.

Read where you stand with read_usage.

read_usage

Needs Usage: Read only. It is a read, so it runs without asking you.

Input
chatIdtext, optionalA chat to read the spend of
Returns
usageLeftMicroUsdUsage left
daysThe stretch the spend below covers: the last 30 days
ownSpentMicroUsdWhat you spent in those days
orgSpentMicroUsdWhat the whole organization spent in those days. Only for a key made by an Admin; null for any other
chatSpentMicroUsdWhat the chat spent, when you passed chatId; else null

Amounts are in millionths of a dollar: divide by 1,000,000 for dollars. They are the same numbers the Usage page shows the key's maker.

const result = await minded.callTool({ name: 'read_usage', arguments: { chatId } });
const usage = JSON.parse(result.content[0].text);
const dollars = (micro) => (micro / 1_000_000).toFixed(2);
console.log(`This chat: $${dollars(usage.chatSpentMicroUsd)}. Last 30 days: $${dollars(usage.ownSpentMicroUsd)}. Left: $${dollars(usage.usageLeftMicroUsd)}.`);

Over HTTP, the same read is GET /usage, with chatId as an optional query (Prompts and replies).

What counts

  • A chat started with a key counts on the Usage page under Chats, like any chat.
  • A key never sees more than its maker's role does. A key made by a member who is not an Admin gets orgSpentMicroUsd: null.
  • Runs that an agent's code starts spend usage too (Agent code).

When no usage is left

send_prompt is refused with a link to Billing, and no chat is made. Add usage in Billing (or ask an Admin to), then send the prompt again (Errors).