Skip to main content
Version 0.1 ScaleDown is a context engineering platform that intelligently compresses AI prompts while preserving semantic integrity and reducing hallucinations. Our research-backed compression algorithms analyze prompt components—from reasoning chains to code contexts—and apply targeted optimization techniques that maintain output quality while dramatically reducing token consumption.

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.
Parameters 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.
Attributes 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.
Set API key globally
Get current key
  • 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 from ScaleDownError.