Skip to content

AXM Logo

axm-smelt

Deterministic token compaction for LLM inputs.

CI axm-audit axm-init Coverage PyPI Python 3.12+


What it does

axm-smelt reduces token consumption through deterministic transformations. It detects formats, tries selected strategies and keeps only candidates with fewer tokens, or equal tokens and fewer characters. No LLM summarization is used.

Use the Python API or the three registered AXMTools: smelt, smelt_check, and smelt_count. The registry provides AXM CLI, MCP and DAG access.

Quick example

Python
import json
from axm_smelt import smelt

report = smelt('{\n  "name": "Alice",\n  "age": 30\n}')
assert json.loads(report.compacted) == {"name": "Alice", "age": 30}
print(report.compacted, report.savings_pct)

A token reduction does not prove that meaning is preserved. The default safe preset can alter XML whitespace, YAML inline comments and Markdown layout. Structural presets can change schema or produce text that is not JSON. Read strategy behavior before choosing a preset.

Find your way

Your question Start here
How do I make my first verified compaction? Getting Started
How do I compact, save or analyze a payload? How-to guides
What do functions, reports and tools accept/return? Contracts
How do I encode command-line arguments? CLI reference
Where is the supported Python API? Public API
Why was a candidate accepted or skipped? Architecture
How are inputs classified? Format detection

JSON, YAML, XML, TOML, CSV, Markdown and text are detected. Detection is broader than compaction support: TOML/CSV have no dedicated compactor. Token counts use tiktoken; Claude/unknown names resolve to an approximate o200k_base proxy in the counting API.