Skip to main content
Glama

AI API cost

ai_api_cost
Read-onlyIdempotent

Estimate USD cost per request, day, and month from token counts, caching, and batch discounts for API workload budgeting.

Instructions

Estimate USD per request, day and month from token counts, caching and published batch discounts. Use for an API workload budget, not chat subscriptions. Model IDs use providerId/id from the bundled src/data/pricing-snapshot.json catalog. Rates are from the dated catalog snapshot returned with the result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelIdsYes
inputTokensYes
outputTokensYes
batchModelIdsNoOptional model IDs using a published batch discount.
requestsPerDayYes
requestsPerMonthYes
cachedInputTokensYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolYes
inputYes
unitsYes
methodYes
estimatesYes
provenanceYes
assumptionsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, so the safety profile is covered. The description adds genuinely useful context beyond that: model IDs must be 'providerId/id' from a bundled catalog, rates come from a dated snapshot, and that snapshot is returned with the result. It does not discuss how caching or batch discounts are applied (e.g., whether cached tokens overlap inputTokens), leaving one behavioral gap.

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?

Three tight sentences, front-loaded with the purpose, followed by routing guidance and then the model-ID format constraint. No redundancy with the title, which merely restates the name.

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?

An output schema exists, so return values need not be explained, and annotations carry the safety profile. The description covers provenance, ID format, and scope. The one residual gap is the relationship between cachedInputTokens and inputTokens, which an agent must guess.

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 description coverage is only 14%, so the description must compensate, and it does for the highest-risk parameter: the required format for modelIds. It also signals the meaning of the caching and batch-discount inputs. The requests-per-day/month and token parameters are only implied rather than explained, so compensation is partial but meaningful.

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 a specific verb and output ('Estimate USD per request, day and month') plus the inputs it derives them from, so the tool's function is unambiguous. It also explicitly distinguishes itself from the domain of its sibling ai_subscription_stack_cost, which an agent could otherwise conflate with a generic AI-cost tool.

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

Usage Guidelines5/5

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

It gives both a positive condition ('Use for an API workload budget') and an explicit exclusion ('not chat subscriptions'), which is exactly the routing decision that separates this tool from ai_subscription_stack_cost. The only minor omission is naming the sibling outright, but the exclusion is functionally sufficient.

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