API Documentation
Compress text for optimized LLM inference. Reduce token usage, lower costs, and speed up your AI applications.
Models
| Model | Price | Best for |
|---|---|---|
| bear-1 | $0.45 / 1M compressed tokens | General compression, code repository understanding |
Endpoint
POST
https://api.thetokencompany.com/v1/compressAuthentication
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_KEYQuick 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."
}| Field | Type | Description |
|---|---|---|
| model | string | Model to use for compression. Currently only bear-1. |
| input | string | The text to compress. |
| compression_settings.aggressiveness | float (0.0–1.0) | How aggressively to compress. Higher values remove more tokens. Default: 0.5. |
| compression_settings.max_output_tokens | int | null | Maximum tokens in output. Set to null for no limit. |
| compression_settings.min_output_tokens | int | null | Minimum 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
}| Field | Type | Description |
|---|---|---|
| output | string | The compressed text. |
| output_tokens | int | Token count of the compressed output. |
| original_input_tokens | int | Token count of the original input. |
| compression_time | float | Time 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"])