Skip to main content

Terminal-based AI API Cost Calculator, Converter & Recommender

Project description

AI-Cost-CLI

A terminal-based calculator and recommendation engine for AI API costs. Supports multiple providers, local currency conversion, and automated pricing updates.

Preview: Direct vs. Aggregator Comparison

Compare the effective cost of using models directly vs. through gateways like OpenRouter, including platform fees.

                    Comparison: gpt-4o vs openrouter/gpt-4o                     
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Attribute        ┃             gpt-4o              ┃    openrouter/gpt-4o    ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Provider         │             OpenAI              │       OpenRouter        │
├──────────────────┼─────────────────────────────────┼─────────────────────────┤
│ Source           │             Direct              │       Aggregator        │
├──────────────────┼─────────────────────────────────┼─────────────────────────┤
│ Platform Fee     │              0.0%               │          5.5%           │
├──────────────────┼─────────────────────────────────┼─────────────────────────┤
│ Type             │              text               │          text           │
├──────────────────┼─────────────────────────────────┼─────────────────────────┤
│ Input Cost       │        111.4775 TRY (1M)        │    117.6088 TRY (1M)    │
├──────────────────┼─────────────────────────────────┼─────────────────────────┤
│ Output/Unit Cost │        445.9100 TRY (1M)        │    470.4350 TRY (1M)    │
└──────────────────┴─────────────────────────────────┴─────────────────────────┘

Features

  • Infrastructure Comparison: Compare Direct providers vs. Aggregators (OpenRouter) and Gateways (Portkey, LiteLLM, Martian).
  • Transparent Commissions: Automatically calculates platform fees (e.g., OpenRouter's 5.5% credit fee).
  • Direct Cost Calculation: Full breakdown of base costs and platform middle-layer fees.
  • Currency Conversion: Real-time conversion to local currencies (TRY, EUR, etc.) with offline fallback.
  • Automated Pricing: Weekly automated updates from official provider documentation.
  • MCP Server: Native support for AI agents (Cursor, Claude Desktop).

Usage

Infrastructure & Sync

# List all models including Source Type (Direct/Aggregator/Gateway)
aicost list --currency TRY

# Compare Direct vs. Aggregator pricing
aicost compare gpt-4o openrouter/gpt-4o --currency TRY

Advanced Cost Calculation

Includes platform fee breakdowns for aggregators:

aicost calc openrouter/gpt-4o --input 1000000 --output 500000 --currency TRY

Output Example:

╭───────── Cost Calculation ──────────╮
│ Model: openrouter/gpt-4o            │
│ Source: Aggregator                  │
│                                     │
│ Base Cost: 316.9976 TRY             │
│ Platform Fee (5.5%): 17.4349 TRY    │
│                                     │
│ Total Cost: 334.4325 TRY            │
╰─────────────────────────────────────╯

Installation

git clone https://github.com/ufhouck/aicost.git
cd aicost
pip install -e .

MCP Server

aicost mcp

Registries

Contributing

The pricing database is located in data/pricing.json. Updates are automatically checked weekly.

License

MIT. Developed by Ufuk Aydın.

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

aicost_cli-1.0.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

aicost_cli-1.0.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aicost_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 39c9c20791ce0d82981988c3280f182387158ba50514e68cebb177c4178755e4
MD5 57ae064905b9c115d39d67e6e8b46e51
BLAKE2b-256 815757c49582de1dae29ad65ebd8e6a584f543c389cd5c3dd7d02ef51c20c619

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aicost_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for aicost_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 457d4fbcb5c2356eef92994440a3b146bd4d03ef2371b70139f27e4c2465aba2
MD5 ecc09b1d72c824c10e4e4812a9e1dbeb
BLAKE2b-256 ad368349f6b5e1f4133ba964f9b85b6e415a7801978c73b5032776994f50552b

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