Skip to content
hanzoaiPublic

About

Hanzo AI native inference engine - Rust-based LLM & embedding engine for foundational models

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

0 watching

Forks

Latest commit

 

History

5,665 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hanzo Engine

Hanzo Engine

Open in Hanzo Edit with Hanzo Deploy with Hanzo

The native, multimodal inference engine — text, vision, audio, speech, image, and embeddings in one fast Rust binary.

| Documentation | Rust SDK | Python SDK | Discord |

GitHub stars

Hanzo Engine runs any Hugging Face model with zero config, quantizes it for your hardware, and serves it over the OpenAI and Anthropic wire formats plus a built-in web UI — one binary, from your laptop to a GPU cluster. It is the native inference layer of the Open AI Cloud.

Latest

  • Multi-backend GPU stack (CUDA · Metal · ROCm · Vulkan): native acceleration on NVIDIA (incl. Blackwell sm_121 / GB10 & CUDA 13.x), Apple Silicon Metal (plus iOS FFI), AMD ROCm 7.1, and Vulkan Wave64 via hanzoai/ml and the hanzo-kernel portable GPU DSL.
  • Extreme quantization — Bonsai-2, NVFP4, MXFP4 & KIVI KV cache: native 1-bit/ternary Bonsai-2 (PQ2_0, PTQ1_0, Q1_0, Q2_0) with fused RMSNorm-FWHT-IqQ8, register-resident NVFP4 E2M1 GEMM, MXFP4 ISQ, and KIVI 2-bit/4-bit asymmetric KV cache quantization (hanzo-paged-attn). Quantization docs
  • Adaptive speculative decoding & fast tokenization: DFlash2 + built-in MTP + O(1) Suffix Automaton (SA_SPEC) draft bypass + GuardedDraft acceptance cooldowns, paired with pure-Rust SWAR tokenization (hanzo-tokenizer) and a self-bypassing PromptTokenCache.
  • KV cache fabric & intelligent routing: hanzo-kv-fabric (non-prefix RAG CacheBlend composition, S-LoRA multi-tenant adapter paging, disk-first cross-restart KV persistence) and hanzo-router (Bidaw KV-residency-aware scheduling + per-org prefix cache salting).
  • Frontier & omni-modal models: Hunyuan v1 (Dense & MoE), Zen-6, DeepSeek-V4 / V3.2, GLM-5 MoE, MiniMax-M2, Qwen3-Omni (text/image/video/audio in → text + 24kHz speech out), Qwen3.5, Gemma 4, and Kimi-K2. Supported models
  • Anthropic Messages, OpenAI & Active Inference Worlds APIs: hanzo-engine serve exposes OpenAI /v1 (Chat, Responses, Embeddings, Audio, Images), Anthropic POST /v1/messages (streaming, tool use, Claude Code), and hanzo-worlds /v1/worlds/{world}/inference from one binary. Examples
  • Hardened agentic runtime: sandboxed local Python execution (hanzo-sandbox, hanzo-code-exec), MCP integration (hanzo-llm-mcp), SSRF-guarded remote fetch (remote_fetch blocking private/NAT64/6to4/link-local ranges across media, video, and web search), bounded GIF/audio decoding, and validated web-UI session paths. Guide

Why Hanzo Engine?

  • Any Hugging Face model, zero config: Just hanzo-engine run -m user/model. Architecture, quantization format, and chat template are auto-detected.
  • True multimodality: Text, vision, video, and audio, speech generation, image generation, and embeddings in one engine.
  • Smart quantization: --quant automatically selects the best quantization format at that level: using a prebuilt UQFF if one is published, otherwise applying ISQ. Docs
  • OpenAI + Anthropic wire formats: The same hanzo-engine serve process exposes OpenAI-compatible /v1 endpoints and an Anthropic-compatible Messages endpoint.
  • Built-in web UI: Served at /ui by default. Shows reasoning, code execution, plots, and files inline. Edit any message and the new branch runs with its own Python state. Pass --no-ui to disable.
  • Hardware-aware: hanzo-engine tune benchmarks your system and picks optimal quantization + device mapping.
  • Flexible SDKs: Python package and Rust crate to build your projects.
  • Native agentic support: built-in agentic loop with web search, local Python code execution with model feedback, session management, and custom tool hooks.

Quick Start

Quick install

npm i -g hanzo                    # any OS; or, on macOS/Linux: curl -fsSL https://hanzo.sh | sh
hanzo engine serve <model>        # e.g. hanzo engine serve zenlm/zen-nano-0.6b

npm i -g hanzo installs the Hanzo CLI launcher; the first hanzo engine fetches the prebuilt hanzo-engine binary (linux amd64/arm64, macOS) and checks its SHA-256. For a CUDA or ROCm build, or any other feature set, build from source as below.

Binaries

This repository builds two programs, and neither is called hanzo:

binary crate how to get it
hanzoai hanzo-server prebuilt, attached to each release
hanzo-engine hanzo-cli prebuilt, fetched by hanzo engine on first use; or built from source by install.sh

The hanzo on your PATH is the Hanzo CLI; its hanzo engine serve MODEL runs hanzo-engine serve -m MODEL. hanzoai logs a deprecation warning that names hanzo serve from hanzo-cli, which is the hanzo-engine binary.

Each release attaches hanzoai-macos-arm64.tar.gz and hanzoai-macos-amd64.tar.gz (Metal), and hanzoai-linux-amd64.tar.gz and hanzoai-linux-arm64.tar.gz (CPU only, with cosign .sig and .pem). Each tarball holds the one hanzoai binary.

install.sh needs Rust 1.88 or newer. It runs cargo install --git https://github.com/hanzoai/engine --locked hanzo-cli with the features it detects, which puts hanzo-engine in ~/.cargo/bin:

curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/hanzoai/engine/main/install.sh | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/hanzoai/engine/main/install.ps1 | iex

Manual installation & other platforms

Serve a model

curl -L https://github.com/hanzoai/engine/releases/latest/download/hanzoai-macos-arm64.tar.gz | tar xz
./hanzoai --serve-ip 127.0.0.1 --port 1234 run -m zenlm/zen-nano-0.6b

From another shell:

curl 127.0.0.1:1234/v1/models

hanzoai has no default port: give it --port, or -i for an interactive session. --serve-ip defaults to 0.0.0.0, every interface. OpenAI-compatible clients use http://127.0.0.1:1234/v1.

hanzo-engine serve -m <model> listens on 0.0.0.0:1234 unless given -p and --host, serves a web UI at /ui, and advertises itself over mDNS unless given --no-advertise. hanzo-engine tune -m <model> --emit-config config.toml recommends a quantization and device map for the machine, and hanzo-engine from-config -f config.toml runs it.

Chat and embeddings on one port

multi-model serves several models on one port, and each request names one by alias. With this models.json:

{
  "chat": { "alias": "chat", "Plain": { "model_id": "zenlm/zen-nano-0.6b" } },
  "embed": { "alias": "embed", "Embedding": { "model_id": "zenlm/zen-embedding-0.6B" } }
}
./hanzoai --serve-ip 127.0.0.1 --port 1234 multi-model --config models.json
curl 127.0.0.1:1234/v1/embeddings -H 'Content-Type: application/json' \
  -d '{"model":"embed","input":"hello"}'
curl 127.0.0.1:1234/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"chat","messages":[{"role":"user","content":"hello"}]}'

Verify Zen Nano locally

Run the smoke test against the CLI server for OpenAI chat, Anthropic Messages streaming, model discovery and the web UI. Start a second instance with the Zen embedding model for the embeddings check. These commands force CPU inference and keep both servers on loopback.

cargo build --locked -p hanzo-cli
target/debug/hanzo-engine serve --host 127.0.0.1 -p 1234 --no-advertise \
  --served-model-name zen-nano -m zenlm/zen-nano-0.6b --cpu --dtype f32

With the Hanzo CLI installed, you can pull and serve the chat model by alias:

hanzo pull zen-nano
HANZO_ENGINE_BIN="$PWD/target/debug/hanzo-engine" hanzo engine serve zen-nano -- \
  --host 127.0.0.1 -p 1234 --no-advertise --served-model-name zen-nano --cpu --dtype f32

If the native downloader reports UnknownIssuer behind a proxy with a trusted system CA, install the Hugging Face CLI. hanzo pull uses hf when it is on PATH.

In a second terminal:

target/debug/hanzo-engine serve --host 127.0.0.1 -p 1235 --no-advertise --no-ui \
  --served-model-name zenlm/zen-embedding-0.6B embedding -m zenlm/zen-embedding-0.6B --cpu --dtype f32

Once both servers are listening, run:

python3 scripts/smoke_zen_nano.py

The script checks the UI entry page, its JavaScript bundle and the capabilities route. For the browser step, open http://127.0.0.1:1234/ui, select zen-nano and send a short message. Confirm that the assistant reply renders.

The first run downloads the model weights. If the weights are already on disk, pass each model directory to -m and keep the --served-model-name values shown above. The script also accepts custom loopback ports and model IDs with --help listing the options.

Memory

Weights take about their file size in memory. Weight files of Zen models in GB (10^9 bytes), as the Hugging Face API lists them (/api/models/<repo>?blobs=true). The 16-bit column is the safetensors release; Q8_0 and Q4_K_M are GGUF files, from the -GGUF repos for the embedding models.

model parameters 16-bit Q8_0 Q4_K_M
zenlm/zen-nano-0.6b 0.60 B 1.19 0.64 0.40
zenlm/zen-embedding-0.6B 0.60 B 1.19 0.64
zenlm/zen-eco-4b-instruct 4.02 B 8.04
zenlm/zen-embedding-8B 7.57 B 15.13 4.68
zenlm/zen-vl-8b-instruct 8.77 B 17.53

That is about 2.0 GB per billion parameters at 16 bits, 1.07 GB at Q8_0 and 0.62 GB at Q4_K_M, so a 14B model needs roughly 28, 15 or 8.7 GB for weights. hanzoai --isq q8_0 or --isq q4k quantizes a 16-bit model as it loads.

The KV cache comes on top: 2 × layers × KV heads × head dim × 2 bytes per token at 16 bits. With the values in each config.json, zen-nano-0.6b (28 × 8 × 128) takes 0.11 MB per token and zen-eco-4b-instruct (36 × 8 × 128) 0.15 MB, so a 32,768-token context adds 3.8 or 4.8 GB. The automatic device map plans for --max-seq-len, 4096 tokens unless set.

Measured on a 64 GB M1 Max with vmmap -summary: zen-nano-0.6b at 16 bits served with a 2.0 GB physical footprint, and 3.6 GB with zen-embedding-0.6B loaded beside it.

On Apple Silicon the GPU budget is the larger of Metal's recommended working set and 2/3 of RAM (3/4 above 36 GB), or sysctl iogpu.wired_limit_mb when that is set (hanzo-engine/src/utils/memory_usage.rs). For the 64 GB M1 Max above the device map reported 52 GB. On a 24 GB Mac the budget starts at 16 GB, about what a 14B model at Q8_0 needs for weights alone.

Full CLI documentation

UI Demo
Web Chat UI Demo

What Makes It Fast

Performance

Quantization (full docs)

  • In-situ quantization (ISQ) of any Hugging Face model
  • GGUF (2-8 bit), GPTQ, AWQ, HQQ, FP8, BNB support
  • ⭐ Per-layer topology: Fine-tune quantization per layer for optimal quality/speed
  • ⭐ Auto-select fastest quant method for your hardware

Flexibility

Agentic Features

Full feature documentation

Supported Models

Text Models
  • Granite 4.0
  • SmolLM 3
  • DeepSeek V3
  • GPT-OSS
  • DeepSeek V2
  • Qwen 3 Next
  • Qwen 3 MoE
  • Phi 3.5 MoE
  • Qwen 3
  • GLM 4
  • GLM-4.7-Flash
  • GLM-4.7 (MoE)
  • Gemma 2
  • Qwen 2
  • Starcoder 2
  • Phi 3
  • Mixtral
  • Phi 2
  • Gemma
  • Llama
  • Mistral
Multimodal Models
  • Qwen 3.5
  • Qwen 3.5 MoE
  • Qwen 3-VL
  • Qwen 3-VL MoE
  • Gemma 3n
  • Llama 4
  • Gemma 3
  • Mistral 3
  • Phi 4 multimodal
  • Qwen 2.5-VL
  • MiniCPM-O
  • Llama 3.2 Vision
  • Qwen 2-VL
  • Idefics 3
  • Idefics 2
  • LLaVA Next
  • LLaVA
  • Phi 3V
Speech Models
  • Voxtral (ASR/speech-to-text)
  • Dia
Image Generation Models
  • FLUX
Embedding Models
  • Embedding Gemma
  • Qwen 3 Embedding

Request a new model | Full compatibility tables

Python SDK

pip install hanzo  # or hanzo-cuda, hanzo-metal, hanzo-mkl, hanzo-accelerate
from hanzo import Runner, Which, ChatCompletionRequest

runner = Runner(
    which=Which.Plain(model_id="Qwen/Qwen3-4B"),
    in_situ_quant="4",
)

res = runner.send_chat_completion_request(
    ChatCompletionRequest(
        model="default",
        messages=[{"role": "user", "content": "Hello!"}],
        max_tokens=256,
    )
)
print(res.choices[0].message.content)

Python SDK | Installation | Examples | Cookbook

Rust SDK

cargo add hanzo
use anyhow::Result;
use hanzo::{IsqType, TextMessageRole, TextMessages, MultimodalModelBuilder};

#[tokio::main]
async fn main() -> Result<()> {
    let model = MultimodalModelBuilder::new("google/gemma-4-E4B-it")
        .with_isq(IsqType::Q4K)
        .with_logging()
        .build()
        .await?;

    let messages = TextMessages::new().add_message(
        TextMessageRole::User,
        "Hello!",
    );

    let response = model.send_chat_request(messages).await?;

    println!("{:?}", response.choices[0].message.content);

    Ok(())
}

API Docs | Crate | Examples

Docker

For quick containerized deployment:

docker pull ghcr.io/hanzoai/engine:latest
docker run --gpus all -p 1234:1234 ghcr.io/hanzoai/engine:latest \
  serve -m Qwen/Qwen3-4B

Docker images

For production use, we recommend installing the CLI directly for maximum flexibility.

Documentation

For complete documentation, see the Documentation.

Quick Links:

Contributing

Contributions welcome! Please open an issue to discuss new features or report bugs. If you want to add a new model, please contact us via an issue and we can coordinate.

Credits

Tensors, kernels, and autodiff come from hanzoai/ml, the Rust compute core underneath this engine. Thank you to all contributors.

Hanzo Engine is MIT licensed. LICENSE carries the full text and every copyright line it names; NOTICE carries the Apache-2.0 attributions that ship with the vendored GPU kernels, and both travel with any binary or crate we distribute.

Hanzo — the Open AI Cloud

Open source · every language · on-chain settlement. hanzo.ai · docs.hanzo.ai

SDKs in every language — Python (flagship) · TypeScript · Go · Rust · C++ · Swift · Kotlin · umbrella

About

Hanzo AI native inference engine - Rust-based LLM & embedding engine for foundational models

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages