API Documentation

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

Models

ModelPriceBest for
bear-1$0.45 / 1M compressed tokensGeneral compression, code repository understanding

Endpoint

POSThttps://api.thetokencompany.com/v1/compress

Authentication

All API requests require authentication. Include your API key in the Authorization header. You can find your API key in your dashboard after signing up.

Authorization: Bearer YOUR_API_KEY

Quick Start

bash
curl -X POST https://api.thetokencompany.com/v1/compress \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "bear-1",
    "compression_settings": {
      "aggressiveness": 0.5,
      "max_output_tokens": null,
      "min_output_tokens": null
    },
    "input": "Your text that needs compression for optimal token usage."
  }'

Request Body

Send a JSON object with the following fields:

json
{
  "model": "bear-1",
  "compression_settings": {
    "aggressiveness": 0.5,
    "max_output_tokens": null,
    "min_output_tokens": null
  },
  "input": "Your text that needs compression for optimal token usage."
}
FieldTypeDescription
modelstringModel to use for compression. Currently only bear-1.
inputstringThe text to compress.
compression_settings.aggressivenessfloat (0.0–1.0)How aggressively to compress. Higher values remove more tokens. Default: 0.5.
compression_settings.max_output_tokensint | nullMaximum tokens in output. Set to null for no limit.
compression_settings.min_output_tokensint | nullMinimum tokens in output. Set to null for no minimum.

Aggressiveness Guide

0.1–0.3Light — removes only obvious filler, safe for all use cases
0.4–0.6Moderate — good balance of compression and quality
0.7–0.9Aggressive — significant savings, best for cost-sensitive workloads

Response

json
{
  "output": "text needs compression token usage.",
  "output_tokens": 5,
  "original_input_tokens": 12,
  "compression_time": 0.4945101737976074
}
FieldTypeDescription
outputstringThe compressed text.
output_tokensintToken count of the compressed output.
original_input_tokensintToken count of the original input.
compression_timefloatTime taken to compress (in seconds).

Python Example

python
import requests

response = requests.post(
    "https://api.thetokencompany.com/v1/compress",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY"
    },
    json={
        "model": "bear-1",
        "compression_settings": {
            "aggressiveness": 0.5,
            "max_output_tokens": None,
            "min_output_tokens": None
        },
        "input": "Your text that needs compression for optimal token usage."
    }
)

result = response.json()
print(result["output"])