Deployment guide

AWS Lambda deployment

AWS Lambda is the most popular serverless compute platform. SuperCompress's tiny footprint and CPU-only operation make it ideal for Lambda deployment.

By Arjun Shah - Creator of SuperCompress - Updated 2026-07-03

Lambda deployment guide

# Create a Lambda deployment package
pip install supercompress -t package/
cp lambda_function.py package/
cd package && zip -r ../deploy.zip .

Lambda function code

from supercompress import Compressor
comp = Compressor()

def lambda_handler(event, context):
    body = json.loads(event["body"])
    result = comp.compress(body["context"], body["query"])
    return {
        "statusCode": 200,
        "body": json.dumps({
            "compressed_text": result.compressed_text,
            "original_tokens": result.original_tokens,
            "kept_tokens": result.kept_tokens
        })
    }

Frequently asked questions

What Lambda configuration works best?

512MB memory, Python 3.11 runtime. Expect ~300ms cold start + ~60ms compression.

Can I use Lambda with API Gateway?

Yes. Deploy behind API Gateway for a RESTful compression endpoint.

Build with less context

Put compression in front of your next LLM call.

Use the hosted API or run SuperCompress locally. Keep the evidence, drop the token waste, and measure the savings before it reaches your model.

Get an API keyRead the guide