A high-performance inference engine for AI models.
For more benchmarks details, see trymirai.com/metrics.
We designed our quantization format with the goal of maximising decode performance, and we deliberately traded off rate/distortion profile for hardware friendliness. Read how it works in the blog post, and find every Mirai checkpoint in our Hugging Face collections. Checkpoints are exported to the uzu format with lalamo.
Install the Mirai app together with mirai, the uzu command line tool, using Homebrew. It needs an Apple Silicon Mac with macOS 27 Golden Gate or newer:
brew install --cask miraiRun mirai to browse, download, and chat with models. Preselect a model with --model, passing its identifier or repository id:
mirai --model trymirai/Qwen3.8-27B-MIf the model is not downloaded yet, mirai starts downloading it automatically.
Server
mirai serverruns an OpenAI-compatible HTTP server:mirai server --model trymirai/Qwen3.8-27B-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--hostand--port:mirai server --model trymirai/Qwen3.8-27B-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. Honorstemperature,top_p,top_k,max_tokens, andseed. Requests without aseeduse the one passed with--seed, or a random one.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.8-27B-M", "messages": [{"role": "user", "content": "Hello!"}], "stream": true }'To send images to a model that accepts them, use an array for the user message’s
content. Include one{"type":"image_url","image_url":{"url":"..."}}part per image, with the image as a base64 data URL (data:image/jpeg;base64,...), followed by a{"type":"text","text":"What changed between these photos?"}part.When
--modelis a decision model, the server serves the TypeSafe System One API instead of chat completions:mirai server --model trymirai/d3-flash-MIt exposes the following endpoints, available both at the root and under
/v1:
POST /v1/systemone(or/v1/decisions) — answers questions about astatetext in one request.GET /v1/models— lists the loaded model.The request body has a
statestring and aquestionsobject that maps your question names to questions. Each question has atype, optionalinstructions, andcriteria:
choice— picks one option.criteriamaps 1 to 255 option names to their descriptions (ornull). The answer has the chosen name, a probability for each name, and a confidence.noul— yes or no.criteriais optional and may describe the answers as{"false": "...", "true": "..."}. The answernoulis the probability of yes.score— rates on a scale.criterialists 2 to 10 distinct levels from lowest to highest. The answerscoreis the expected level index, with a probability for each level index and alegendmapping indices to levels.curl http://127.0.0.1:8000/v1/systemone \ -H "Content-Type: application/json" \ -d '{ "state": "The headphones arrived a day early and sound amazing. The battery lasts all week, and I have already recommended them to two friends.", "questions": { "topic": { "type": "choice", "instructions": "What is this message about?", "criteria": { "praise": "Compliments about a product or service", "question": "Asks for information or help", "complaint": "Reports a problem" } }, "recommend": { "type": "noul", "instructions": "Would the customer recommend the product?" }, "satisfaction": { "type": "score", "instructions": "How satisfied is the customer?", "criteria": ["Unhappy", "Neutral", "Happy", "Delighted"] } } }'The response answers each question under its name (probabilities rounded here):
{ "model": "vllm-sr:d3-flash:9b:mirai:mirai-m:4", "answers": { "topic": { "type": "choice", "choice": "praise", "probabilities": {"praise": 0.9995, "question": 0.0001, "complaint": 0.0004}, "confidence": 0.9957 }, "recommend": { "type": "noul", "noul": 0.9987 }, "satisfaction": { "type": "score", "score": 2.8875, "probabilities": {"0": 0.0005, "1": 0.0015, "2": 0.1080, "3": 0.8900}, "confidence": 0.7420, "legend": {"0": "Unhappy", "1": "Neutral", "2": "Happy", "3": "Delighted"} } }, "usage": {"input_tokens": 374, "output_tokens": 0} }Compared to the TypeSafe API, the server is text only:
state,instructions, and criteria are strings, and there are noassetsorboxquestions.modelis optional and ignored, since the loaded model answers. Errors use the same OpenAI-style body as chat completions: an invalid question is rejected with status 400 and names it, for example"param": "questions.satisfaction".
Rust
Add the dependency:
[dependencies]
uzu = { git = "https://github.com/trymirai/uzu", branch = "main", package = "uzu" }Run the code below:
use std::io::{self, Write};
use uzu::{
engine::{Engine, EngineConfig},
types::session::chat::{ChatConfig, ChatMessage, ChatReplyConfig},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let engine_config = EngineConfig::default();
let engine = Engine::new(engine_config).await?;
let model = engine.model("trymirai/Qwen3.5-0.8B-M".to_string()).await?.ok_or("Model not found")?;
let downloader = engine.download(&model).await?;
while let Some(update) = downloader.next().await {
print!("\r\u{001B}[2KDownload progress: {:.2}%", update.progress() * 100.0);
io::stdout().flush()?;
}
println!();
let session = engine.chat(model, ChatConfig::default()).await?;
let messages = vec![
ChatMessage::system().with_text("You are a helpful assistant".to_string()),
ChatMessage::user().with_text("Tell me a short, funny story about a robot".to_string()),
];
let replies = session.reply(messages, ChatReplyConfig::default()).await?;
if let Some(reply) = replies.last() {
println!("Reasoning: {}", reply.message.reasoning().unwrap_or_default());
println!("Text: {}", reply.message.text().unwrap_or_default());
}
Ok(())
}Python
Add the dependency:
uv add uzu==0.7.7Run the code below:
import asyncio
from uzu import ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig
async def main() -> None:
engine_config = EngineConfig.create()
engine = await Engine.create(engine_config)
model = await engine.model("trymirai/Qwen3.5-0.8B-M")
if model is None:
return
async for update in (await engine.download(model)).iterator():
print(f"\rDownload progress: {update.progress:.2%}", end="", flush=True)
print()
session = await engine.chat(model, ChatConfig.create())
messages = [
ChatMessage.system().with_text("You are a helpful assistant"),
ChatMessage.user().with_text("Tell me a short, funny story about a robot"),
]
replies = await session.reply(messages, ChatReplyConfig.create())
if not replies:
return
message = replies[-1].message
print(f"Reasoning: {message.reasoning}")
print(f"Text: {message.text}")
if __name__ == "__main__":
asyncio.run(main())Swift
Add the dependency:
dependencies: [
.package(url: "https://github.com/trymirai/uzu.git", from: "0.7.7")
]Run the code below:
import Foundation
import Uzu
public func runQuickStart() async throws {
let engineConfig = EngineConfig.create()
let engine = try await Engine.create(config: engineConfig)
guard let model = try await engine.model(identifier: "trymirai/Qwen3.5-0.8B-M") else {
return
}
for try await update in try await engine.download(model: model).iterator() {
print(String(format: "\r\u{001B}[2KDownload progress: %.2f%%", update.progress() * 100), terminator: "")
fflush(stdout)
}
print()
let session = try await engine.chat(model: model, config: .create())
let messages = [
ChatMessage.system().withText(text: "You are a helpful assistant"),
ChatMessage.user().withText(text: "Tell me a short, funny story about a robot")
]
let reply = try await session.reply(input: messages, config: .create())
guard let message = reply.last?.message else {
return
}
print("Reasoning: \(message.reasoning() ?? "empty")")
print("Text: \(message.text() ?? "empty")")
}TypeScript
Add the dependency:
pnpm add @trymirai/uzu@0.7.7Run the code below:
import { ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig } from '@trymirai/uzu';
async function main() {
let engineConfig = EngineConfig.create();
let engine = await Engine.create(engineConfig);
let model = await engine.model('trymirai/Qwen3.5-0.8B-M');
if (!model) {
throw new Error('Model not found');
}
for await (const update of await engine.download(model)) {
process.stdout.write(`\rDownload progress: ${(update.progress * 100).toFixed(2)}%`);
}
console.log();
let session = await engine.chat(model, ChatConfig.create());
let messages = [
ChatMessage.system().withText('You are a helpful assistant'),
ChatMessage.user().withText('Tell me a short, funny story about a robot')
];
let reply = await session.reply(messages, ChatReplyConfig.create());
let message = reply[0]?.message;
if (message) {
console.log('Reasoning: ', message.reasoning);
console.log('Text: ', message.text);
}
}
main().catch((error) => {
console.error(error);
});Kotlin
Add the dependency:
// settings.gradle.kts
includeBuild("<uzu checkout>/crates/legacy/uzu/bindings/kotlin")
// build.gradle.kts
dependencies {
implementation("com.trymirai:uzu")
}Build the engine for your machine first with cargo tools build kotlin in the uzu checkout. It runs on macOS (Apple
silicon, Metal), Linux and Windows (x86-64, Vulkan), and Android (below); the Vulkan requirements are in the
CLI section of the main README. The structured output example also uses
org.json:json.
On Windows, use a JDK whose bundled C++ runtime (bin\msvcp140.dll) is 14.40 or newer, such as Eclipse Temurin 27:
GPU drivers crash with an older one, like the 14.29 runtime of Android Studio's JDK.
An application on JDK 27 needs two settings: Kotlin 2.4 targets JVM 26 at most, so Java's target must match it, and JNA loads the engine library, which the JDK warns about unless native access is enabled:
// build.gradle.kts
java { targetCompatibility = JavaVersion.toVersion(26) }
application {
applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
}On Android, build the engine for arm64 with cargo tools build kotlin --targets android, which needs the Android NDK
and cargo-ndk (cargo tools install kotlin). The bindings come from the last target built, so this replaces the
desktop build. The app's Gradle settings also need the repository of rustls-platform-verifier, which checks the
engine's HTTPS certificates:
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://github.com/rustls/rustls-platform-verifier/raw/maven-archive/android-release-support/maven/") {
content {
includeGroup("org.rustls")
}
}
}
}
// app/build.gradle.kts
android {
defaultConfig {
// The engine is built for arm64 only; without this filter the app also installs on other ABIs and fails at
// launch.
ndk { abiFilters += "arm64-v8a" }
}
}Set minSdk = 31 and run on an arm64 device with Vulkan 1.3. An androidx.startup initializer merged into the app's
manifest sets the SDK up when the app's main process starts, so use the SDK from that process. It stores models in the
app's no-backup files directory. apps/playground-android
is a complete app.
Run the code below:
package com.trymirai.uzu.examples
import com.trymirai.uzu.Engine
import com.trymirai.uzu.EngineConfig
import com.trymirai.uzu.asFlow
import com.trymirai.uzu.create
import com.trymirai.uzu.shoji.ChatConfig
import com.trymirai.uzu.shoji.ChatMessage
import com.trymirai.uzu.shoji.ChatReplyConfig
import com.trymirai.uzu.system
import com.trymirai.uzu.user
suspend fun runQuickStart() {
val engine = Engine.create(EngineConfig.create())
val model = checkNotNull(engine.model("trymirai/Qwen3.5-0.8B-M")) { "Model not found" }
engine.download(model).asFlow().collect { update ->
println("Download progress: %.2f%%".format(update.progress() * 100))
}
val session = engine.chat(model, ChatConfig.create())
val messages = listOf(
ChatMessage.system().withText("You are a helpful assistant"),
ChatMessage.user().withText("Tell me a short, funny story about a robot"),
)
val message = checkNotNull(session.reply(messages, ChatReplyConfig.create()).lastOrNull()?.message) {
"Reply is empty"
}
println("Reasoning: ${message.reasoning() ?: "empty"}")
println("Text: ${message.text() ?: "empty"}")
}Everything from model downloading to inference configuration is handled automatically. Refer to the documentation for more examples and details on how to customize each step of the process.
uzu is a Rust crate with bindings for Swift and Kotlin (uniffi-rs), Python (pyo3) and TypeScript (napi-rs). It runs on Metal, Vulkan (experimental) and CPU.
cargo tools covers setup, builds, tests and examples for every language:
cargo tools setup # rustup, uv, pnpm, Rust targets, Metal toolchain, ...
cargo tools install typescript # language-specific dependencies
cargo tools build rust --targets apple
cargo tools test python
cargo tools example swift chat
cargo run --release -p cli # the CLI from source, same arguments as miraiVulkan on Linux and Windows
The Vulkan backend does not yet match the quality and stability of the Metal backend. It needs:
- the Vulkan SDK through
VULKAN_SDK, or Slang 2026.17 or newer throughSLANG_DIR, orSLANG_INCLUDE_DIRandSLANG_LIB_DIR - libclang, which Windows finds through
LIBCLANG_PATH - a Vulkan 1.3 driver: a GPU's, or Mesa's lavapipe, which runs Vulkan on the CPU
VK_LAYER_KHRONOS_validation(part of the SDK) for the library tests
On Linux, nix develop provides everything but the GPU driver.
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.





