Cut your LLM API costs by 10-20%. Drop-in prompt optimization for Python.
Project description
fortress-optimizer
Cut your LLM API costs by 10-20%. Drop-in prompt optimization for Python.
pip install fortress-optimizer
3-Line Quick Start
from fortress_optimizer import FortressClient
client = FortressClient(api_key="fk_your_key_here")
result = client.optimize("Can you please help me write a detailed and comprehensive analysis of this data")
print(result["optimization"]["optimized_prompt"])
# → "Write a detailed analysis of this data"
print(f"Saved {result['tokens']['savings_percentage']}% tokens")
# → "Saved 18% tokens"
50,000 tokens/month free. No credit card required. Get a key at fortress-optimizer.com
Why?
Every token you send to GPT-4, Claude, or Gemini costs money. Most prompts contain filler words, redundant phrases, and unnecessary politeness that inflate token counts without improving results.
Fortress compresses your prompts server-side — same meaning, fewer tokens, lower cost.
Before / After
# Before: 22 tokens
prompt = "Could you please help me analyze this sales data and provide detailed insights and recommendations?"
result = client.optimize(prompt, level="aggressive")
# After: 12 tokens
print(result["optimization"]["optimized_prompt"])
# → "Analyze sales data, provide insights and recommendations"
print(f"{result['tokens']['savings']} tokens saved ({result['tokens']['savings_percentage']}%)")
# → "10 tokens saved (45%)"
Optimization Levels
| Level | Savings | Best For |
|---|---|---|
conservative |
~5% | Production prompts where every word matters |
balanced |
~15% | General use (default) |
aggressive |
~20% | Cost-sensitive batch processing |
Full API
client = FortressClient(
api_key="fk_your_key",
base_url="https://api.fortress-optimizer.com", # default
)
# Optimize a prompt
result = client.optimize(prompt, level="balanced", provider="openai")
# result["optimization"]["optimized_prompt"]
# result["tokens"]["original"], ["optimized"], ["savings"], ["savings_percentage"]
# Check usage
usage = client.get_usage()
# usage["tokens_remaining"], usage["tier"], usage["reset_date"]
# List providers
providers = client.get_providers()
# Health check
is_healthy = client.health_check()
Batch Optimization
prompts = [
"Please analyze this data and provide your insights",
"Can you help me understand what this code does in detail",
"I would like you to summarize the key points of this document",
]
results = [client.optimize(p, level="balanced") for p in prompts]
total_saved = sum(r["tokens"]["savings"] for r in results)
print(f"Saved {total_saved} tokens across {len(results)} prompts")
Providers
OpenAI, Anthropic, Azure, Google Gemini, Groq, Ollama — pass the provider name and the optimizer tailors compression to each tokenizer.
Pricing
| Plan | Price | Tokens |
|---|---|---|
| Free | $0 | 50,000/month |
| Pro | $15/month | Unlimited |
| Teams | From $60/month | Unlimited + team management |
| Enterprise | Custom | Dedicated support + SLAs |
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fortress_optimizer-1.0.1.tar.gz.
File metadata
- Download URL: fortress_optimizer-1.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0bcabff93186e9ca69327ae72de0fad02721256c2870e2a9c476e00a19558c
|
|
| MD5 |
6b97cab7215594b78827ec521b21f485
|
|
| BLAKE2b-256 |
2b4c3fc7b00dc82c4dfecd6f1f70cf59668bed29bccc7bfe630ad4f7ed85096b
|
File details
Details for the file fortress_optimizer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fortress_optimizer-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ca9bccd5c6adf19bd84394933b4530cacba304414be63371fcfa56c8fcaac94
|
|
| MD5 |
f073bb3cf25dbcb5b398c04fec280c8d
|
|
| BLAKE2b-256 |
9097ed0edf89c4b93f89fade64de6e769190dc49e5b8833a576ef846d7be9a2b
|