Step-by-step guide to sending your first compression request to the LessToken API and understanding the response.
Make sure you have the following ready:
You need an active API key to authenticate requests
Use cURL, Postman, or your preferred HTTP client
Here's the simplest compression request you can make:
curl -X POST https://lesstokens.hive-hub.ai/api/compress \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Large language models are powerful but expensive. This API helps reduce costs by compressing prompts intelligently while maintaining semantic meaning and context."
}'Replace YOUR_API_KEY
Don't forget to replace YOUR_API_KEY with your actual API key from the dashboard.
A successful request returns a JSON response with the compressed text and detailed metrics:
{
"compressedPrompt": "LLMs powerful but expensive. API reduces costs by compressing prompts intelligently while maintaining semantic meaning & context.",
"originalTokens": 28,
"compressedTokens": 19,
"compressionRatio": 0.32,
"savingsPercentage": 32.14,
"processingTimeMs": 45,
"id": "req_abc123xyz",
"timestamp": "2025-01-18T14:30:00Z"
}Original Tokens
28
Input token count
Compressed Tokens
19
Output token count
Tokens Saved
9
Reduction achieved
Savings
32.14%
Compression ratio
You can customize compression behavior with options:
curl -X POST https://lesstokens.hive-hub.ai/api/compress \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Your text here with extra spaces and newlines\n\n\n",
"options": {
"jsonMinify": true,
"removeComments": true,
"compressArrays": false,
"maxTimeMs": 5000
}
}'jsonMinifybooleanMinify JSON content in the prompt
Default: false
removeCommentsbooleanRemove code comments from prompts
Default: true
compressArraysbooleanCompress large array structures
Default: false
maxTimeMsnumberMaximum processing time in milliseconds
Default: 10000
Missing or invalid API key. Check that your X-API-Key header is correct.
Solution: Verify your API key in the dashboard and ensure it's not revoked.
Invalid request body or missing required fields.
Solution: Ensure the 'prompt' field is present and is a string.
You've exceeded your rate limit.
Solution: Wait a moment before retrying or upgrade your plan for higher limits.
Something went wrong on our end.
Solution: Retry the request. If the issue persists, contact support.
Test with short prompts first to understand the compression behavior
Test with various content types: code, prose, JSON, etc.
Pay attention to compression ratios and processing times
Great! You've made your first request. Now learn how to integrate this into your applications: