Quick Start
Get your API key by creating an account. Choose your language:
import requests
# 1. Call our API with the prompt to compress
response = requests.post(
"https://api.thetokencompany.com/v1/compress",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "bear-1.2",
"input": "Your long text to compress goes here...",
"compression_settings": {"aggressiveness": 0.1}
}
)
# 2. Print the compressed prompt
print(response.json()["output"])
API Endpoint
POST https://api.thetokencompany.com/v1/compress
Authentication
Add your API key to the request header:
Authorization: Bearer YOUR_API_KEY
Get your API key by creating an account.
Request
{
"model": "bear-1.2",
"input": "Your text to compress",
"compression_settings": {
"aggressiveness": 0.1
}
}
| Parameter | Type | Description |
|---|
model | string | bear-1.2 (recommended), bear-1.1, or bear-1 |
input | string | Text to compress |
compression_settings.aggressiveness | float | 0.0 to 1.0 — higher means more compression. Default: 0.5 |
Response
{
"output": "Compressed text here",
"output_tokens": 5,
"original_input_tokens": 12
}
| Field | Description |
|---|
output | Compressed text |
output_tokens | Token count after compression |
original_input_tokens | Original token count |
Gzip Compression
We recommend gzip for every request — overhead is under 1ms and it’s up to 2.5x faster for large payloads. The Python SDK and npm package enable gzip by default. For direct API usage, add Content-Encoding: gzip and send the compressed JSON body. See the full guide and benchmarks on the Gzip Compression page.
import gzip, json, requests
payload = json.dumps({
"model": "bear-1.2",
"input": your_text,
"compression_settings": {"aggressiveness": 0.1}
}).encode()
response = requests.post(
"https://api.thetokencompany.com/v1/compress",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"Content-Encoding": "gzip"
},
data=gzip.compress(payload)
)
Protected Tokens
Parts of the input text can be protected from compression by using the <ttc_safe> tags. See the full documentation on the Protect Text page.
compression applied here<ttc_safe>but not here</ttc_safe>
Pricing
| Model | Price |
|---|
bear-1.2 | $0.05 / 1M compressed tokens |
bear-1.1 | $0.05 / 1M compressed tokens |
bear-1 | $0.05 / 1M compressed tokens |
What are compressed tokens?
Compressed tokens are the tokens that were removed during compression — the difference between your input and output token counts.
Example: If you send 500 tokens and receive 200 tokens back, you are charged for the 300 tokens that were removed. The 200 remaining tokens are free.