llmtrim

v0.13.4
io.github.fkiene/llmtrim Checked 1 hour ago Published 2 months ago

MCP server and proxy that compresses LLM prompts, tool output, and replies to cut token cost.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

llmtrim_compress

Compress an LLM request body and report the token savings. Pass the raw request JSON; get back the compressed request in the same shape plus before/after token counts and the per-stage breakdown.

ParameterTypeDescription
request *The provider request body (OpenAI, Anthropic, or Google shape). Accepts either the JSON object itself or a JSON string of it; the whole body is compressed and returned in the same shape.
providerstring | nullProvider hint: `openai`, `anthropic`, or `google`. Leave unset to detect it from the request shape.

llmtrim_compress_text

Compress a single text blob and report the token savings. Use this to shrink one chunk (a tool output, a document) rather than a whole request. The text is wrapped in a minimal request, compressed, and the shrunk text is returned.

ParameterTypeDescription
text *stringA single text blob to shrink (a tool output, a document, a message). It is wrapped in a one-message request, compressed, and the shrunk text is returned.

llmtrim_stats

Report recent savings from the local ledger: tokens trimmed and dollars saved. The same headline figures the `llmtrim status --json` dashboard shows.