LLM Margin Lab LLM Margin Lab, an open-source interactive calculator for the unit economics of AI features, lets developers model token costs, retries, prompt caching, model routing, infrastructure, support, and target gross margin in a shareable scenario that runs locally without an API key. The tool, requiring Node.js 20.9 or newer, calculates revenue and contribution profit per active user, maximum requests per user at a target margin, and margin sensitivity as usage grows, with all assumptions encoded in a URL for sharing. An interactive calculator for the unit economics of AI features. Most AI products can quote token prices. Fewer can answer the question that matters: how much usage can each customer consume before the business model breaks? LLM Margin Lab combines pricing, tokens, retries, prompt caching, model routing, infrastructure, support, and target gross margin in one shareable scenario. It runs locally and does not require an API key. - Revenue and contribution profit per active user - Input and output token costs - Retry amplification - Prompt cache hit rate and cache discounts - Routing a percentage of work to a cheaper model - Infrastructure and support costs - Maximum requests per user at a target margin - Margin sensitivity as usage grows The included presets are illustrative. Replace them with current model prices and the operating costs of your own stack. Requires Node.js 20.9 or newer. npm install npm run dev Open http://localhost:3000 http://localhost:3000 . Use Copy scenario to put every assumption in the URL. The recipient can edit the scenario without an account or backend. No prompt text, customer data, or proprietary model configuration is included unless you type it into a numeric field, which the app does not provide. The calculator works without analytics. If you set TELEMETRY API KEY , copied scenario links emit one aggregate event through the server route using Telemetry https://telemetry.sh/?utm source=github&utm medium=referral&utm campaign=llm-margin-lab&utm content=readme . The event contains only the selected preset plus broad margin and spend bands; it does not contain prices, token counts, URLs, IP addresses, or scenario values. cp .env.example .env.local Add your Telemetry API key, then restart the dev server. npm run typecheck npm test npm run build MIT