Getting Started
This tutorial walks you through installing axm-smelt and compacting your first payload.
Prerequisites
- Python 3.12+
- uv (recommended) or pip
Installation
Or with pip:
Step 1: Compact from the CLI
Pipe a JSON payload through axm-smelt compact:
The compacted text is printed to stdout. Token savings are reported to stderr:
Use a preset for more aggressive compaction:
Step 2: Compact from Python
Python
from axm_smelt import smelt
data = '{\n "name": "Alice",\n "age": 30,\n "notes": null\n}'
report = smelt(data, preset="moderate")
print(report.compacted) # {"name":"Alice","age":30}
print(f"{report.savings_pct:.1f}% saved") # 50.0% saved
print(report.strategies_applied) # ['minify', 'drop_nulls']
Step 3: Analyze Token Waste
Use check to see what each strategy would save, without modifying the input:
Text Only
Format: json
Tokens: 42
Strategies applied: none
Strategy estimates:
minify: 18.2%
drop_nulls: 9.5%
flatten: 0.0%
Step 4: Count Tokens
Next Steps
- Compact Data — Full CLI and API options
- Use Strategies — Apply individual strategies
- Use Presets — Choose the right preset
- Strategy Catalog — Detailed strategy reference