用于 AI 模型的高性能推理引擎
A high-performance inference engine for AI models. It allows you to deploy AI directly in your app with zero latency, full data privacy, and no inference costs. Key features:
Add the dependency:
[dependencies]
uzu = { git = "https://github.com/trymirai/uzu", branch = "main", package = "uzu" }Run the code below:
…Add the dependency:
uv add uzu==0.5.27Run the code below:
…Add the dependency:
dependencies: [
.package(url: "https://github.com/trymirai/uzu.git", from: "0.5.27")
]Run the code below:
…Add the dependency:
pnpm add @trymirai/[email protected]Run the code below:
…Everything from model downloading to inference configuration is handled automatically. Refer to the documentation for details on how to customize each step of the process.
You can run any example via cargo tools example <rust | python | swift | typescript> <chat | chat-cloud | chat-shared-instance | chat-structured-output | quick-start | tool-calls>:
In this example, we will download a model and get a reply to a specific list of messages:
Rust…………
Once loaded, the same ChatSession can be reused for multiple requests until you drop it. Each model may consume a significant amount of RAM, so it's important to keep only one session loaded at a time. For iOS apps, we recommend adding the Increased Memory Capability entitlement to ensure your app can allocate the required memory.
In this example, we will get a reply to a specific list of messages from a cloud model:
Rust…………This example shows how to reuse chat instance without reloading model into memory:
Rust…………Sometimes you want the generated output to be valid JSON with predefined fields. You can use Grammar to manually specify a JSON schema for the response you want to receive:
…………This example shows how to use external tools:
Rust…………uzu is a native Rust crate with bindings available for:
It supports:
metalcpuaarch64-apple-darwinaarch64-apple-iosaarch64-apple-ios-simaarch64-pc-windows-msvc (in progress)aarch64-unknown-linux-gnu (in progress)wasm32-wasip1-threads (in progress)x86_64-apple-darwinx86_64-pc-windows-msvc (in progress)x86_64-unknown-linux-gnu (in progress)cargo tools setup, which installs all necessary dependencies (rustup, uv, pnpm, Rust targets, Metal toolchain, ...) if not already present.cargo tools:cargo tools install typescriptcargo tools build rust --targets applecargo tools test pythoncargo tools example swift chatuzu uses its own model format. You can export a model yourself with lalamo:
git clone https://github.com/trymirai/lalamo.git
cd lalamo
uv run lalamo list-models
uv run lalamo convert meta-llama/Llama-3.2-1B-InstructYou can run uzu in CLI mode:
cargo run --release -p cliThis launches an interactive app where you can browse, download, and interact with models.
You can also preselect a model with --model, passing its identifier or repository id:
cargo run --release -p cli -- --model trymirai/Qwen3.5-4B-MIf the model is not downloaded yet, the CLI starts downloading it automatically.
To run benchmarks, pass a downloaded model path, a benchmark task file, and an output path:
cargo run --release -p cli -- bench {MODEL_PATH} {TASK_PATH} {OUTPUT_PATH}You can also run uzu as an OpenAI-compatible HTTP server:
cargo run --release -p cli -- server --model trymirai/Qwen3.5-4B-MThe model is loaded on startup (and downloaded first if needed). By default the server listens on 127.0.0.1:8000; override the address with --host and --port:
cargo run --release -p cli -- server --model trymirai/Qwen3.5-4B-M --host 0.0.0.0 --port 8080It exposes the following endpoints, available both at the root and under /v1:
POST /v1/chat/completions — chat completions, with streaming when "stream": true. Honors temperature, top_p, top_k, and max_tokens.GET /v1/models — lists the loaded model.curl http://127.0.0.1:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "trymirai/Qwen3.5-4B-M",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'If you experience any problems, please contact us via Discord or email.
This project is licensed under the MIT License. See the LICENSE file for details.
暂无开放 Issues,或尚未同步最近议题。