LLM Cost Calculator

Estimate prompt and completion costs using reference prices for supported models. Returns token estimates, costs and cheaper options.

Pay by wallet (x402) llm-cost-calculate

Example

Example answer
{
  "model": "gpt-4o",
  "cost_usd": 0.000027,
  "input_tokens": 11,
  "total_tokens": 11,
  "model_pricing": {
    "input_per_1k": 0.0025,
    "output_per_1k": 0.01
  },
  "output_tokens": 0,
  "context_window": 128000,
  "cheaper_alternatives": [
    {
      "model": "gemini-1.5-flash",
      "cost_usd": 0.000001,
      "context_window": 1000000,
      "savings_percent": 97
    },
    {
      "model": "gpt-4o-mini",
      "cost_usd": 0.000002,
      "context_window": 128000,
      "savings_percent": 94
    },
    {
      "model": "claude-3-haiku",
      "cost_usd": 0.000003,
      "context_window": 200000,
      "savings_percent": 90
    },
    {
      "model": "gpt-3.5-turbo",
      "cost_usd": 0.000006,
      "context_window": 16385,
      "savings_percent": 80
    },
    {
      "model": "llama-3-70b",
      "cost_usd": 0.000006,
      "context_window": 8192,
      "savings_percent": 76
    }
  ]
}

Inputs

FieldTypeRequiredWhat it is
modelstringYes—
prompt_textstringNo—
prompt_tokensintegerNo—
completion_textstringNo—
completion_tokensintegerNo—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
cost_usdnumberAlways (present in every successful answer)
input_tokensintegerAlways (present in every successful answer)
output_tokensintegerAlways (present in every successful answer)
cheaper_alternativesarrayAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "llm-cost-calculate",
    "inputs": {
      "model": "gpt-4o",
      "prompt_text": "Write a function to validate email addresses"
    },
    "max_price_cents": 2
  }'

Limitations

  • New models and price changes may be missing

    Prices come from a stored reference table. New models or recent price changes may be missing.

    What to do instead: Check the provider's current pricing page for models showing unexpected costs, especially after major releases