Main Classes
scaledown.compressor.ScaleDownCompressor
The compressor module contains various Compressors, the default being ScaleDownCompressor.
The main entry point for compressing text. It manages API communication, batch processing, and compression settings.
This class inherits from
BaseCompressor and handles both single-string and list-based inputs automatically.
Methods
compress
Compresses the given context and prompt.
Returns
CompressedPrompt: If inputs are strings.List[CompressedPrompt]: If inputs are lists (supports batch processing).
Data Structures
scaledown.types.CompressedPrompt
A smart object containing the compressed text and valid metadta. It behaves like a string but carries rich statistics.
This also is the output of Compressor objects.
Methods
-
print_stats()
Prints a formatted summary of compression performance to stdout. As an example- ScaleDown Stats:- Tokens: 1000 -> 400
- Savings: 60.0%
- Ratio: 2.5x
- Latency: 150ms
scaledown.metrics.CompressionMetrics
Pydantic model that validates the raw metrics returned by the API.
Configuration & Exceptions
Configuration
ScaleDown uses a global configuration system for API keys and endpoints.- Environment Variables:
SCALEDOWN_API_KEY: Automatically loaded if not set in code.SCALEDOWN_API_URL: Override the default API endpoint (Default:https://api.scaledown.xyz).
Exceptions
All custom exceptions inherit fromScaleDownError.