Skip to main content
Glama

Cost from token usage

cost_from_usage

Calculate the USD cost of AI model token usage, including input, output, and cached tokens, using historical or current prices.

Instructions

Value a token rollup in USD at a point in time, using the shared cache multipliers (cache read 0.1x input, cache write 1.25x for 5m / 2x for 1h). tokens accepts input, output, cache_read, cache_write_5m, cache_write_1h. Defaults to today if no date is given.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel id or alias to price the usage against.
tokensYesToken counts to value. All fields optional and non-negative; missing fields count as 0.
dateNoOptional date (YYYY-MM-DD). Omit for today.
providerNoOptional provider slug to disambiguate a bare id.
Behavior3/5

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

With no annotations, the description discloses cache multipliers and date defaults. However, it does not mention potential rate limits, caching behavior, or whether the tool is read-only. The 'shared cache multipliers' hint at internal state but are not fully explained.

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

Conciseness5/5

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

The description is two sentences with no wasted words. The key purpose is front-loaded, followed by essential details about token fields and date default.

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

Completeness4/5

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

Given the nested tokens object and absence of output schema, the description covers token field meaning and date defaults. It could mention the return value format (e.g., a number in USD), but the function name makes it clear.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3. The description adds value by listing the specific token fields (input, output, cache_read, etc.) and explaining cache multipliers, which goes beyond the schema's property descriptions.

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 states 'Value a token rollup in USD at a point in time', which is a specific verb and resource. It distinguishes from sibling tools like 'current_price' (which likely prices a single token) and 'price_on' (which may fetch historical prices) by focusing on token rollup valuation with cache multipliers.

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 implies when to use the tool (when you have token counts to value) but does not explicitly guide when not to use it or contrast with siblings. It mentions defaults but lacks exclusion criteria.

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/RoninForge/ai-price-index-mcp'

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