Integration guide

Spring Boot compression integration

Spring Boot powers enterprise Java applications. Add SuperCompress as a Spring interceptor or filter.

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

Spring interceptor

@Component
public class CompressionInterceptor implements HandlerInterceptor {
    private final RestTemplate restTemplate = new RestTemplate();
    private final String apiKey = System.getenv("SUPERCOMPRESS_API_KEY");

    @Override
    public boolean preHandle(HttpServletRequest request,
                            HttpServletResponse response, Object handler) {
        if (request.getRequestURI().equals("/api/chat")) {
            // Extract body, call SuperCompress API, set compressed body
            String compressed = callSuperCompress(body, query);
            request.setAttribute("compressed_context", compressed);
        }
        return true;
    }
}

Frequently asked questions

Does it work with Spring WebFlux?

Yes. Create a WebFilter for reactive Spring applications.

Can I use it with Spring Cloud Gateway?

Yes. Add compression as a gateway filter for all LLM-bound routes.

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