{"_id":"@binux/llm-cost","name":"@binux/llm-cost","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@binux/llm-cost","version":"1.0.0","description":"💰 Beautiful CLI to count tokens and estimate costs for any LLM model (Claude, GPT, Gemini, Mistral, and 300+ more). Auto-updates prices from OpenRouter.","main":"src/index.js","bin":{"llm-cost":"src/cli.js"},"scripts":{"test":"node --test test/*.test.js","start":"node src/cli.js"},"keywords":["llm","tokens","cost","pricing","calculator","claude","openai","gemini","gpt","anthropic","ai","cli"],"author":"","license":"MIT","dependencies":{},"engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/binux20/llm-cost.git"},"homepage":"https://github.com/binux20/llm-cost#readme","bugs":{"url":"https://github.com/binux20/llm-cost/issues"},"gitHead":"692ac58bf8d3fa99c702608935ea4616d74e9d67","_id":"@binux/llm-cost@1.0.0","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-QdUfhb6ah2N/xB6L0zT9ONd3gHhtRu1efpGkn/Muxfs0jeZh0J13+SvepN5JkdG6vc3nGvLl2+qIcxW1UUvAMA==","shasum":"d02e8fbdef176a3933fe729bb6763f19e2e95ea8","tarball":"https://registry.npmjs.org/@binux/llm-cost/-/llm-cost-1.0.0.tgz","fileCount":13,"unpackedSize":78068,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDoZGnss0KoMlLlI2Qto2p3iYViZM/LtrRUDsLDKJ0MJAIhANyth65y/xbkzTK/+rtguwWDy3nrrMFL/9uqbAufkHTY"}]},"_npmUser":{"name":"binux","email":"binuxsuper@gmail.com"},"directories":{},"maintainers":[{"name":"binux","email":"binuxsuper@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/llm-cost_1.0.0_1773848664054_0.7896221811252029"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-18T15:44:23.977Z","1.0.0":"2026-03-18T15:44:24.221Z","modified":"2026-03-18T15:44:24.405Z"},"maintainers":[{"name":"binux","email":"binuxsuper@gmail.com"}],"description":"💰 Beautiful CLI to count tokens and estimate costs for any LLM model (Claude, GPT, Gemini, Mistral, and 300+ more). Auto-updates prices from OpenRouter.","homepage":"https://github.com/binux20/llm-cost#readme","keywords":["llm","tokens","cost","pricing","calculator","claude","openai","gemini","gpt","anthropic","ai","cli"],"repository":{"type":"git","url":"git+https://github.com/binux20/llm-cost.git"},"bugs":{"url":"https://github.com/binux20/llm-cost/issues"},"license":"MIT","readme":"# llm-cost 💰\n\n> Count tokens and estimate costs for **any LLM model** — right in your terminal.\n\n[![npm version](https://img.shields.io/npm/v/llm-cost.svg)](https://www.npmjs.com/package/llm-cost)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](#)\n\n**300+ models · Auto-updated prices · Zero dependencies · Beautiful CLI**\n\n---\n\n## ✨ Features\n\n- 🔢 **Accurate token counting** — BPE-approximation, ~95% accuracy\n- 💵 **Real-time pricing** — auto-fetches latest prices from OpenRouter on every run\n- 🏆 **Live Benchmarks** — pulls daily ELO ratings directly from LMSYS Chatbot Arena\n- 📊 **Model Recommendations** — smart match by category (code, chat, agents) and cost efficiency\n- 🎨 **Beautiful interactive UI** — colorized TUI with budget calculator and filtering\n- 📦 **Zero dependencies** — pure Node.js, nothing to install\n- 🔌 **Pipe-friendly** — works with `cat`, `echo`, stdin\n- 📚 **Library API** — use programmatically in your own projects\n\n### Supported Providers\n\n| Provider | Models |\n|----------|--------|\n| **Anthropic** | Claude Opus 4.5, Sonnet 4.5, Haiku 4.5, 3.7 Sonnet, 3.5 Sonnet/Haiku, 3 Opus |\n| **OpenAI** | GPT-4.1, GPT-4.1 Mini/Nano, GPT-4o, GPT-4o Mini, o3, o4-mini |\n| **Google** | Gemini 2.5 Pro/Flash/Flash-Lite, 2.0 Flash |\n| **Meta** | Llama 3.3 70B, 3.1 405B, 3.1 8B |\n| **Mistral** | Mistral Large, Small, Codestral |\n| **xAI** | Grok 3, Grok 3 Mini |\n| **DeepSeek** | DeepSeek R1, Chat V3 |\n| **Cohere** | Command R+, Command R |\n| + 300 more via auto-update from OpenRouter |\n\n---\n\n## 🚀 Install\n\n```bash\nnpm install -g llm-cost\n```\n\nOr use without installing:\n\n```bash\nnpx llm-cost\n```\n\nRequires **Node.js 18+**.\n\n---\n\n## 📖 Usage\n\n### Interactive Mode (default)\n\nJust run `llm-cost` with no arguments — perfect for beginners:\n\n```bash\nllm-cost\n```\n\nIt will:\n1. Show a welcome screen with model count\n2. Let you type/paste your prompt\n3. Count tokens in real time\n4. Ask for expected output length\n5. Show a filterable comparison table\n\n### Quick Mode\n\n```bash\n# Count tokens and show costs for top models\nllm-cost \"Explain quantum computing in simple terms\"\n\n# Specific model\nllm-cost \"Hello world\" -m claude-haiku\n\n# Full comparison across ALL models\nllm-cost \"Write a 1000-word essay about AI\" --compare\n\n# Set expected output tokens\nllm-cost \"Translate this article\" -o 2000\n```\n\n### Pipe Mode\n\n```bash\n# From a file\ncat my-prompt.txt | llm-cost\n\n# From echo\necho \"Hello, how are you?\" | llm-cost\n\n# From clipboard (macOS)\npbpaste | llm-cost\n```\n\n### List Models\n\n```bash\n# All models with prices\nllm-cost --list\n\n# Filter by provider\nllm-cost --list anthropic\nllm-cost --list openai\nllm-cost --list google\n```\n\n---\n\n## 📦 Programmatic API\n\n```javascript\nconst { countTokens, getModels, estimateCost, estimateAll } = require('llm-cost');\n\n// Count tokens\nconst tokens = countTokens('Hello, world!');\nconsole.log(tokens); // ~4\n\n// Get all models (auto-fetches latest prices)\nconst models = await getModels();\n\n// Estimate cost for one model\nconst cost = estimateCost({\n  inputTokens: 1000,\n  outputTokens: 500,\n  model: models[0],\n});\nconsole.log(cost); // { inputCost, outputCost, totalCost }\n\n// Compare all models at once\nconst { results } = await estimateAll({\n  text: 'Your prompt here',\n  outputTokens: 500,\n});\n// results sorted cheapest-first\n```\n\n---\n\n## 🔄 Auto-Update\n\nPrices are automatically fetched from [OpenRouter's](https://openrouter.ai) public API on every run and cached for 1 hour. If you're offline, built-in fallback prices are used.\n\nNo API key required. No account needed.\n\n---\n\n## 🛠 CLI Reference\n\n| Option | Description |\n|--------|-------------|\n| *(no args)* | Interactive mode |\n| `\"text\"` | Quick calc for top models |\n| `-m, --model <name>` | Calculate for a specific model (partial name OK) |\n| `-o, --output <n>` | Expected output tokens (default: auto) |\n| `-c, --compare` | Compare ALL models |\n| `-l, --list [provider]` | List models with prices |\n| `-h, --help` | Show help |\n| `-v, --version` | Show version |\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to:\n- Add new model providers\n- Improve token counting accuracy\n- Suggest UI improvements\n\n```bash\ngit clone https://github.com/YOUR_USERNAME/llm-cost.git\ncd llm-cost\nnpm test\n```\n\n---\n\n## 📄 License\n\n[MIT](LICENSE) — use it however you want.\n\n---\n\n<p align=\"center\">\n  <b>Built with ❤️ and Claude</b><br>\n  <sub>This project was created as part of the <a href=\"https://claude.com/contact-sales/claude-for-oss\">Claude for Open Source</a> initiative.</sub>\n</p>\n","readmeFilename":"README.md","_rev":"1-5e19cf142953e4e84d768cd4712c5c8f"}