Go integration guide
Go prompt compression
Go is increasingly popular for building high-performance AI backends. SuperCompress's REST API makes it easy to add prompt compression to any Go service.
Go client implementation
package supercompress
import (
"bytes"
"encoding/json"
"net/http"
)
type CompressRequest struct {
Context string `json:"context"`
Query string `json:"query"`
}
type CompressResponse struct {
CompressedText string `json:"compressed_text"`
}
func Compress(apiKey, context, query string) (string, error) {
body := CompressRequest{Context: context, Query: query}
buf := new(bytes.Buffer)
json.NewEncoder(buf).Encode(body)
req, _ := http.NewRequest("POST",
"https://supercompress.dev/api/v1/compress", buf)
req.Header.Set("X-API-Key", apiKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { return "", err }
defer resp.Body.Close()
var result CompressResponse
json.NewDecoder(resp.Body).Decode(&result)
return result.CompressedText, nil
}
Frequently asked questions
Does this require the Python package?
No. Go services use the REST API directly. No Python dependency needed.
How fast is the Go integration?
The REST API responds in ~60ms. The Go HTTP client adds minimal overhead (~2-5ms).
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.