Blog · March 9, 2026

Announcing ai-cost-calc: AI Cost Calculator SDK

Today we are launching ai-cost-calc, a free AI cost calculator SDK for JavaScript/TypeScript and Python. It helps developers calculate model costs with daily pricing updates and benchmark-aware model data.

This release is also part of our distribution strategy for MarginDash: ship useful open source tooling first, help developers solve real cost problems quickly, and earn product visibility through adoption.

Why We Built This AI Cost Calculator

The original problem was simple: teams were hardcoding model prices into scripts and spreadsheets, then discovering those numbers were stale weeks later. AI pricing moves quickly, and static tables drift.

ai-cost-calc solves this by giving developers a clean SDK surface backed by a daily-refreshed pricing dataset, so cost calculations remain current without maintaining custom pricing infrastructure.

What You Get

Daily Price Updates

Pricing data refreshes daily so your AI cost calculator does not lag vendor changes.

Benchmark-Aware Data

Variant metrics include intelligence_index, coding_index, and agentic_index.

Simple SDK API

Pass model name plus token counts and get cost + model metadata back.

Quick Start

TypeScript / JavaScript
AiCostCalc SDK Your code
npm install ai-cost-calc

import { AiCostCalc } from "ai-cost-calc";

const calc = new AiCostCalc();
const result = await calc.cost("openai/gpt-5", 5000, 1200);

console.log(result.totalCost);
Python
AiCostCalc SDK Your code
pip install ai-cost-calc

from ai_cost_calc import AiCostCalc

calc = AiCostCalc()
result = calc.cost(
    "openai/gpt-5",
    input_tokens=5000,
    output_tokens=1200
)

print(result.total_cost)

Why Benchmark Metrics Matter in an AI Cost Calculator

Cost-only routing misses quality tradeoffs. A cheaper model can still be the wrong choice for critical tasks.

That is why each variant includes benchmark signals for reasoning, coding, and agentic behavior. The SDK gives cost data plus directional capability context to support better routing decisions.

  • intelligence_index: broad reasoning capability signal.
  • coding_index: software engineering and code-generation signal.
  • agentic_index: multi-step, tool-using task signal.

FAQ

What is ai-cost-calc?
ai-cost-calc is a free open source AI cost calculator SDK for JavaScript/TypeScript and Python. It calculates API cost from model name plus token usage, so developers can add cost visibility in minutes instead of maintaining pricing tables manually.
Why is this AI cost calculator different from static calculators?
Most calculators ship a static price table that drifts out of date as vendors change model pricing. ai-cost-calc uses a pricing database that updates daily, so cost calculations stay aligned with current model rates.
Which benchmark metrics are included?
ai-cost-calc includes three benchmark metrics at the model variant level: intelligence_index, coding_index, and agentic_index. These help teams compare not just cost, but cost relative to capability.
Can I use ai-cost-calc without using MarginDash?
Yes. The SDK is free and open source, and you can use it as a standalone AI cost calculator in your own application. MarginDash is optional if you want hosted dashboards, per-customer margin tracking, Stripe reconciliation, and budget alerts.
Which languages are supported at launch?
At launch, ai-cost-calc supports JavaScript/TypeScript and Python. Install with npm or pip and send model name plus token counts to calculate cost.

Build With the SDK, Scale With MarginDash

Start free with ai-cost-calc. Add hosted margin analytics when you need customer-level unit economics.

See My Margin Data

No credit card required