Estimar costo de tokens de LLM
llm-cost-estimateEstima 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]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calls | No | Number of identical calls (integer; optional; default 1; min 1; max 1000000000). | |
| input_text | No | Text to estimate input tokens from (string; optional). | |
| input_tokens | No | Input tokens (integer; optional; min 0; max 1000000000000). | |
| output_tokens | No | Output tokens (integer; optional; default 0; min 0; max 1000000000000). | |
| cached_input_tokens | No | Of the input, tokens billed at cache price (integer; optional; default 0; min 0; max 1000000000000). | |
| price_input_per_mtok | Yes | USD per 1M input tokens (number; required; min 0; max 10000). | |
| price_cached_per_mtok | No | USD per 1M cached input tokens (number; optional; default 0; min 0; max 10000). | |
| price_output_per_mtok | Yes | USD per 1M output tokens (number; required; min 0; max 10000). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calls | No | ||
| total_usd | No | ||
| input_tokens | No | ||
| output_tokens | No | ||
| estimated_input | No | ||
| cost_per_call_usd | No |