Skip to main content
Glama
README.md
![llm-infra-calc banner](assets/banner.png)

# llm-infra-calc

**Open LLM pricing/GPU registry, zero-dependency CLI, and MCP server for VRAM + KV-cache sizing, cloud API vs. self-hosted break-even, and PostgreSQL `pgvector` HNSW RAM estimation.**

Back-of-the-envelope math is built on transparent JSON presets in [`data/`](data/) so your terminal, coding agents, and PRs stay in sync with real hardware and frontier API pricing.

---

## Quick CLI Usage (Zero Install)

```bash
# 1. Size GPU + VRAM including KV-cache concurrency & Ollama vs. vLLM guidance
npx github:adamblansett/llm-infra-calc vram --model qwen-3-32b --quant q4_k_m --context 16384 --concurrency 12

# 2. Compare frontier API spend (with prompt caching) vs. dedicated GPU rent
npx github:adamblansett/llm-infra-calc api-cost --model claude-sonnet-4-5 --reqs 10000 --in 3000 --out 400 --cache 60

# 3. Estimate RAG chunks, pgvector HNSW RAM residency, and managed vector DB hosting
npx github:adamblansett/llm-infra-calc rag --docs 10000 --pages 10 --dims 1536 --queries 500000

# 4. List all supported models, quantizations, and GPU tiers
npx github:adamblansett/llm-infra-calc list
```

---

## Use as an MCP Server (Claude Code, Cursor, Codex)

```json
{
  "mcpServers": {
    "llm-infra-calc": {
      "command": "npx",
      "args": ["-y", "--package=github:adamblansett/llm-infra-calc", "llm-infra-calc-mcp"]
    }
  }
}
```

### Exposed MCP Tools

| Tool | What It Calculates |
| :--- | :--- |
| **`size_llm_gpu`** | Model weights + KV-cache under concurrent streams + CUDA overhead, GPU tier selection, payback months, Ollama vs. vLLM threshold |
| **`compare_api_vs_self_hosted`** | Monthly API cost with prompt cache hit rates (`Claude Sonnet/Haiku 4.5`, `GPT-5/mini`, `Gemini 2.5 Pro/Flash`, `DeepSeek V3.2`) + daily break-even volume |
| **`estimate_rag_pgvector`** | Total chunks, raw float32 size, `pgvector` HNSW RAM (`~1.65x`), ingestion embedding spend, and pgvector vs. managed vector DB hosting |
| **`list_llm_registry`** | Returns all open JSON presets (`data/models-api.json`, `data/models-open.json`, `data/gpus.json`) |

---

## Interactive Web Calculators & Architecture Help

- **LLM GPU & VRAM Sizer:** [adamblansett.com/tools/llm-gpu-calculator](https://adamblansett.com/tools/llm-gpu-calculator/)
- **AI Token & GPU Break-Even:** [adamblansett.com/tools/ai-cost-calculator](https://adamblansett.com/tools/ai-cost-calculator/)
- **RAG & pgvector Cost Estimator:** [adamblansett.com/tools/rag-cost-calculator](https://adamblansett.com/tools/rag-cost-calculator/)
- **Need private VPC LLM deployment or 48-Hour Audit?** [adamblansett.com/audit](https://adamblansett.com/audit/)

Community PRs adding new open-weight models, GPU pricing tiers, or API updates in [`data/`](data/) are welcome—see [CONTRIBUTING.md](CONTRIBUTING.md).

MIT © 2026 [Adam Blansett](https://adamblansett.com)