Codec docs
Codec is a token-native binary transport protocol for AI APIs. The six reference implementations ship matching APIs — pick your runtime and skip to the walkthrough.
Get started
A control-plane primitive for AI inference. Lets gateways, routers, agents, and tool dispatchers operate on raw token IDs end-to-end, with detokenization localized at the edges that need text.
90 seconds from "never seen Codec" to a streaming binary completion in your terminal.
The wire format in detail — frames, vocab handshake, transports, compression. Everything you need to write a fifth implementation.
Pick your runtime
The canonical reference implementation. Install, decode a stream, encode a request, watch for tool calls, translate across vocabs.
Async-first binding for Python 3.10+. Decode streams, encode IDs, watch tool calls, translate across vocabs.
ASP.NET / console-friendly binding. .NET 8+, IAsyncEnumerable streams, full nullability, AOT-friendly.
C99 reference implementation. CMake, single header, no dependencies, ABI-stable struct layout. For embedded clients and FFI bridges.
Native Rust crate. Sync iterators by default, async via the tokio feature. Hand-rolled protobuf, zero-cost token IDs, full sha256 map verification.
JDK 17+ binding. java.net.http.HttpClient, Iterator + Flow.Publisher streams, Jackson JSON, msgpack-java for frames. Maven-ready.
Source & spec
- github.com/wdunn001/Codec — protocol + six reference implementations
- github.com/wdunn001/codec-maps — pre-generated tokenizer dialect maps for common models (open to contributions)
- @codecai/maps-cli — generate a map for any model with a
tokenizer.json - PROTOCOL.md — the canonical wire spec
- RESULTS.md — live benchmark numbers