API Documentation

Compress text for optimized LLM inference. Reduce token usage, lower costs, and speed up your AI applications.

Endpoint

POSThttps://api.otsofy.com/compress

Quick Start

Auth header
bash
curl -X POST https://api.otsofy.com/compress \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "input": "Your text that needs compression for optimal token usage.",
    "importance_cutoff": 0.3
  }'

Authentication

You can preview the API without a key (rate limited). For full access, sign up to get your API key.

Authorization: Bearer YOUR_API_KEY

Compression Modes

Choose one of two modes depending on your needs. Pass input (required) plus one of these parameters:

Adaptive

importance_cutoff: 0.0–1.0

Analyzes your text and removes content below an importance threshold. Keeps the most meaningful parts, removes fluff.

0.1Light — removes only obvious filler
0.3Moderate — good default
0.6+Aggressive — keeps only key info

Best for: general use, quality-focused compression

Static

compression_rate: 0.0–1.0

Removes a fixed percentage of tokens regardless of content. Predictable output size every time.

0.2Removes 20% of tokens
0.5Removes 50% of tokens
0.8Removes 80% of tokens

Best for: budget planning, fixed context windows

Response

json
{
  "success": true,
  "compressed_text": "text needs compression for token usage.",
  "original_tokens": 12,
  "compressed_tokens": 7
}

Python Example

Auth header
python
import requests

response = requests.post(
    "https://api.otsofy.com/compress",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY"
    },
    json={
        "input": "Your text that needs compression for optimal token usage.",
        "importance_cutoff": 0.3
    }
)

print(response.json()["compressed_text"])