compress
Convert arbitrary JSON to a compact KTOF string and return size statistics.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data | Any | ✅ | JSON-serializable payload (prompts, tool data, structured metadata). |
options.delimiter | str | ❌ | Single-character separator used inside the encoded string. |
options.indent | int | ❌ | Pretty-print indentation applied during decode for readability. |
options.length_marker | bool | str | ❌ | Include payload length metadata; set to a custom marker string if needed. |
EncodeRequest.
Code example
Response example
Errors
400→ Invalid payload (e.g.,datamissing or not JSON-serializable).401→ Missing/invalid API key.413→ Payload too large for the current plan.
KaizenAPIError.
Notes
- Use
compressfor raw JSON blobs; preferprompts_encodewhen your payload follows the chat/messages format. - Include
metadatato correlate stats with downstream requests—Kaizen echoes it back unchanged.