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.
Try it yourself
Paste your long prompt into the playground, ask a question, and see what SuperCompress keeps and removes. Free, no signup needed.