Authentication
Authenticate all requests by passing your API Key in the Authorization header using the Bearer scheme.
Get your key from your Pro Dashboard.
Programmatically compress prompts, cut token consumption by 40–60%, and integrate CuToken directly into LLM agent workflows, LangChain, or custom backend services.
Authenticate all requests by passing your API Key in the Authorization header using the Bearer scheme.
Get your key from your Pro Dashboard.
All requests should be sent over HTTPS. Send JSON payloads with standard headers:
CORS is enabled (*) for direct web, extension, or agent calls.
1 credit = 2,000 characters. Credits are shared seamlessly across API, Terminal CLI, Chrome Extension, and Web.
Core endpoints to manage credits and optimize prompts.
/api/optimize.php
Optimize prompt text with multi-pass compression
Compresses the provided prompt through normalization, lexical pruning, and SLM refinement. Automatically calculates token savings and deducts corresponding credits.
| Field | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | The input prompt text to compress (max 2,000 chars). |
| mode | string | Optional | Optimization intensity: safe, balanced (default), or aggressive. |
| template | string | Optional | Output format template: concise (default), structured, role_based, step_by_step, etc. |
curl -X POST https://pro.cutoken.in/api/optimize.php \
-H "Authorization: Bearer ct_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "You are a helpful customer service representative. Please kindly assist me with updating my billing address on the system.",
"mode": "balanced"
}'
import requests
res = requests.post(
"https://pro.cutoken.in/api/optimize.php",
headers={"Authorization": "Bearer ct_live_your_key_here"},
json={
"prompt": "You are a helpful customer service representative...",
"mode": "aggressive"
}
)
data = res.json()
print("Compressed:", data["data"]["compressed_prompt"])
print("Tokens saved:", data["data"]["saved_tokens"])
const res = await fetch("https://pro.cutoken.in/api/optimize.php", {
method: "POST",
headers: {
"Authorization": "Bearer ct_live_your_key_here",
"Content-Type": "application/json"
},
body: JSON.stringify({
prompt: "You are a helpful customer service representative...",
mode: "balanced"
})
});
const result = await res.json();
console.log(result.data.compressed_prompt);
{
"success": true,
"data": {
"compressed_prompt": "Help update system billing address.",
"origin_tokens": 20,
"compressed_tokens": 6,
"saved_tokens": 14,
"reduction_pct": "70%"
},
"credits_remaining": 1249.0
}
/api/me.php
Check current account, credit balance, and API status
Returns user information and remaining credit quota. Use this in your agent health checks or to alert when credits run low.
curl -X GET https://pro.cutoken.in/api/me.php \
-H "Authorization: Bearer ct_live_your_key_here"
{
"success": true,
"name": "Alex Smith",
"email": "alex@example.com",
"credits_remaining": 1249.0,
"credits_formatted": "1,249",
"chars_per_credit": 2000,
"has_api_key": true
}
Predictable, standard HTTP responses for seamless error handling.
| Status | Reason | Action |
|---|---|---|
| 200 OK | Optimization successful | Output returned in data.compressed_prompt. |
| 400 Bad Request | Missing or empty prompt parameter | Ensure request body contains valid JSON with non-empty prompt. |
| 401 Unauthorized | Invalid or missing API key | Check Authorization: Bearer <key> header. |
| 402 Payment Required | Insufficient credits | Top up your credit balance at cutoken.in/pricing. |
| 413 Payload Too Large | Prompt exceeds 2,000 characters | Chunk large prompts or contact us for enterprise limits. |
| 405 Method Not Allowed | Incorrect HTTP method | Use POST for optimization and GET for account balance. |
Integrate prompt compression into your production apps, agents, or internal tools in minutes.