Minify LLM prompts to reduce API token costs
Project description
CAIO (Cost-Aware Inference Orchestration)
CAIO is a high-performance optimization engine designed to drastically reduce LLM API costs. It employs a "hardcore" minification strategy that intelligently scrubs amateur conversational noise ("fluff") and compresses code-centric prompts before transmission, ensuring you only pay for the tokens that matter.
Key Features
- Generalized NLP Scrubber: Intelligently identifies and removes non-essential conversational text (greetings, politeness, fluff) while preserving core logic and code context.
- Code Minifier: Strips comments, unnecessary whitespace, and formatting overhead to maximize token density.
- Tiered Optimization: Flexible optimization tiers (e.g.,
'dev') to suit different stages of the development lifecycle. - Cost-Efficient: Directly reduces the token count sent to providers like OpenAI, Google Gemini, and Anthropic.
Installation
Install the package via pip:
pip install caio-atharva
Usage Example
Import CAIO, initialize it with your target model, and start optimizing your prompts immediately.
from caio import CAIO
# Initialize the optimizer. Specify your target model (default: gemini-1.5-flash)
optimizer = CAIO(model="provider-5/gemini-3-pro")
# Your original, verbose prompt
bloated_prompt = """
Hello there! I hope you are having a great day.
I'm new to Python and I was wondering if you could please help me.
Could you write a function to calculate the fibonacci sequence?
Make sure it's recursive. Thanks so much!
"""
# Optimize the prompt using the 'dev' tier for maximum efficiency
result = optimizer.optimize(bloated_prompt, tier="dev")
# Access and print the results
print(f"Original Length: {len(bloated_prompt)}")
print(f"Optimized Prompt: {result['optimized_prompt']}")
print(f"Tokens/Chars Saved: {result['tokens_saved']}")
Output
The optimized prompt sent to the LLM will look like this:
CODE-ONLY;NO-CHAT;MINIFY-RESPONSE: write a function to calculate the fibonacci sequence? Make sure it's recursive.
Impact Comparison
See how CAIO transforms a standard prompt into a cost-efficient payload.
| Feature | Bloated Prompt (Expensive) | CAIO Optimized Prompt (Efficient) |
|---|---|---|
| Content | "Hi! Please write a Python script for binary search. Thanks!" | CODE-ONLY;NO-CHAT;MINIFY-RESPONSE: write a Python script for binary search. |
| Token Load | High (Includes social overhead) | Low (Pure instruction & code) |
| Cost | $$$ ( paying for "Please" and "Thanks" ) | $ ( Paying only for logic ) |
| Latency | Slower processing of extra text | Faster inference |
Project Structure
CAIO-SDK/
├── caio/
│ ├── __init__.py
│ └── optimizer.py # Core logic: CAIO class & NLP scrubber
├── setup.py # Package configuration
└── README.md # Documentation
Metadata
- Developer: Atharva Matale
- License: MIT License
- Version: 1.0.7
- Version: 1.0.10
Maximize efficient inference. Minimize costs. Use CAIO.
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
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 caio_atharva-1.0.10.tar.gz.
File metadata
- Download URL: caio_atharva-1.0.10.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f31fce28a8de705710be67e14459ef1f7bd833fd2f9b423de3ebeec1b5a04b1c
|
|
| MD5 |
69ca80029c065bdff700a2b807925103
|
|
| BLAKE2b-256 |
e8794f6f08d46b0a0773d19876faf6f67615a1969deb8353ea6e58252ced14fd
|
File details
Details for the file caio_atharva-1.0.10-py3-none-any.whl.
File metadata
- Download URL: caio_atharva-1.0.10-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
934707cc8993eec21d9e9631fc3cefdc15d8be07a87a2dc64bc7c3b1132c470b
|
|
| MD5 |
3f3cc5fa76dd3f77aa70711ad7260196
|
|
| BLAKE2b-256 |
2b68aeec0a43f6db9fb4e94500ce820aff2b52b4e250775f8c021966fee24338
|