Skip to main content

Cut AI API costs by 63-99% with intelligent routing across all AI providers

Project description

APICrusher - Cut AI API Costs by 63-99%

Stop bleeding money on AI APIs. APICrusher automatically routes requests to the cheapest capable model and caches responses, cutting costs by 63-99% with just 2 lines of code.

🚀 Quick Start

# Python 3.7+ required
# Use a virtual environment (recommended for all Python packages)
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install with your provider(s)
pip install apicrusher[standard]  # OpenAI + Redis caching (recommended)
# OR
pip install apicrusher[all]       # All providers (OpenAI, Anthropic, Google, etc.)

📋 Installation Options

# Choose based on your needs:
pip install apicrusher[standard]   # OpenAI + Redis (most users)
pip install apicrusher[openai]     # Just OpenAI support
pip install apicrusher[anthropic]  # Just Anthropic support
pip install apicrusher[google]     # Just Google support
pip install apicrusher[all]        # Everything - all providers
pip install apicrusher              # Minimal - add providers later

Virtual Environment Required

Modern Python systems require virtual environments for pip packages:

# If you see "externally-managed-environment" error:
python3 -m venv venv
source venv/bin/activate
pip install apicrusher[standard]

API Keys Required

APICrusher optimizes your existing AI API calls. You need:

  1. Your AI provider API key (OpenAI, Anthropic, etc.) - Keep using your existing keys
  2. An APICrusher optimization key from apicrusher.com - Enables cost optimization

How It Works

APICrusher is a smart proxy layer. You keep your existing API keys. We analyze each request and route it to the optimal model. Your API keys never leave your server.

💻 Basic Usage

# Before (expensive)
from openai import OpenAI
client = OpenAI(api_key="sk-...")  # Your OpenAI key

# After (63-99% cheaper)
from apicrusher import OpenAI
client = OpenAI(
    openai_api_key="sk-...",        # Your existing OpenAI key
    apicrusher_key="apc_live_..."   # Add optimization key
)

# Your code stays exactly the same
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

💰 How Much Can You Save?

Single Provider vs Cross-Provider

  • Single Provider (e.g., just OpenAI): 70-85% savings
  • Cross-Provider (e.g., OpenAI + Anthropic): Up to 99% savings
Your Current Usage Monthly Cost With APICrusher You Save
GPT-4 for everything $1,000 $180 $820 (82%)
Mixed GPT-4/3.5 $500 $95 $405 (81%)
Heavy API usage $5,000 $750 $4,250 (85%)
Long conversations $2,000 $340 $1,660 (83%)

🎯 Core Features

Cross-Provider Optimization (NEW in v2.0)

Get 99% savings by routing between providers:

from apicrusher import OpenAI

client = OpenAI(
    openai_api_key="sk-...",             # Your OpenAI key
    anthropic_api_key="sk-ant-...",      # Optional: Add for 99% savings
    google_api_key="...",                # Optional: Add Google key
    apicrusher_key="apc_live_..."    
)

# Simple GPT-4 queries now route to Claude Haiku automatically (99% cheaper)
# Complex queries stay on GPT-4 to preserve quality

Universal Provider Support

Works with ALL major AI providers and models:

  • OpenAI: GPT-5, GPT-4, GPT-4o, O1, O3 (all current models)
  • Anthropic: Claude Opus 4.1, Claude Sonnet 4, Claude 3.5
  • Google: Gemini 2.0, Gemini 1.5 Pro/Flash
  • Meta: Llama 3.3, Llama 3.2, Code Llama
  • Others: Groq, Cohere, Mistral, DeepSeek, and more

Intelligent Model Routing

  • Simple queries → Cheap models (gpt-4o-mini)
  • Complex queries → Premium models (GPT-5, Claude Opus 4.1)
  • Automatic quality preservation

Smart Caching

  • Deduplicates identical requests
  • Redis + in-memory fallback
  • 33% average cache hit rate

🆕 Context Compression (NEW!)

Stop paying to reprocess the same conversation 50 times:

# Enable context compression for long conversations
response = client.chat.completions.create(
    model="gpt-4",
    messages=conversation_history,  # 50 messages = 15,000 tokens normally
    compress_context=True  # Reduces to ~3,000 tokens automatically
)

# Features:
# - Summarizes older messages while preserving key decisions
# - Removes duplicate context automatically  
# - Compresses code blocks by 40-60%
# - Sends only deltas for continuing conversations
# - Preserves last 3 messages in full for accuracy

Context Compression Savings Example:

  • Normal 20-message conversation: 150,000 tokens ($2.25)
  • With compression: 35,000 tokens ($0.52)
  • Savings: 77% on long conversations

🏢 Enterprise Security & Controls (v2.0)

Security Features

  • IP Allowlisting: Restrict API keys to specific IP ranges
  • Audit Logging: Complete usage trail for compliance (SOC2 Type II)
  • API Key Rotation: Rotate keys without service interruption
  • Email Verification: Secure access control for all users
  • Role-Based Access: Admin and user permissions for teams

Business Controls

  • Usage Quotas: Configurable limits per tier
    • Trial: 1,000 calls/day
    • Professional: 10,000 calls/day
    • Enterprise: Unlimited with alerts
  • 80% Alerts: Email warnings before quota exceeded
  • Overage Protection: Prevent unexpected bills
  • Team Management: Multiple users under one billing account
  • Monthly Reports: Automated ROI reports for finance teams

Reliability & Monitoring

  • Webhook Retry Queue: Never miss critical payment events
  • Health Monitoring: Real-time system status at /metrics
  • Automatic Failover: Cross-provider redundancy
  • 99.9% Uptime SLA: For enterprise customers
  • Dedicated Support: Priority response for business accounts

Compliance

  • SOC2 Type II: Security audit compliant
  • GDPR Ready: Data processing agreements available
  • HIPAA Compatible: With enterprise agreement
  • Self-Hosted Option: Deploy in your own VPC for maximum control

📊 Analytics & Reporting

# Get detailed savings report
client.print_savings_summary()

# Output:
# 💸 Total Saved: $127.43
# 📞 Total Calls: 1,432
# 💾 Cache Hit Rate: 34.2%
# ⚡ Optimization Rate: 91.3%

Executive Dashboard

  • Real-time cost savings visualization
  • Model routing analytics
  • Usage patterns and trends
  • Export to CSV/Excel for finance teams
  • Monthly ROI reports via email

🔧 Advanced Usage

Multi-Provider Setup

from apicrusher import OpenAI

# Install with: pip install apicrusher[all]
client = OpenAI(
    openai_api_key="sk-...",
    anthropic_api_key="sk-ant-...",
    google_api_key="...",
    groq_api_key="...",
    apicrusher_key="apc_..."
)

# Automatically routes to cheapest provider
response = client.chat.completions.create(
    model="gpt-4",  # Will use cheapest capable model
    messages=[{"role": "user", "content": "Format this date: 2024-01-01"}]
)

Context Compression Options

# Fine-tune compression behavior
response = client.chat.completions.create(
    model="gpt-4",
    messages=long_conversation,
    compress_context=True,
    compression_threshold=10,  # Start compressing after 10 messages
    preserve_recent=5  # Keep last 5 messages uncompressed
)

Manual Optimization Control

# Force specific model
response = client.chat.completions.create(
    model="gpt-4o-mini",  # Use this exact model
    messages=messages,
    skip_optimization=True  # Bypass routing logic
)

Enterprise Configuration

# Configure enterprise features
client = OpenAI(
    openai_api_key="sk-...",
    apicrusher_key="apc_enterprise_...",
    config={
        "ip_allowlist": ["192.168.1.0/24"],
        "audit_logging": True,
        "usage_quota": 50000,  # Daily limit
        "alert_threshold": 0.8,  # Alert at 80% usage
        "team_id": "eng-team-01"
    }
)

📊 Real-World Results

Based on actual customer usage:

  • E-commerce company: Reduced costs from $8,400/mo to $1,260/mo (85% savings)
  • SaaS startup: Cut API bills from $3,200/mo to $480/mo (85% savings)
  • AI coding assistant: Dropped from $12,000/mo to $2,400/mo (80% savings)
  • Customer support platform: Saved $47,000/year with context compression
  • Data analytics firm: 99% reduction using cross-provider routing

🛡️ Security & Privacy

  • Your API keys stay local - Never sent to our servers
  • No prompt logging - Your data remains private
  • Open source core - Audit the optimization logic
  • SOC2 compliant - Enterprise-ready security
  • IP allowlisting - Restrict access to your network
  • Audit trails - Complete usage history for compliance

🚀 Getting Started

  1. Install: pip install apicrusher[standard]
  2. Get your key: Sign up at apicrusher.com
  3. Add 2 lines: Replace your import and add your key
  4. Save money: Watch your costs drop by 63-99%

💰 Pricing

  • Free Trial: 7 days, no credit card required
  • Professional: $99/month (pays for itself in hours)
  • Enterprise: Custom pricing for high-volume usage

Most customers save 10-50x the subscription cost in the first month.

🤝 Support

License

MIT License - Use it however you want.


Stop bleeding money on AI APIs. Start saving with APICrusher today.

Get Your Key →

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

apicrusher-2.2.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

apicrusher-2.2.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file apicrusher-2.2.0.tar.gz.

File metadata

  • Download URL: apicrusher-2.2.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for apicrusher-2.2.0.tar.gz
Algorithm Hash digest
SHA256 798281d86abce1d206e66cf0a3437e40ecc913bb14a8314e7121e42cae850999
MD5 093de0dd74b8e903a87e804cc4612184
BLAKE2b-256 7562a4e1cd534e932eb51edde90a3a05db4ff77200ad065581f6f40a581ccead

See more details on using hashes here.

File details

Details for the file apicrusher-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: apicrusher-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for apicrusher-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71edad99fed9d3199eb25e3635cfe168c38d8643dd3dd5b5665cd30999344022
MD5 16a1119e84a92f184feb5dc7b16e591c
BLAKE2b-256 b6b58da47d2c62c13c15978fdc33d2eb08739ec7376192957ba1a15297187e8d

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