PCTUTU.comBack to PCTUTU.com
GitHub projects
uzuUtilities
Category
Utilities
Publisher
trymirai
Repository
Open repository
Release
Open release
Current version
0.7.7
Release date
2026-12-01
Package size
macOS 54.3 MB
Utilities · trymirai

uzu

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:

Version 0.7.7
Available for macOS

README

Mirai

Discord Contact us Read docs License Build Python Package Python TypeScript Package Downloads Swift SPM Platforms Swift Kotlin

uzu

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:

  • Simple, high-level API
  • Unified model configurations, making it easy to add support for new models
  • Traceable computations to ensure correctness against the source-of-truth implementation
  • Utilizes unified memory on Apple devices
  • Broad model support

Quick Start

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.7

Run 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/[email protected]

Run 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 details on how to customize each step of the process.

Examples

You can run any example via cargo tools example <rust | python | swift | typescript | kotlin> <chat | chat-cloud | chat-shared-instance | chat-structured-output | quick-start | tool-calls | vision>:

Chat

In this example, we will download a model and get a reply to a specific list of messages:

Rust
use std::io::{self, Write};

use uzu::{
    engine
Publisher informationSoftware details and release files are provided by the publisher.