Skip to main content
Glama

Estimar costo de tokens de LLM

llm-cost-estimate
Read-onlyIdempotent

Estima el costo de llamadas a un LLM a partir de tokens (o texto estimado) y precios por millón indicados; sin lista de precios incorporada. Cuándo: un flujo de agente necesita un resultado exacto y repetible para un paso auxiliar (tokens, costos, reintentos, fragmentos, ranking, limpieza de JSON). No para: estimar el costo de un lote de llamadas pagadas por uso (x402-cost-estimate). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Estimates LLM request cost from input/output token counts (or text, estimated heuristically) and supplied per-million-token prices, with optional cached-input pricing and call volume. No built-in price list. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). [EN completo / full EN: inputSchema.description]

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "calls": 100,
      "input_tokens": 10000,
      "output_tokens": 2000,
      "price_input_per_mtok": 3,
      "price_output_per_mtok": 15
    },
    "name": "llm-cost-estimate"
  }
}

Input Schema

NameRequiredDescriptionDefault
callsNoNumber of identical calls (integer; optional; default 1; min 1; max 1000000000).
input_textNoText to estimate input tokens from (string; optional).
input_tokensNoInput tokens (integer; optional; min 0; max 1000000000000).
output_tokensNoOutput tokens (integer; optional; default 0; min 0; max 1000000000000).
cached_input_tokensNoOf the input, tokens billed at cache price (integer; optional; default 0; min 0; max 1000000000000).
price_input_per_mtokYesUSD per 1M input tokens (number; required; min 0; max 10000).
price_cached_per_mtokNoUSD per 1M cached input tokens (number; optional; default 0; min 0; max 10000).
price_output_per_mtokYesUSD per 1M output tokens (number; required; min 0; max 10000).

Output Schema

NameRequiredDescriptionDefault
callsNo
total_usdNo
input_tokensNo
output_tokensNo
estimated_inputNo
cost_per_call_usdNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "calls": 100,
      +    "input_tokens": 10000,
      +    "output_tokens": 2000,
      +    "price_input_per_mtok": 3,
      +    "price_output_per_mtok": 15
      +  }
      +]
  2. Changed2 schema fields changed
    • addedInput schema / properties / price_input_per_mtok / examples
      Added value: +[
      +  3
      +]
    • addedInput schema / properties / price_output_per_mtok / examples
      Added value: +[
      +  15
      +]
  3. Changed1 schema field changed
    • addedInput schema / description
      Added value: +"EN: Estimates LLM request cost from input/output token counts (or text, estimated heuristically) and supplied per-million-token prices, with optional cached-input pricing and call volume. No built-in price list. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). Not for: estimating the cost of a batch of pay-per-call API requests (x402-cost-estimate). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB."
  4. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Adds genuinely new behavior beyond the annotations: no built-in price list, deterministic output, no network or stored state, and hard limits (64 KB JSON input, 1 s per call, 1 MB result). It partially restates what readOnlyHint/idempotentHint/openWorldHint already declare ('solo lectura, sin red, sin estado guardado'), which keeps it from a 5, but the limit and no-price-list facts are real added value.

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

Conciseness3/5

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

The content is front-loaded and logically ordered (purpose, when, not-for, effects, determinism, limits), but it is duplicated almost verbatim in Spanish and English and ends with a meta-pointer to 'inputSchema.description' that carries no information for the caller. The duplication roughly doubles length without adding decision-relevant content.

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?

For an 8-parameter, non-destructive, deterministic calculator with an output schema and full schema coverage, nothing an agent needs to call it correctly is missing: cost model, required vs optional inputs, exclusions, limits, and side-effect profile are all present. Return-value details are correctly left to the output schema.

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 100%, so the baseline is 3, but the description adds meaning beyond the schema by explaining that text input yields a heuristic token estimate and that cached-input pricing and call volume are optional modifiers. That clarifies how input_text and cached_input_tokens interact with the required price parameters rather than merely listing them.

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?

States a specific verb and resource (estimate LLM call cost from token counts or text plus supplied per-million prices) and immediately scopes it with 'sin lista de precios incorporada', which prevents the agent from expecting a built-in pricing table. It also names the sibling it is not (x402-cost-estimate) so it can be distinguished without opening schemas.

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?

Uses explicit 'Cuándo:' and 'No para:' sections: use it when an agent loop needs an exact, repeatable bookkeeping result; do not use it for pay-per-call batch costing, where x402-cost-estimate is named as the alternative. Both the positive trigger and the exclusion are stated, not implied.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources