Learn how to authenticate your API requests using API keys. All requests must include a valid API key in the X-API-Key header.
All API requests must include your API key in the X-API-Key header. This identifies your account and tracks your usage.
curl -X POST https://lesstokens.hive-hub.ai/api/compress \
-H "X-API-Key: lsk_live_1234567890abcdef..." \
-H "Content-Type: application/json" \
-d '{"prompt": "Your text here"}'LessToken API keys follow a specific format to identify the key type and environment:
lsk_test_...For development and testing environments
Example:
lsk_test_1234567890abcdef1234567890abcdeflsk_live_...For production environments
Example:
lsk_live_1234567890abcdef1234567890abcdefNever Expose Live Keys
Always use environment variables to store API keys. Never commit keys to version control or expose them in client-side code.
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 to compress",
"options": {
"jsonMinify": true,
"removeComments": true
}
}'import axios from 'axios';
const apiKey = process.env.LESSTOKEN_API_KEY;
const baseUrl = 'https://lesstokens.hive-hub.ai';
async function compressText(prompt: string) {
const response = await axios.post(
`${baseUrl}/compress`,
{
prompt,
options: {
jsonMinify: true,
removeComments: true,
},
},
{
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json',
},
}
);
return response.data;
}import os
import requests
api_key = os.getenv('LESSTOKEN_API_KEY')
base_url = 'https://lesstokens.hive-hub.ai'
def compress_text(prompt: str):
response = requests.post(
f'{base_url}/compress',
headers={
'X-API-Key': api_key,
'Content-Type': 'application/json'
},
json={
'prompt': prompt,
'options': {
'jsonMinify': True,
'removeComments': True
}
}
)
return response.json()Missing or invalid API key
Common Causes:
Solution:
Verify your API key in the dashboard and ensure it's included in the X-API-Key header.
Example Response:
{
"error": "Unauthorized",
"message": "Invalid or missing API key",
"code": "AUTHENTICATION_REQUIRED"
}Valid key but insufficient permissions
Common Causes:
Solution:
Check your account status and rate limits in the dashboard. Contact support if needed.
Example Response:
{
"error": "Forbidden",
"message": "Rate limit exceeded",
"code": "RATE_LIMIT_EXCEEDED"
}Store API keys in environment variables, never hardcode them in your source code.
Do:
Don't:
Generate new API keys periodically and revoke old ones to minimize security risks.
Do:
Don't:
Always use test keys (lsk_test_) during development to avoid accidental charges.
Do:
Don't:
API requests are rate-limited to ensure fair usage and system stability. Rate limits are applied per API key.
100 requests/hour
For testing and small projects
1,000 requests/hour
For production applications
Custom limits
For high-volume usage
Rate Limit Headers
All API responses include rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.
Now that you understand authentication, explore the API endpoints: