Skip to main content
Glama

spend

Analyze API usage costs by capability and provider, showing total spend, execution counts, and cost averages for specified periods.

Instructions

Get your spend breakdown by capability and provider. Shows total spend, execution count, and cost averages. Defaults to current month.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNoPeriod (YYYY-MM). Defaults to current month.

Implementation Reference

  • The handleSpend function, which takes SpendInput and an API client to fetch the spend breakdown.
    export async function handleSpend(
      input: SpendInput,
      client: RhumbApiClient
    ): Promise<SpendOutput> {
      const result = await client.getSpend(input.period);
      return result as unknown as SpendOutput;
    }
  • The MCP tool 'spend' registration, which calls handleSpend to process the request.
    // -- spend ------------------------------------------------------------
    server.tool(
      "spend",
      "Get your spending breakdown for a billing period: total USD spent, call count, average cost per call, broken down by Capability and by provider. Use to audit costs or optimize routing.",
      {
        period: z.string().optional().describe(SpendInputSchema.properties.period.description)
      },
      async ({ period }) => {
        const result = await handleSpend({ period }, client);
        return {
          content: [{ type: "text" as const, text: JSON.stringify(result) }]
        };
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/supertrained/rhumb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server