🔑

Authentication

Authenticate all requests by passing your API Key in the Authorization header using the Bearer scheme.

Authorization: Bearer ct_live_xxxxxxxxxxxxxxxx

Get your key from your Pro Dashboard.

🌐

Base URL & Content

All requests should be sent over HTTPS. Send JSON payloads with standard headers:

https://pro.cutoken.in/api
Content-Type: application/json

CORS is enabled (*) for direct web, extension, or agent calls.

Credits & Quota

1 credit = 2,000 characters. Credits are shared seamlessly across API, Terminal CLI, Chrome Extension, and Web.

Credit Balance: Real-time deduction
Max payload: 2,000 chars / request

API ENDPOINTS

Core endpoints to manage credits and optimize prompts.

POST /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.

REQUEST HEADERS

Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json

REQUEST BODY (JSON)

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.

CODE EXAMPLES

cURL
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"
  }'
Python (requests)
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"])
Node.js (fetch)
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);
Response (200 OK)
{
  "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
}
GET /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
curl -X GET https://pro.cutoken.in/api/me.php \
  -H "Authorization: Bearer ct_live_your_key_here"
Response (200 OK)
{
  "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
}

HTTP STATUS CODES

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.

START BUILDING WITH CUTOKEN API

Integrate prompt compression into your production apps, agents, or internal tools in minutes.