v1
latestOpenAPI 3.1.0MIT2026-07-13174391.2 KBCompress chat history and code context by removing irrelevant lines at 33,000 tok/s. Every surviving line is byte-for-byte identical to the original input. Accepts string input or message arrays.
post/v1/compact
Request body
Example request
{
"input": "def hello():\n return 1\n\ndef unused():\n pass\n\ndef world():\n return 2",
"messages": [
{
"role": "user",
"content": "Help me build a Node.js API with JWT auth"
}
],
"query": "hello function",
"compression_ratio": 0.5,
"include_line_ranges": true,
"include_markers": true,
"model": "morph-compactor"
}Response
Compact response with compressed output and metadata
Example response
{
"id": "cmpr-7373faf8af65",
"object": "compact",
"model": "morph-compactor",
"output": "def hello():\n return 1\n(filtered 3 lines)\ndef world():\n return 2",
"messages": [
{
"role": "user",
"content": "def hello():\n return 1\n(filtered 3 lines)\ndef world():\n return 2",
"compacted_line_ranges": [
{
"start": 4,
"end": 6
}
]
}
],
"usage": {
"input_tokens": 101,
"output_tokens": 65,
"compression_ratio": 0.644,
"processing_time_ms": 109
}
}