API & MCP
Everything a person can do on LLM Cost Explorer, a program or AI agent can do with the same inputs and get the identical result.
HTTP API
POST https://llmcostexplorer.usefulweb.site/api/v1/calculate– run LLM Cost ExplorerGET https://llmcostexplorer.usefulweb.site/api/v1/tool– inputs, output schema, examples- OpenAPI 3.1: /openapi.json · /openapi.yaml
- Errors:
application/problem+json;422includes per-fielderrors.
LLM Cost Explorer
Calculates what an LLM workload costs per request and per month on each model – requests per day, input and output tokens, the share of the prompt that can be cached, cache hit rate and batch discounts – using live prices from OpenRouter's public models API, a pasted copy of it, or prices you enter. Shows caching and batch savings, the cheapest models that fit your context and budget, and a cost comparison chart.
| Field | Type | Default | Description |
|---|---|---|---|
priceSource | select (manual, openrouter, paste) | "manual" | Prices from |
prices | table | — | Model prices (USD per 1M tokens) |
modelIds | list | — | OpenRouter model ids. e.g. openai/gpt-4o-mini – one per line. Empty in paste mode = all pasted models. |
modelsJson | textarea | — | OpenRouter models JSON |
requestsPerDay (required) | number | 1000 | Requests per day |
inputTokens (required) | integer | 2000 | Input tokens per request |
outputTokens (required) | integer | 500 | Output tokens per request |
cacheablePct | number | 0 | Cacheable prompt prefix. Share of input tokens that repeat across requests (system prompt, tools, documents). |
cacheHitRate | number | 80 | Cache hit rate |
batchSharePct | number | 0 | Share of requests sent via batch API |
batchDiscountPct | number | 50 | Batch discount |
daysPerMonth | number | 30.4 | Days per month |
budget | number | — | Monthly budget (optional) |
Example request
Support bot: 5,000 requests/day, cached system prompt (example prices you entered)
curl -X POST https://llmcostexplorer.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"priceSource":"manual","prices":[{"model":"Large model (example)","inputPerM":3,"outputPerM":15,"cacheReadPerM":0.3,"cacheWritePerM":3.75,"contextTokens":200000},{"model":"Mid model (example)","inputPerM":0.4,"outputPerM":1.6,"cacheReadPerM":0.1,"contextTokens":1000000},{"model":"Small model (example)","inputPerM":0.1,"outputPerM":0.4,"contextTokens":8000}],"requestsPerDay":5000,"inputTokens":12000,"outputTokens":400,"cacheablePct":75,"cacheHitRate":90,"budget":2000}'
Every result contains
inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.
MCP (Model Context Protocol)
- Streamable HTTP endpoint:
https://llmcostexplorer.usefulweb.site/mcp– protocol revisions 2026-07-28 (stateless) and 2025-11-25 / 2025-06-18 / 2025-03-26 (initialize handshake). - Tools:
llm_cost_explorer - Local stdio connector:
node src/mcp-stdio.ts --tool=llm-cost-explorer
{
"mcpServers": {
"llm-cost-explorer": { "type": "http", "url": "https://llmcostexplorer.usefulweb.site/mcp" }
}
}