Skip to main content
Glama
zhaoyue722

LLM Usage & Cost Tracker

query_spend

Query LLM spending grouped by provider, model, project, tag, or day over a customizable time window, with optional filters to narrow results.

Instructions

Return spending broken down by a chosen axis over a time window.

start and end are ISO-8601 strings (trailing-Z, +00:00, or naive — naive is interpreted as UTC). Default window is the last 30 days. group_by is one of provider | model | project | tag | day. filter AND-combines optional provider/model/project equality predicates.

include_failed defaults to False so failure rows (e.g. streams that died mid-flight with partial counts) are excluded from totals and groups. Pass True to fold them back in — useful for debugging capture-layer behavior, not for honest spend numbers.

Tag semantics: events with NULL/empty tags are excluded from group_by="tag" results entirely; multi-tag events contribute once per tag (so per-group calls sums can exceed the window total). Project semantics are symmetric: NULL projects are dropped from group_by="project". Groups are ordered cost-desc with alphabetical ties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNo
startNo
filterNo
group_byNoprovider
include_failedNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupsYes
total_callsYes
total_cost_usdYes
total_input_tokensYes
total_output_tokensYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Given no annotations, the description fully discloses behavioral traits: tag semantics (NULL exclusion, multi-tag duplication), project semantics, ordering by cost-desc, and include_failed purpose (debugging vs honest spend). No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with front-loaded purpose and detailed parameter explanations. It is slightly long but every sentence adds value. Minor redundancy in tag semantics, but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 5 parameters, 1 enum, and a nested object, the description covers all input semantics comprehensively. An output schema exists but is not shown, so no need to explain return values. Complete for effective tool usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates by explaining each parameter: start/end format and default, group_by enum values, filter predicates, and include_failed meaning. Adds significant meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns spending broken down by a chosen axis over a time window. It specifies the verb "return" and resource "spending" with clear breakdown dimensions, distinguishing it from siblings like compare_providers and usage_summary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides context on default behavior (e.g., 30-day window, include_failed=False) but does not explicitly state when to use this tool versus alternatives like compare_providers or usage_summary. No exclusions or when-not-to-use guidance are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/zhaoyue722/llm-usage-mcp'

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