Back to Runanywhere Sdks

README

README.md

0.20.1227.9 KB
Original Source
<p align="center"> </p> <h1 align="center">RunAnywhere</h1> <p align="center"> <strong>One SDK. Every device.</strong>

LLMs, vision, speech, voice agents, RAG, embeddings, and image generation, running locally on phones, browsers, desktops, and servers.

Private by default. Offline by design. Accelerated by whatever silicon the device has.

</p> <p align="center"> <a href="https://apps.apple.com/us/app/runanywhere/id6756506307"></a>&nbsp;&nbsp;<a href="https://play.google.com/store/apps/details?id=com.runanywhere.runanywhereai"></a> </p> <p align="center"> <a href="https://github.com/RunanywhereAI/runanywhere-sdks/stargazers"></a> <a href="LICENSE"></a> <a href="https://docs.runanywhere.ai"></a> <a href="https://huggingface.co/runanywhere/models"></a> <a href="https://discord.gg/N359FBbDVd"></a> </p> <p align="center"> </p> <p align="center"> <sub>Eight SDKs, one C++ core. A capability registry routes every call to the best engine on the device, and the Console manages your fleet from above.</sub> </p>

What you can build

Every capability below runs fully on-device, behind one API that is identical on all eight platforms:

  • LLM chat: Llama, Qwen, Gemma, Phi, LFM, SmolLM, DeepSeek, and more, with token streaming, multi-turn history, and LoRA adapters
  • Structured output: JSON constrained by a grammar compiled from your schema, so the result always parses
  • Tool calling: grammar-constrained tool calls, parallel calls, and an agent loop
  • Vision (VLM): image understanding, live camera description, and photo Q&A
  • Speech-to-Text: Whisper and Moonshine transcription, streaming and batch
  • Text-to-Speech: neural voices from Piper, Kokoro, Kitten, MeloTTS, and Magpie
  • Voice agents: wake word, VAD, STT, LLM, and TTS in one pipeline, with sentence-streaming playback
  • Embeddings: L2-normalized vectors for search and retrieval
  • RAG: local document ingestion and retrieval-augmented answers, with streaming
  • Image generation: Stable Diffusion on Core ML, plus inpainting on the Hexagon NPU

Your code never picks hardware. Engines register what they can run, and the highest-priority engine that fits the device wins: QHexRT on the Snapdragon Hexagon NPU, MLX on Apple silicon, llama.cpp everywhere (Metal on Apple, CUDA on NVIDIA as an opt-in build, WebGPU in the browser), sherpa + ONNX for speech and embeddings, and Core ML for diffusion, dispatching across CPU, GPU, and the Apple Neural Engine.


Quick start

The fastest way to feel it. Install, load, generate, all local:

bash
pip install runanywhere
python
from runanywhere import RunAnywhere

with RunAnywhere() as ra:
    llm = ra.load_llm("qwen2.5-0.5b")  # downloads on first use
    print(llm.generate_text("Explain on-device AI in one sentence."))

Prefer a terminal? The same core ships as a CLI:

bash
brew install runanywhere-ai/tap/rcli
rcli run qwen3 "Explain on-device AI in one sentence."

Building for mobile, web, or desktop? Every platform below speaks the same API.

<details> <summary><b>Swift</b> (iOS / macOS)</summary>
swift
import RunAnywhere
import LlamaCPPRuntime

// 1. Initialize
LlamaCPP.register()
try RunAnywhere.initialize()

// 2. Load a model
var load = RAModelLoadRequest()
load.modelID = "smollm2-360m"
load.category = .language
load.framework = .llamaCpp
_ = await RunAnywhere.loadModel(load)

// 3. Generate
var req = RALLMGenerateRequest()
req.prompt = "What is the capital of France?"
let result = try await RunAnywhere.generate(req)
print(result.text) // "Paris is the capital of France."

Add the MLX backend (import RunAnywhereMLX; MLX.register()) for Apple-native LLM, VLM, STT, TTS, and embeddings on Apple silicon.

Install via Swift Package Manager:

https://github.com/RunanywhereAI/runanywhere-sdks

Documentation · Source

</details> <details> <summary><b>Kotlin</b> (Android)</summary>
kotlin
import ai.runanywhere.proto.v1.ModelCategory
import ai.runanywhere.proto.v1.SDKEnvironment
import com.runanywhere.sdk.llm.llamacpp.LlamaCPP
import com.runanywhere.sdk.public.RunAnywhere
import com.runanywhere.sdk.public.extensions.*
import com.runanywhere.sdk.public.types.RAModelInfo
import com.runanywhere.sdk.public.types.RAModelLoadRequest

// 1. Initialize (in a coroutine scope)
LlamaCPP.register()
RunAnywhere.initialize(
    context = this,
    environment = SDKEnvironment.SDK_ENVIRONMENT_DEVELOPMENT,
)

// 2. Download and load a model
val modelId = "smollm2-360m-instruct-q8_0"
RunAnywhere.downloadModelStream(RAModelInfo(id = modelId)).collect { /* progress */ }
RunAnywhere.loadModel(
    RAModelLoadRequest(model_id = modelId, category = ModelCategory.MODEL_CATEGORY_LANGUAGE),
)

// 3. Generate
val result = RunAnywhere.generate("What is the capital of France?")
println(result.text) // "Paris is the capital of France."

Install via Gradle (Maven Central):

kotlin
dependencies {
    implementation("io.github.sanchitmonga22:runanywhere-sdk:0.20.11")
    implementation("io.github.sanchitmonga22:runanywhere-llamacpp:0.20.11")
    // Optional: STT / TTS / VAD
    // implementation("io.github.sanchitmonga22:runanywhere-onnx:0.20.11")
}

Documentation · Source

</details> <details> <summary><b>Flutter</b></summary>
dart
import 'package:runanywhere/runanywhere.dart';
import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart';

// 1. Initialize
LlamaCpp.register();
await RunAnywhere.initialize();

// 2. Download and load a model
await RunAnywhere.downloadModel('smollm2-360m');
await RunAnywhere.llm.load('smollm2-360m');

// 3. Generate
final response = await RunAnywhere.llm.chat('What is the capital of France?');
print(response); // "Paris is the capital of France."

Install via pub.dev:

yaml
dependencies:
  runanywhere: ^0.20.11
  runanywhere_llamacpp: ^0.20.11  # LLM/VLM text generation
  # runanywhere_onnx: ^0.20.11    # STT, TTS, VAD, voice agent
  # runanywhere_mlx: ^0.20.11     # Apple-native LLM/VLM/STT/TTS/embeddings
  # runanywhere_qhexrt: ^0.20.11  # Snapdragon Hexagon NPU

Documentation · Source

</details> <details> <summary><b>React Native</b></summary>
typescript
import { RunAnywhere, SDKEnvironment } from '@runanywhere/core';
import { LlamaCPP } from '@runanywhere/llamacpp';

// 1. Initialize
await RunAnywhere.initialize({ environment: SDKEnvironment.SDK_ENVIRONMENT_DEVELOPMENT });
LlamaCPP.register();

// 2. Download and load a model
await RunAnywhere.downloadModel('smollm2-360m');
await RunAnywhere.loadModel('smollm2-360m');

// 3. Generate
const result = await RunAnywhere.generate('What is the capital of France?');
console.log(result.text); // "Paris is the capital of France."

Install via npm:

bash
npm install @runanywhere/[email protected] @runanywhere/[email protected]
# optional backends: @runanywhere/onnx @runanywhere/mlx @runanywhere/qhexrt

Documentation · Source

</details> <details> <summary><b>Web</b> (TypeScript, WASM + WebGPU)</summary>
typescript
import { RunAnywhere, SDKEnvironment } from '@runanywhere/web';
import { LlamaCPP } from '@runanywhere/web-llamacpp';

// 1. Initialize
await RunAnywhere.initialize({ environment: SDKEnvironment.SDK_ENVIRONMENT_DEVELOPMENT });
await LlamaCPP.register({ acceleration: 'auto' }); // WebGPU when available, WASM otherwise
await RunAnywhere.completeServicesInitialization();

// 2. Load a model
await RunAnywhere.loadModel({ modelId: 'qwen2.5-0.5b' });

// 3. Generate
const result = await RunAnywhere.generate({
  prompt: 'What is the capital of France?',
});
console.log(result.text); // "Paris is the capital of France."

Install via npm:

bash
npm install @runanywhere/[email protected] @runanywhere/[email protected]
# @runanywhere/web-onnx for STT/TTS/VAD/embeddings in the browser

Source · Web starter app

</details> <details> <summary><b>Electron</b> (Windows-first desktop)</summary>
js
const { RunAnywhere } = require('@runanywhere/electron');

// 1. Initialize
RunAnywhere.initialize();

// 2. Load a model (catalog id or a local path)
const llm = await RunAnywhere.loadLLM('qwen2.5-0.5b');

// 3. Generate (streaming)
for await (const token of llm.generate('What is the capital of France?')) {
  process.stdout.write(token);
}

llm.unload();
RunAnywhere.shutdown();

A native N-API addon over the C core. Inference runs in an isolated Electron utility process and streams to the renderer over a MessagePort. LLM, VLM, STT, TTS, embeddings, RAG, structured output, tool calling, and a voice pipeline, with a prebuilt win32-x64 addon. CUDA is available as an opt-in source build.

Install: build from source (Windows x64 preview), see the SDK README for steps.

</details> <details> <summary><b>Python</b> (Windows / macOS / Linux)</summary>
python
from runanywhere import RunAnywhere

with RunAnywhere() as ra:
    # 1. Load a model (auto-downloads on first use)
    llm = ra.load_llm("qwen2.5-0.5b")

    # 2. Stream tokens (sync)
    for token in llm.generate("What is the capital of France?"):
        print(token, end="", flush=True)

    # 2b. Or async
    # async for token in llm.agenerate("..."):
    #     ...

    # 3. Or grab the full text
    print(llm.generate_text("Capital of France? One word."))  # "Paris"

Every method has an async twin. LLM, VLM, STT, TTS, embeddings (numpy), VAD, voice agent, RAG, structured output, and tool calling, with prebuilt wheels that bundle the native runtime. CUDA is available as an opt-in source build.

Install via pip:

bash
pip install runanywhere==0.20.11

Source

</details> <details> <summary><b>rcli</b> (terminal)</summary>
console
$ rcli pull qwen3
pulling qwen3-0.6b ▕████████████▏ 100%  639 MB/639 MB  32 MB/s
$ rcli run qwen3 "Reply with exactly: RCLI WORKS" --no-think
RCLI WORKS
$ rcli tts --text "RunAnywhere runs models on device." --output hello.wav
$ rcli stt --input hello.wav
 Run anywhere runs models on device.
$ rcli voice --input question.wav --output reply.wav   # full STT > LLM > TTS turn
$ rcli serve qwen3        # OpenAI-compatible API on :8080

Also: rcli run --image photo.jpg (VLM), rcli vad, rcli embed, rcli image (diffusion, Apple), rcli lora, and --json on everything.

Install (macOS Apple Silicon, Linux x86_64/aarch64, Windows x86_64):

bash
brew install runanywhere-ai/tap/rcli
# or
curl -fsSL https://raw.githubusercontent.com/RunanywhereAI/runanywhere-sdks/main/sdk/runanywhere-cli/scripts/install.sh | sh

CLI README

</details>

SDKs

SDKPlatformsStatusInstallDocs
SwiftiOS 17.5+, macOS 14.5+StableSwift Package Managerdocs.runanywhere.ai/swift
KotlinAndroid API 24+StableGradle (io.github.sanchitmonga22:runanywhere-sdk)docs.runanywhere.ai/kotlin
FlutteriOS, AndroidBetapub.dev (runanywhere)docs.runanywhere.ai/flutter
React NativeiOS, AndroidBetanpm (@runanywhere/core)docs.runanywhere.ai/react-native
WebChromium, Safari, FirefoxBetanpm (@runanywhere/web)SDK README
ElectronWindows x64 desktopPreviewBuild from sourceSDK README
PythonWindows, macOS, LinuxAlphapip (runanywhere)SDK README
rclimacOS, Linux, WindowsStableHomebrew / install scriptCLI README

All SDKs ship on one version line, currently 0.20.11, from a single C++ core. Pin the same version across the core package and its backends. See Releases for what is published today.


Features

FeatureSwiftKotlinFlutterRNWebElectronPythonrcli
LLM generation + streamingYesYesYesYesYesYesYesYes
Vision language models (VLM)YesYesYesYesYesYesYesYes
Speech-to-TextYesYesYesYesYesYesYesYes
Text-to-SpeechYesYesYesYesYesYesYesYes
Voice activity detectionYesYesYesYesYesYesYesYes
Voice agent pipelineYesYesYesYesYesYesYesYes
Wake wordYesYesYesYesYesYesYesYes
EmbeddingsYesYesYesYesYesYesYesYes
RAG (with streaming)YesYesYesYesYesYesYesn/a
Structured output (JSON)YesYesYesYesYesYesYesn/a
Tool callingYesYesYesYesYesYesYesn/a
Image generation (diffusion)YesYesYesYesn/an/an/aYes
LoRA adaptersYesYesYesYesYesn/an/aYes
Hexagon NPU (QHexRT)n/aYesYesYesn/an/an/an/a
MLX (Apple silicon)Yesn/aYesYesn/an/an/aYes
OpenAI-compatible servern/an/an/an/an/an/aYesYes
Model download + progressYesYesYesYesYesYesYesYes

Inference engines

Every SDK is a thin binding over runanywhere-commons, a single C++ core behind a pure C ABI. Engines plug into a capability registry and declare, per modality, what they can run. At inference time the highest-priority engine that serves the modality on the current device wins. Same code, different silicon, no branching in your app.

EngineModalitiesRuns onNotes
QHexRTLLM, VLM, STT, TTS, embeddings, inpaintingSnapdragon Hexagon NPU (v75 / v79 / v81)RunAnywhere's own NPU runtime, details below
MLXLLM, VLM, STT, TTS, embeddingsApple siliconApple-native inference via mlx-swift, safetensors models
llama.cppLLM, VLMEverywhere: Metal on Apple, CUDA opt-in on Windows/Linux, WebGPU + WASM in the browser, CPU with NEON/AVXGGUF models
sherpa + ONNXSTT, TTS, VAD, embeddingsAll platformssherpa-onnx for speech, ONNX Runtime for embeddings and RAG
Core MLImage generation (diffusion)iOS, macOSCore ML dispatches each layer across CPU, GPU, and the Apple Neural Engine
PlatformApple Foundation Models, system TTSiOS, macOS, AndroidNative OS capabilities behind the same API
CloudHybrid STTAll platformsOptional confidence-cascade routing to hosted providers

MetalRT, RunAnywhere's proprietary GPU inference engine for Apple silicon, powers RCLI, our on-device voice assistant for macOS with local RAG and 40+ system actions at sub-200 ms latency. Signed binaries live at metalrt-binaries.


Hexagon NPU acceleration (QHexRT)

QHexRT is RunAnywhere's inference runtime for the Qualcomm Hexagon NPU. It runs LLM, vision, speech, and text-to-speech models directly on the Snapdragon NPU (Hexagon v75 / v79 / v81) and ships as a built-in accelerator: your app calls the same loadModel and generate, and it uses the NPU automatically on supported devices.

  • Runs LLM, VLM, speech-to-text, and text-to-speech on the NPU, including text-to-speech, which other runtimes run on the CPU.
  • Runs Mixture-of-Experts and hybrid-attention models on the NPU (Phi-tiny-MoE, Qwen3.5), plus the 1-bit Bonsai family up to Bonsai-27B (Hexagon v81).
  • Runs NVIDIA's Cosmos3-Edge and Magpie-TTS Multilingual, and handles embeddings and image inpainting (LaMa) on the NPU as well.
  • Hybrid streaming voice agents: LLM on the NPU, STT and TTS on the CPU, with sentence-by-sentence streaming playback.
  • Fast prefill and low time-to-first-token, with context that extends past the compiled window.
  • Prebuilt model bundles published on Hugging Face; the SDK downloads the one matching the device.

Measured on a Samsung Galaxy S25 (Snapdragon 8 Elite, Hexagon v79):

ModelTaskParamsDecodeTime to first token
LFM2.5-230MLLM0.23 B164 tok/s32 ms
Qwen3-0.6BLLM0.6 B33 tok/s (prefill up to 3,692 tok/s)127 ms
Llama-3.2-1BLLM1.2 B16.3 tok/s56 ms
Phi-tiny-MoEMoE LLM3.8 B (1.1 B active)5-7 tok/s~2.5 s
InternVL3.5-1BVLM1 B37 tok/s290 ms
Whisper baseASR74 M~5x real-timen/a
MeloTTS-ENTTSn/a~4.5x real-timen/a

Available on the Kotlin, Flutter, and React Native SDKs. Snapdragon (Android arm64) only.


OpenAI-compatible server

The Python SDK and rcli both expose the local runtime as a drop-in OpenAI API, so anything that speaks the OpenAI client works against models running on your machine:

bash
pip install "runanywhere[server]"
runanywhere serve        # http://127.0.0.1:8000
python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
reply = client.chat.completions.create(
    model="qwen2.5-0.5b",
    messages=[{"role": "user", "content": "Hello from the edge."}],
)

Endpoints: /v1/chat/completions (streaming and non-streaming, text and vision), /v1/completions, /v1/embeddings, /v1/audio/transcriptions, /v1/audio/speech, and /v1/models. rcli serve offers the same on port 8080.


RunAnywhere Console

The Console is the control plane for on-device AI fleets. SDKs authenticate with an API key, register the device with its hardware profile, pull their assigned models, and report per-modality telemetry.

  • Deploy models over the air: assign catalog or bring-your-own models to an API key, and devices fetch them on their next sync. New models without an app release.
  • Device fleet: every registered device with its chip, memory, and NPU capability.
  • Analytics: usage, latency, and errors per modality across the fleet.
  • Benchmarks: compare local models against hosted providers.

The Console is optional. Every SDK runs fully offline without an API key, and telemetry is scoped per modality when enabled.


Models

Hexagon NPU (QHexRT)

Prebuilt bundles published on Hugging Face; the SDK downloads the one matching the device.

ModelTaskParamsBundle
Llama-3.2-1BLLM1.2 Bllama3_2_1b_HNPU
LFM2.5-230M / 350MLLM0.23 / 0.35 Blfm2_5_230m_HNPU · lfm2_5_350m_HNPU
Qwen3.5-0.8B / 2B / 4BLLM0.8-4 Bqwen3_5_0_8b_HNPU · 2b · 4b
Bonsai 1-bit familyLLM1.7 / 4 / 8 / 27 B1-bit and ternary builds; Bonsai-27B runs on Hexagon v81
Gemma-4-E2B / E4BLLM + VLM~2 / 4 Bgemma4_e2b_HNPU · gemma4_e4b_HNPU
Phi-tiny-MoEMoE LLM3.8 Bphi_tiny_moe_HNPU
DeepSeek-R1-Distill-QwenLLM1.5 / 7 B1.5b · 7b
Cosmos3-EdgeLLMedgeNVIDIA model family, Hexagon v79
Qwen3-VL-2BVLM2 Bqwen3_vl_HNPU
InternVL3.5-1BVLM1 Binternvl3_5_1b_HNPU
Whisper base / smallASR74 / 244 Mwhisper_base_HNPU · whisper_small_HNPU
Moonshine tiny / baseASRn/amoonshine_base_HNPU
MeloTTS-ENTTSn/amelotts_en_HNPU
Magpie-TTS MultilingualTTS357 Mmagpie_tts_357m_HNPU
Kitten TTS mini / microTTSn/aHexagon v75
EmbeddingGemma-300MEmbeddings300 Membeddinggemma_300m_HNPU

Browse all models on Hugging Face

Cross-platform

TypeModelsEngine
LLMSmolLM2, Qwen 3 / 2.5, Llama 3.2, LFM2, Mistral 7B (GGUF)llama.cpp
LLM / VLM (Apple)Qwen3, SmolVLM2, and other mlx-community safetensors modelsMLX
VLMSmolVLM2, LFM2-VL, Qwen2-VL (GGUF + mmproj)llama.cpp
Speech-to-TextWhisper Tiny / Base, Moonshinesherpa + ONNX
Text-to-SpeechPiper voices, Kokoro, Kitten TTSsherpa + ONNX
VADSilero VADsherpa + ONNX
EmbeddingsMiniLM, EmbeddingGemmaONNX Runtime
Image generationStable DiffusionCore ML

Anything not in the catalog can be pulled straight from Hugging Face or a direct URL; the core infers format, framework, and category from the artifact.


Example apps

Full consumer-assistant apps, one per platform, all built on the SDK:

PlatformSourceGet it
iOSexamples/ios/RunAnywhereAIApp Store
Androidexamples/android/RunAnywhereAIGoogle Play
Webexamples/web/RunAnywhereAIBuild from source
React Nativeexamples/react-native/RunAnywhereAIBuild from source
Flutterexamples/flutter/RunAnywhereAIBuild from source
Electronexamples/electron/RunAnywhereAIBuild from source (Windows)

The Android, Flutter, and React Native apps include an NPU section that detects the device's Hexagon arch and runs LLM, vision, speech, and text-to-speech on the NPU.

Starters, minimal projects to copy from: Swift · Kotlin · Flutter · React Native · Web

Playground, real projects built on the stack:


Repository layout

Business logic lives in the C++ core, so one fix lands on all eight SDKs at once.

runanywhere-sdks/
├── sdk/
│   ├── runanywhere-swift/          # iOS/macOS SDK (XCFramework)
│   ├── runanywhere-kotlin/         # Android SDK (JNI)
│   ├── runanywhere-flutter/        # Flutter SDK (Dart FFI)
│   ├── runanywhere-react-native/   # React Native SDK (Nitro/JSI)
│   ├── runanywhere-web/            # Web SDK (WebAssembly / WebGPU)
│   ├── runanywhere-electron/       # Electron SDK (N-API addon)
│   ├── runanywhere-python/         # Python SDK (pybind11)
│   ├── runanywhere-cli/            # rcli, the terminal SDK
│   └── runanywhere-commons/        # Shared C/C++ core behind a C ABI
│
├── engines/                        # llamacpp, mlx, sherpa, onnx, coreml, qhexrt, cloud
├── runtimes/                       # cpu, coreml, onnxrt compute adapters
├── idl/                            # Protobuf schemas, generated bindings per language
├── examples/                       # Full example apps
├── Playground/                     # Real-world reference apps
└── docs/                           # Documentation

Requirements

PlatformMinimum
iOS17.5+
macOS14.5+
AndroidAPI 24 (7.0), arm64 recommended
WebChrome 96+ / Edge 96+, Chrome 120+ for WebGPU
React Native0.83.1+, 0.85+ recommended (Node.js 22.12+)
Flutter3.44+ (Dart 3.12+)
ElectronWindows x64 (preview)
Python3.9+ on Windows, macOS, Linux (3.12+ recommended)
rclimacOS arm64, Linux x86_64 / aarch64, Windows x86_64

Hexagon NPU: Snapdragon with Hexagon v75 / v79 / v81, Android arm64. MLX: Apple silicon, physical devices. Memory: 2 GB minimum, 4 GB+ recommended for larger models.


Contributing

We welcome contributions. See the Contributing Guide for setup and conventions.

bash
git clone https://github.com/RunanywhereAI/runanywhere-sdks.git
cd runanywhere-sdks

# Doctor / setup helpers
./run doctor
./run setup

# Build the native XCFrameworks into sdk/runanywhere-swift/Binaries/.
# Required for local Swift development.
./sdk/runanywhere-swift/scripts/build-core-xcframework.sh

# Run the iOS sample app
cd examples/ios/RunAnywhereAI
open RunAnywhereAI.xcodeproj

Community


License

RunAnywhere License (Apache 2.0 based, with additional commercial-use terms). See LICENSE for details.