Back to Runanywhere Sdks

README

README.md

0.20.1117.0 KB
Original Source
<p align="center"> </p> <h1 align="center">RunAnywhere</h1> <p align="center"> <strong>On-device AI for every platform.</strong>

Run LLMs, vision, speech-to-text, and text-to-speech locally. Private, offline, fast.

One SDK for iOS, Android, Flutter, React Native, and Web, with Hexagon NPU acceleration on Snapdragon.

</p> <p align="center"> <a href="https://apps.apple.com/us/app/runanywhere/id6756506307"> </a> &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>

What is RunAnywhere?

RunAnywhere lets you add AI features to your app that run entirely on-device, with no cloud, no latency, and no data leaving the device:

  • LLM Chat: Llama, Qwen, Gemma, Phi, LFM, Mistral, and more
  • Vision (VLM): image understanding and captioning
  • Speech-to-Text: Whisper- and Moonshine-based transcription
  • Text-to-Speech: neural voice synthesis
  • Voice Assistant: a full speech-to-text, LLM, and text-to-speech pipeline

One API spans iOS, Android, Flutter, React Native, and Web, and routes to the best engine on each device: Core ML on Apple, WebGPU in the browser, llama.cpp everywhere as a fallback, and the Hexagon NPU on Snapdragon.


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


See It In Action

<div align="center"> <table> <tr> <td align="center" width="50%">
  <strong>Text Generation</strong>

  <sub>LLM inference, 100% on-device</sub>
</td>
<td width="40"></td>
<td align="center" width="50%">
  


  <strong>Voice AI</strong>

  <sub>STT to LLM to TTS pipeline, fully offline</sub>
</td>
</tr> <tr><td colspan="3" height="30"></td></tr> <tr> <td align="center" width="50%">
  <strong>Image Generation</strong>

  <sub>On-device diffusion model</sub>
</td>
<td width="40"></td>
<td align="center" width="50%">
  


  <strong>Visual Language Model</strong>

  <sub>Vision + language understanding on-device</sub>
</td>
</tr> </table> </div>

SDKs

PlatformStatusInstallationDocumentationNPU
Swift (iOS/macOS)StableSwift Package Managerdocs.runanywhere.ai/swiftn/a
Kotlin (Android)StableGradledocs.runanywhere.ai/kotlinYes
Web (Browser)BetanpmSDK READMEn/a
React NativeBetanpmdocs.runanywhere.ai/react-nativeYes
FlutterBetapub.devdocs.runanywhere.ai/flutterYes

Quick Start

Swift (iOS / macOS)

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

Install via Swift Package Manager:

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

Documentation · Source code


Kotlin (Android)

kotlin
import com.runanywhere.sdk.public.RunAnywhere
import com.runanywhere.sdk.public.extensions.*

// 1. Initialize
LlamaCPP.register()
RunAnywhere.initialize(environment = SDKEnvironment.DEVELOPMENT)

// 2. Load a model
RunAnywhere.downloadModel("smollm2-360m").collect { println("${it.progress * 100}%") }
RunAnywhere.loadLLMModel("smollm2-360m")

// 3. Generate
val response = RunAnywhere.chat("What is the capital of France?")
println(response) // "Paris is the capital of France."

Install via Gradle:

kotlin
dependencies {
    implementation("com.runanywhere.sdk:runanywhere-kotlin:0.16.1")
    implementation("com.runanywhere.sdk:runanywhere-core-llamacpp:0.16.1")
}

Documentation · Source code


React Native

typescript
import { RunAnywhere, SDKEnvironment } from '@runanywhere/core';
import { LlamaCPP } from '@runanywhere/llamacpp';

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

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

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

Install via npm:

bash
npm install @runanywhere/core @runanywhere/llamacpp

Documentation · Source code


Flutter

dart
import 'package:runanywhere/runanywhere.dart';
import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart';

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

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

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

Install via pub.dev:

yaml
dependencies:
  runanywhere: ^0.16.0
  runanywhere_llamacpp: ^0.16.0  # LLM text generation
  # runanywhere_onnx: ^0.16.0   # Add this if you need STT, TTS, or Voice features

Documentation · Source code


Web (Browser)

typescript
import { RunAnywhere } from '@runanywhere/web';

// 1. Initialize
await RunAnywhere.initialize({ environment: 'development' });

// 2. Load a model
await RunAnywhere.loadModel({
  id: 'qwen2.5-0.5b',
  source: '/models/qwen2.5-0.5b-instruct-q4_0.gguf',
});

// 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/web

Source code


Features

FeatureiOSAndroidWebReact NativeFlutter
LLM Text GenerationYesYesYesYesYes
StreamingYesYesYesYesYes
Speech-to-TextYesYesYesYesYes
Text-to-SpeechYesYesYesYesYes
Voice Assistant PipelineYesYesYesYesYes
Vision Language ModelsYesYesYesn/aYes
Hexagon NPU (QHexRT)n/aYesn/aYesYes
Model Download + ProgressYesYesYesYesYes
Structured Output (JSON)YesYesYesSoonSoon
Tool CallingYesYesYesn/an/a
Embeddingsn/an/aYesn/an/a
Apple Foundation ModelsYesn/an/an/an/a

Supported 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
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
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
EmbeddingGemma-300MEmbeddings300 Membeddinggemma_300m_HNPU

Browse all models on Hugging Face

Cross-platform (GGUF / ONNX)

TypeModelsRuntime
LLMSmolLM2, Qwen 2.5, Llama 3.2, Mistral 7Bllama.cpp
Speech-to-TextWhisper Tiny / BaseONNX
Text-to-SpeechPiper (US / UK English)ONNX

Sample Apps

PlatformSourceDownload
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

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.


Starter Examples

Minimal projects to get up and running on each platform:

PlatformRepository
Kotlin (Android)kotlin-starter-example
Swift (iOS)swift-starter-example
Flutterflutter-starter-example
React Nativereact-native-starter-app

Playground

Real-world projects built with RunAnywhere. Each ships as a standalone app you can build and run.


Architecture

A single C/C++ core (runanywhere-commons) behind a C ABI, with thin platform SDKs on top and a plugin registry that selects the best engine per device (llama.cpp, ONNX/sherpa, Core ML, Metal, and QHexRT on the Hexagon NPU). Business logic lives in the core, so one fix lands on all five SDKs.

runanywhere-sdks/
├── sdk/
│   ├── runanywhere-swift/          # iOS/macOS SDK
│   ├── runanywhere-kotlin/         # Android SDK
│   ├── runanywhere-web/            # Web SDK (WebAssembly / WebGPU)
│   ├── runanywhere-react-native/   # React Native SDK
│   ├── runanywhere-flutter/        # Flutter SDK
│   └── runanywhere-commons/        # Shared C/C++ core
│
├── engines/                        # Pluggable inference backends
├── examples/                       # Sample apps
├── Playground/                     # Real-world reference apps
└── docs/                           # Documentation

Requirements

PlatformMinimumRecommended
iOS17.0+17.0+
macOS14.0+14.0+
AndroidAPI 24 (7.0)API 28+
WebChrome 96+ / Edge 96+Chrome 120+
React Native0.74+0.76+
Flutter3.10+3.24+

Hexagon NPU: Snapdragon with Hexagon v79 / v81 (Snapdragon 8 Elite class), Android arm64. Memory: 2 GB minimum, 4 GB+ recommended for larger models.


Contributing

We welcome contributions. See our Contributing Guide for details.

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

# 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

Support


License

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