Compact context
Changed onCompress 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.
Request
- Base URLhttps://api.morphllm.com
- AuthHTTP bearer
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,
"preserve_recent": 0,
"compress_system_messages": false,
"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
}
],
"kept_line_ranges": []
}
],
"usage": {
"input_tokens": 101,
"output_tokens": 65,
"compression_ratio": 0.644,
"processing_time_ms": 109
}
}Changes
- warning
removed the optional property
/from the response with the status - warning
removed the optional property
/from the response with the status - info
api operation id
createCompactionwas added - info
the endpoint scheme security
bearerAuthwas added to the API - info
api tag
compactadded - info
added the non-success response with the status
- info
added the non-success response with the status
- info
removed the non-success response with the status
- info
removed the non-success response with the status
- info
the response property
/became required for the status - info
the response property
/became required for the status - info
the response property
/became required for the status - info
the response property
/became required for the status - info
the response property
////became required for the status - info
the response property
////became required for the status - info
the response property
//became required for the status - info
the response property
////became required for the status - info
the response property
////became required for the status - info
the response property
//became required for the status - info
the response property
/became required for the status - info
the response property
/became required for the status - info
the response property
/became required for the status - info
the response property
/became required for the status
- warning