API Reference

All endpoints are prefixed with https://api.ziptoken.ai. Requests require Authorization: Bearer <key>.

POST/api/v1/compress

Compress a single text input. Returns the compressed text, token counts, savings ratio, and a quality score.

Request body

ParameterTypeRequiredDescription
textstringrequiredThe prompt text to compress. Max length depends on your plan.
modestringoptional"conservative" | "balanced" | "aggressive". Default: "balanced".
modelstringoptionalTarget LLM: "gpt-4o" | "claude-3-5" | "gemini". Used for tokenizer selection.
preserveCodebooleanoptionalKeep code blocks unchanged. Default: true.

Response

json
{
  "compressed":      "string β€” the compressed prompt",
  "originalTokens":  1024,
  "compressedTokens": 512,
  "savedTokens":     512,
  "ratio":           0.5,
  "qualityScore":    4,    // 1–5 scale
  "mode":            "balanced",
  "model":           "rule-based"
}
POST/api/v1/batch

Compress up to 100 texts in a single request. Available on Starter and above.

Request body

ParameterTypeRequiredDescription
textsstring[]requiredArray of prompt texts to compress. Max 100 items.
modestringoptionalApplied to all items. Default: "balanced".
preserveCodebooleanoptionalDefault: true.

Response

json
{
  "results": [
    {
      "compressed":      "...",
      "originalTokens":  200,
      "compressedTokens": 110,
      "savedTokens":     90,
      "ratio":           0.45,
      "qualityScore":    4
    }
  ],
  "totalSavedTokens": 900,
  "averageRatio":     0.45
}
GET/api/v1/usage

Retrieve token usage for the current billing period.

Response

json
{
  "plan":             "starter",
  "tokensUsed":       1_450_000,
  "tokensLimit":      2_000_000,
  "periodStart":      "2025-04-01T00:00:00Z",
  "periodEnd":        "2025-05-01T00:00:00Z",
  "resetAt":          "2025-05-01T00:00:00Z"
}

Error codes

StatusCodeMeaning
400invalid_requestMissing or malformed body.
401invalid_keyAPI key is missing or invalid.
402quota_exceededMonthly token quota reached. Upgrade or wait for reset.
413text_too_longInput exceeds the plan's max token limit.
429rate_limitToo many requests. Respect the Retry-After header.
500internal_errorSomething went wrong on our end. Retry with backoff.