Skip to main content

Estimate real-world AI + cloud infrastructure costs for LLM applications

Project description

๐Ÿš€ AI Infra Cost Estimator

Estimate real-world AI + cloud costs before scaling breaks you.

Python 3.9+ License: MIT


๐ŸŽฏ Problem

Most AI startups underestimate costs because LLM usage, concurrency, and infrastructure scaling are tightly coupled.

A small growth in requests can cause non-linear cost jumps that catch founders off guard.

This tool estimates:

  • ๐Ÿ’ฐ LLM API costs (tokens, caching impact)
  • ๐Ÿ–ฅ๏ธ Infrastructure costs (compute, pods, scaling)
  • ๐Ÿ“ˆ Scaling thresholds (when costs jump)
  • ๐Ÿ’ก Optimization recommendations

Before you deploy.


โœจ Features

  • Multi-model support: OpenAI, Anthropic, Google, Meta, Mistral
  • Infrastructure estimation: Pod/container scaling calculations
  • Caching analysis: See how caching affects your costs
  • Scaling breakpoints: Know when you'll need more resources
  • Cost projections: See costs at 1.5x, 2x, 3x, 5x growth
  • Optimization recommendations: Actionable cost-saving suggestions
  • Multiple output formats: Markdown reports & JSON for automation

๐Ÿ“Š Example Output

### Monthly Cost Summary

LLM Cost:     $1,820
Infra Cost:   $640
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Total:        $2,460

Cost per Request: $0.0082
Yearly Estimate:  $29,520

### Scaling Alerts
- At 18,000 req/day โ†’ scale to 2 pods
- At 45,000 req/day โ†’ cost doubles to $4,920/month

### Recommendations
1. ๐ŸŸ  Improve cache hit ratio to 40%
   Potential Savings: $520/month
   
2. ๐ŸŸก Consider switching to gpt-3.5-turbo
   Potential Savings: $890/month

๐Ÿš€ Quick Start

Installation

Option 1: Install via pip (Recommended)

pip install ai-infra-cost-estimator

Option 2: Install from source

# Clone the repository
git clone https://github.com/MindTheInfraAI/AI_Infra_Cost_Estimator.git
cd AI_Infra_Cost_Estimator

# Install the package
pip install -e .

Basic Usage

# Run with a config file
ai-cost-estimator run config.yaml

# Output as JSON
ai-cost-estimator run config.yaml --format json

# Save report to file
ai-cost-estimator run config.yaml --output report.md

Create Your Configuration

# Generate sample config
ai-cost-estimator init my-config.yaml

Edit my-config.yaml:

requests_per_day: 10000
avg_input_tokens: 800
avg_output_tokens: 400
model: gpt-4o-mini
region: us-east-1
cache_hit_ratio: 0.2
concurrency_limit: 50

๐Ÿ“– CLI Commands

Command Description
run <config> Run cost estimation
run <config> --format json Output as JSON
run <config> -o report.md Save to file
list-models Show available LLM models
list-regions Show available cloud regions
list-instances Show available instance types
compare <config> Compare costs across all models
init [filename] Create sample configuration

Examples

# List all supported models with pricing
ai-cost-estimator list-models

# Compare your workload across all models
ai-cost-estimator compare examples/startup.yaml

# Use a specific example config
ai-cost-estimator run examples/enterprise.yaml

๐Ÿ“ Configuration Reference

# Required Parameters
requests_per_day: 10000      # Daily API request volume
avg_input_tokens: 800        # Average tokens per input/prompt
avg_output_tokens: 400       # Average tokens per response
model: gpt-4o-mini           # LLM model name

# Optional Parameters (with defaults)
region: us-east-1            # Cloud region
cache_hit_ratio: 0.0         # Cache effectiveness (0.0 - 1.0)
concurrency_limit: 50        # Max concurrent requests per pod
avg_latency_ms: 500          # Average request latency
headroom_percent: 20.0       # Extra capacity buffer
instance_type: auto          # small, medium, large, xlarge, gpu_t4, gpu_a100

๐Ÿค– Supported Models

โš ๏ธ Important Disclaimer: The pricing shown below are estimated values for reference purposes only. Actual costs may vary based on provider pricing changes, volume discounts, and regional variations. Please verify current pricing from the official provider documentation before making business decisions.

Model Provider Input/1K Output/1K
gpt-4o OpenAI $0.0025 $0.01
gpt-4o-mini OpenAI $0.00015 $0.0006
gpt-4-turbo OpenAI $0.01 $0.03
gpt-3.5-turbo OpenAI $0.0005 $0.0015
claude-3-5-sonnet Anthropic $0.003 $0.015
claude-3-opus Anthropic $0.015 $0.075
claude-3-haiku Anthropic $0.00025 $0.00125
gemini-1.5-pro Google $0.00125 $0.005
gemini-1.5-flash Google $0.000075 $0.0003
llama-3.1-70b Meta $0.00079 $0.00079
llama-3.1-8b Meta $0.00018 $0.00018
mistral-large Mistral $0.002 $0.006
mistral-small Mistral $0.0002 $0.0006

Always check official pricing pages for current rates.


๐ŸŒ Supported Regions

Region Location Price Multiplier
us-east-1 N. Virginia 1.0x
us-west-2 Oregon 1.0x
eu-west-1 Ireland 1.1x
eu-central-1 Frankfurt 1.15x
ap-south-1 Mumbai 0.9x
ap-southeast-1 Singapore 1.05x
ap-northeast-1 Tokyo 1.2x

๐Ÿ“‚ Project Structure

ai-infra-cost-estimator/
โ”œโ”€โ”€ ai_infra_cost_estimator/  # Main package (pip installable)
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py               # Command-line interface
โ”‚   โ”œโ”€โ”€ calculator/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ llm.py           # LLM cost calculations
โ”‚   โ”‚   โ”œโ”€โ”€ infra.py         # Infrastructure cost calculations
โ”‚   โ”‚   โ””โ”€โ”€ scaling.py       # Scaling analysis & recommendations
โ”‚   โ”œโ”€โ”€ report/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ markdown.py      # Markdown report generator
โ”‚   โ”‚   โ””โ”€โ”€ json_report.py   # JSON report generator
โ”‚   โ””โ”€โ”€ pricing/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ models.json      # Model & infra pricing data
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ startup.yaml         # Startup configuration
โ”‚   โ”œโ”€โ”€ enterprise.yaml      # Enterprise configuration
โ”‚   โ”œโ”€โ”€ budget.yaml          # Budget-conscious config
โ”‚   โ”œโ”€โ”€ chatbot.yaml         # Chatbot application config
โ”‚   โ””โ”€โ”€ code_assistant.yaml  # Code assistant config
โ”œโ”€โ”€ pyproject.toml           # Package configuration
โ”œโ”€โ”€ MANIFEST.in
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ LICENSE

๐Ÿงฎ How It Works

LLM Cost Calculation

effective_requests = requests_per_day ร— (1 - cache_hit_ratio)
daily_tokens = effective_requests ร— (input_tokens + output_tokens)
monthly_cost = (daily_tokens / 1000) ร— price_per_1k ร— 30

Infrastructure Calculation

requests_per_second = requests_per_day / 86400
required_concurrency = rps ร— avg_latency_seconds ร— overhead_multiplier
required_pods = ceil(required_concurrency / concurrency_limit)
monthly_cost = pods ร— cost_per_hour ร— 720

Scaling Breakpoints

The analyzer finds:

  • When you need to add pods
  • When costs double
  • Impact of cache improvements
  • Cheaper model alternatives

๐Ÿ‘ฅ Who This Is For

  • AI SaaS Founders - Understand costs before launch
  • Platform Engineers - Plan infrastructure scaling
  • Cloud Architects - Optimize deployment strategy
  • Indie Hackers - Build within budget constraints

๐Ÿ”ง Programmatic Usage

from ai_infra_cost_estimator import (
    LLMCostCalculator,
    InfraCostCalculator,
    ScalingAnalyzer,
    MarkdownReportGenerator
)

# Calculate LLM costs
llm_calc = LLMCostCalculator()
llm_result = llm_calc.calculate(
    requests_per_day=10000,
    avg_input_tokens=800,
    avg_output_tokens=400,
    model="gpt-4o-mini",
    cache_hit_ratio=0.2
)

print(f"Monthly LLM Cost: ${llm_result.monthly_total_cost:.2f}")

# Calculate infrastructure costs
infra_calc = InfraCostCalculator()
infra_result = infra_calc.calculate(
    requests_per_day=10000,
    avg_latency_ms=500,
    concurrency_limit=50,
    region="us-east-1"
)

print(f"Monthly Infra Cost: ${infra_result.total_monthly_cost:.2f}")

# Get scaling analysis
analyzer = ScalingAnalyzer()
analysis = analyzer.analyze(
    requests_per_day=10000,
    avg_input_tokens=800,
    avg_output_tokens=400,
    model="gpt-4o-mini",
    cache_hit_ratio=0.2
)

for alert in analysis.scaling_alerts:
    print(f"โš ๏ธ {alert}")

for rec in analysis.recommendations[:3]:
    print(f"๐Ÿ’ก {rec.title}: Save ${rec.potential_savings:.2f}/month")

๐Ÿ›ฃ๏ธ Roadmap

  • v1.1: GPU cost estimation for self-hosted models
  • v1.2: Multi-region deployment cost comparison
  • v1.3: API endpoint for integration
  • v2.0: Real-time cloud integration (AWS, GCP, Azure)

๐Ÿ“ Assumptions

These estimates are based on:

  • Stateless inference workloads
  • HTTP-based serving
  • Average token sizes (actual may vary)
  • Public API pricing (enterprise pricing may differ)
  • No model fine-tuning costs

Clear assumptions = trust.


๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ’ฌ Support


โš ๏ธ Disclaimer

This tool provides estimated costs for planning and budgeting purposes only.

  • All model pricing values are approximations and may not reflect current actual pricing
  • LLM providers frequently update their pricing โ€” always verify with official documentation
  • Infrastructure costs vary by cloud provider, region, and specific configurations
  • Enterprise agreements, volume discounts, and promotional pricing are not factored in
  • Please recheck and validate all estimates before making financial or business decisions

Official Pricing Pages:


Built for builders who want to understand their AI costs before they scale.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_infra_cost_estimator-1.0.0.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_infra_cost_estimator-1.0.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file ai_infra_cost_estimator-1.0.0.tar.gz.

File metadata

  • Download URL: ai_infra_cost_estimator-1.0.0.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for ai_infra_cost_estimator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e7da404f5ec3da08bd687f0936cabb511cb5c6f6c001fc930442e76c7e9f1363
MD5 dfe25f8b5b378a4722302cdabe767756
BLAKE2b-256 12b088ebc971cd5fe9eb21851e5e791d5aca3020fda2e304aa399817a8e5b66f

See more details on using hashes here.

File details

Details for the file ai_infra_cost_estimator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_infra_cost_estimator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddf4d26215ec0b9061850c1589ca6a372366423f462177e156d945e3d235d783
MD5 fb7f8c7fc9a9fb80f27649eebd460b37
BLAKE2b-256 3c7ae8d7cbffb0ecc2bdc30c29d0d457f933257851bc5db4c4a37b27a97879c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page