Skip to content

Documentation

M2M Protocol Documentation

Version 1.0 | GitHub | Hydra Model

Overview

M2M (Machine-to-Machine) Protocol is a token-optimized compression scheme for LLM API traffic. Unlike byte-oriented compression (gzip, brotli) that increases token count due to Base64 encoding, M2M achieves 25-40% token reduction through semantic compression.

Documentation Structure

Specification (spec/)

Formal protocol specification following IETF RFC conventions:

DocumentDescription
00-introduction.mdProtocol overview, goals, and scope
01-terminology.mdDefinitions and RFC 2119 requirement keywords
02-wire-format.mdBinary/text encoding specification
03-message-types.mdComplete message catalog
04-compression.mdCompression algorithms and mappings
05-session-management.mdSession lifecycle and state machine
06-security.mdSecurity model and threat mitigations

Guides (guides/)

Human-readable documentation for implementers:

DocumentDescription
quickstart.md5-minute getting started guide
proxy.mdOpenAI-compatible proxy server

Reference (reference/)

API and configuration reference:

DocumentDescription
error-codes.mdComplete error code reference
configuration.mdConfiguration options
abbreviations.mdKey/value abbreviation tables

Examples (examples/)

Working examples and test vectors:

DirectoryDescription
wire-format/Annotated wire format examples

Quick Reference

Wire Format Prefixes

AlgorithmPrefixUse Case
Token#T1|LLM API payloads (~30% savings)
Brotli#BR|Large content (>4KB)
None(passthrough)Small content (<100 bytes)

Compression Example

Original (68 bytes):
{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}
Compressed (45 bytes, 34% reduction):
#T1|{"M":"4o","m":[{"r":"u","c":"Hello"}]}

Version History

See CHANGELOG.md for version history.

License

Apache-2.0