Integration guide
Flask compression integration
Flask is lightweight and widely used for AI application backends. Add SuperCompress as a Flask before_request handler.
Flask integration
from flask import Flask, request, jsonify
from supercompress import Compressor
app = Flask(__name__)
comp = Compressor()
@app.route("/api/compress", methods=["POST"])
def compress():
data = request.json
result = comp.compress(data["context"], data["query"])
return jsonify({
"compressed_text": result.compressed_text,
"original_tokens": result.original_tokens,
"kept_tokens": result.kept_tokens
})
Frequently asked questions
Can I use blueprints with compression?
Yes. Apply compression middleware to specific blueprints.
Does it work with Flask-SocketIO?
Yes. Compress messages before emitting them through the socket.
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.