Skip to main content
Glama

AI token cost arbitrage

ai_token_arbitrage
Read-onlyIdempotent

Calculate multi-provider LLM API inference token costs, prompt caching economics (up to 95% discount), batch API savings (50%), and cross-model cost disparity multipliers across frontier and high-efficiency models (Anthropic Claude, OpenAI GPT, Google Gemini, DeepSeek).

Behavior: Deterministic, idempotent calculation with zero external side effects. Models official public provider pricing cards per million input/output tokens. Incorporates prompt cache hit pricing reductions and asynchronous batch API discounts. Evaluates real-time pack age and freshness status (FRESH < 14 days, AGING 14-30 days, STALE > 30 days). Returns comprehensive model cost matrix, cheapest and most expensive model arbitrage analysis, cache savings, and monthly cost projections.

Usage Guidelines: Use when budgeting AI agent inference costs, evaluating LLM providers, or deciding whether to implement prompt caching or batch inference. Do not use for cloud network egress; use cloud_egress_finops instead.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompt_tokens": "<prompt_tokens>",
      "completion_tokens": "<completion_tokens>",
      "as_of_date": "<as_of_date>"
    },
    "name": "ai_token_arbitrage"
  }
}

Input Schema

NameRequiredDescriptionDefault
isBatchNoCamelCase alias for is_batch.
asOfDateNoCamelCase alias for as_of_date.
is_batchNoWhether asynchronous batch processing discount (50%) applies. Alias: isBatch.
as_of_dateYesISO date string (YYYY-MM-DD) for rate-pack historical resolution (e.g. '2026-09-07' for current, '2025-11-15' for 2025-Q4). Alias: asOfDate.
promptTokensNoCamelCase alias for prompt_tokens.
cacheHitRatioNoCamelCase alias for cache_hit_ratio.
prompt_tokensYesNumber of input prompt tokens per API call. Must be a non-negative integer. Alias: promptTokens.
cache_hit_ratioNoProportion of input prompt tokens served from cache (0.0 to 1.0 or 0% to 100%). Default is 0.80 (80%). Alias: cacheHitRatio.
completionTokensNoCamelCase alias for completion_tokens.
completion_tokensYesNumber of generated output completion tokens per API call. Must be a non-negative integer. Alias: completionTokens.

Output Schema

NameRequiredDescriptionDefault
inputsNo
matrixNo
arbitrageNo
freshnessNo
disclaimerNo
rate_pack_idNo
token_distributionNo
statutory_authorityNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changed
    • addedInput schema / properties / completionTokens / minimum
      Added value: +0
    • changedInput schema / properties / completionTokens / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / completion_tokens / minimum
      Added value: +0
    • changedInput schema / properties / completion_tokens / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / promptTokens / minimum
      Added value: +0
    • changedInput schema / properties / promptTokens / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / prompt_tokens / minimum
      Added value: +0
    • changedInput schema / properties / prompt_tokens / type
      Previous value: -"number"New value: +"integer"
  2. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "properties": {
      +    "arbitrage": {
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    },
      +    "disclaimer": {
      +      "type": [
      +        "string",
      +        "number",
      +        "null"
      +      ]
      +    },
      +    "freshness": {
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    },
      +    "inputs": {
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    },
      +    "matrix": {
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    },
      +    "rate_pack_id": {
      +      "type": [
      +        "string",
      +        "number",
      +        "null"
      +      ]
      +    },
      +    "statutory_authority": {
      +      "type": [
      +        "string",
      +        "number",
      +        "null"
      +      ]
      +    },
      +    "token_distribution": {
      +      "type": [
      +        "object",
      +        "null"
      +      ]
      +    }
      +  },
      +  "type": "object"
      +}
  3. Changed1 schema field changed
    • changedInput schema / required
      Previous value: -[
      -  "prompt_tokens",
      -  "completion_tokens"
      -]New value: +[
      +  "prompt_tokens",
      +  "completion_tokens",
      +  "as_of_date"
      +]
  4. Changed2 schema fields changed
    • removedInput schema / properties / completion_tokens / default
      Removed value: -1000
    • removedInput schema / properties / prompt_tokens / default
      Removed value: -5000
  5. Changed15 schema fields changed
    • addedInput schema / properties / asOfDate
      Added value: +{
      +  "description": "CamelCase alias for as_of_date.",
      +  "type": "string"
      +}
    • addedInput schema / properties / as_of_date
      Added value: +{
      +  "description": "ISO date string (YYYY-MM-DD) for rate-pack historical resolution (e.g. '2026-09-07' for current, '2025-11-15' for 2025-Q4). Alias: asOfDate.",
      +  "type": "string"
      +}
    • removedInput schema / properties / cacheHitRatio / default
      Removed value: -0.8
    • changedInput schema / properties / cacheHitRatio / description
      Previous value: -"Proportion of input prompt tokens served from cache (0.0 to 1.0 or 0 to 100%). Default is 0.80 (80%)."New value: +"CamelCase alias for cache_hit_ratio."
    • addedInput schema / properties / cache_hit_ratio
      Added value: +{
      +  "default": 0.8,
      +  "description": "Proportion of input prompt tokens served from cache (0.0 to 1.0 or 0% to 100%). Default is 0.80 (80%). Alias: cacheHitRatio.",
      +  "type": "number"
      +}
    • removedInput schema / properties / completionTokens / default
      Removed value: -1000
    • changedInput schema / properties / completionTokens / description
      Previous value: -"Number of generated output completion tokens per API call. Must be an integer >= 0."New value: +"CamelCase alias for completion_tokens."
    • addedInput schema / properties / completion_tokens
      Added value: +{
      +  "default": 1000,
      +  "description": "Number of generated output completion tokens per API call. Must be a non-negative integer. Alias: completionTokens.",
      +  "type": "number"
      +}
    • removedInput schema / properties / isBatch / default
      Removed value: -false
    • changedInput schema / properties / isBatch / description
      Previous value: -"Whether the 50% asynchronous batch processing discount applies."New value: +"CamelCase alias for is_batch."
    • addedInput schema / properties / is_batch
      Added value: +{
      +  "default": false,
      +  "description": "Whether asynchronous batch processing discount (50%) applies. Alias: isBatch.",
      +  "type": "boolean"
      +}
    • removedInput schema / properties / promptTokens / default
      Removed value: -5000
    • changedInput schema / properties / promptTokens / description
      Previous value: -"Number of input prompt tokens per API call. Must be an integer >= 0."New value: +"CamelCase alias for prompt_tokens."
    • addedInput schema / properties / prompt_tokens
      Added value: +{
      +  "default": 5000,
      +  "description": "Number of input prompt tokens per API call. Must be a non-negative integer. Alias: promptTokens.",
      +  "type": "number"
      +}
    • addedInput schema / required
      Added value: +[
      +  "prompt_tokens",
      +  "completion_tokens"
      +]
  6. Changed4 schema fields changed
    • changedInput schema / properties / cacheHitRatio / description
      Previous value: -"Prompt cache hit ratio (0.0 to 1.0 or 0 to 100%)"New value: +"Proportion of input prompt tokens served from cache (0.0 to 1.0 or 0 to 100%). Default is 0.80 (80%)."
    • changedInput schema / properties / completionTokens / description
      Previous value: -"Output completion token count per API request"New value: +"Number of generated output completion tokens per API call. Must be an integer >= 0."
    • changedInput schema / properties / isBatch / description
      Previous value: -"Whether asynchronous batch API 50% discount applies"New value: +"Whether the 50% asynchronous batch processing discount applies."
    • changedInput schema / properties / promptTokens / description
      Previous value: -"Input prompt token count per API request"New value: +"Number of input prompt tokens per API call. Must be an integer >= 0."
  7. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already cover readOnly, idempotent, non-destructive, and closed-world, so 'deterministic, idempotent calculation with zero external side effects' is largely redundant. What the description genuinely adds beyond structured data is the pricing-data provenance ('official public provider pricing cards per million tokens') and the freshness tier thresholds (FRESH < 14 days, AGING 14-30, STALE > 30), which are behavioral rules an agent could not infer from the annotations.

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?

Three labeled sections (purpose, Behavior, Usage Guidelines) with the core action front-loaded in the first clause, so an agent can stop reading early. There is minor promotional padding ('comprehensive', 'real-time', 'cost disparity multipliers') but no sentence is purely filler; the freshness thresholds and the sibling exclusion both earn their space.

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?

For a read-only calculation tool with full schema coverage and an output schema, the description supplies all the decision-relevant context: cost model, discount mechanics, freshness semantics, and sibling exclusion. Its one small gap is that the return-value recap ('model cost matrix, cheapest and most expensive model arbitrage analysis') is redundant given the output schema, though harmless.

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

Parameters3/5

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

Schema description coverage is 100% and every one of the ten properties (including all CamelCase aliases and defaults) is documented in-schema, so the baseline is 3. The description does add modest meaning by explaining why the batch and cache parameters matter (50% batch discount, up to 95% cache discount, default 0.8 hit ratio), but it does not map these economics to any specific parameter name.

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?

Opens with a specific verb+resource: 'Calculate multi-provider LLM API inference token costs' plus the named sub-features (prompt caching economics, batch savings, cross-model cost disparity multipliers). An agent can distinguish this from any of the 28 siblings on the list, and the explicit model families named (Claude, GPT, Gemini, DeepSeek) further scope it.

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?

Provides explicit when-to-use triggers ('budgeting AI agent inference costs, evaluating LLM providers, or deciding whether to implement prompt caching or batch inference') and an explicit when-not with a named alternative ('Do not use for cloud network egress; use cloud_egress_finops instead'). This is the strongest possible routing signal.

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