Back to Runanywhere Sdks

RunAnywhere Flutter SDK

sdk/runanywhere-flutter/README.md

0.20.127.0 KB
Original Source

RunAnywhere Flutter SDK

On-device AI for Flutter — run LLMs, speech-to-text, text-to-speech, and voice pipelines locally. Private, offline-capable, production-ready.

<p align="center"> </p> <p align="center"> <a href="https://docs.runanywhere.ai/flutter/introduction"></a> <a href="https://discord.gg/N359FBbDVd"></a> <a href="../../LICENSE"></a> </p> <p align="center"> <a href="https://flutter.dev"></a> <a href="https://dart.dev"></a> <a href="#"></a> <a href="#"></a> </p>

Requirements

ComponentMinimumRecommended
Flutter3.44+3.44.6 (see pubspec.yaml)
Dart3.12+3.12.2 (workspace constraint)
iOS17.5+17.5+
AndroidAPI 24 (7.0+)API 28+
Xcode26+26+
RAM2 GB4 GB+ for larger models

ARM64 devices are recommended. Metal on iOS and NEON on Android provide significant speedups.

Platform setup: iOS requires static CocoaPods linkage and microphone permissions for voice features. See docs/DEVELOPMENT.md for Podfile and manifest details.


Installation

Add the packages you need to pubspec.yaml. Pin to 0.20.12:

Core + LlamaCpp (LLM):

yaml
dependencies:
  runanywhere: 0.20.12
  runanywhere_llamacpp: 0.20.12

Core + ONNX (STT / TTS / VAD):

yaml
dependencies:
  runanywhere: 0.20.12
  runanywhere_onnx: 0.20.12

Core + MLX (Apple LLM / VLM / speech on physical iOS devices):

yaml
dependencies:
  runanywhere: 0.20.12
  runanywhere_mlx: 0.20.12

Optional NPU (Snapdragon Android):

yaml
  runanywhere_qhexrt: 0.20.12

Then run:

bash
flutter pub get
cd ios && pod install && cd ..   # iOS only
PackagePurpose
runanywhereCore SDK — required
runanywhere_llamacppLLM / VLM (GGUF)
runanywhere_onnxSTT, TTS, VAD
runanywhere_mlxApple MLX
runanywhere_qhexrtQualcomm Hexagon NPU (optional)

Quick Start

The public API is namespaced — each capability is accessed via a static accessor on RunAnywhere:

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await RunAnywhere.initialize();
  LlamaCpp.register();

  await RunAnywhere.downloadModel('smollm2-360m');
  await RunAnywhere.llm.load('smollm2-360m');

  final response = await RunAnywhere.llm.chat('What is the capital of France?');
  print(response);
}

For streaming, voice, vision, RAG, and tool calling, see the documentation.

Production initialization

dart
await RunAnywhere.initialize(
  apiKey: '<YOUR_API_KEY>',
  baseURL: 'https://api.runanywhere.ai',
  environment: SDKEnvironment.SDK_ENVIRONMENT_PRODUCTION,
);

Capabilities

Register backend modules (LlamaCpp, Onnx, Mlx) before downloading or loading models.

AccessorPurposeExample
RunAnywhere.llmText generationllm.chat(), llm.generate(), llm.generateStream()
RunAnywhere.sttSpeech-to-textstt.transcribe(), stt.transcribeStream()
RunAnywhere.ttsText-to-speechtts.synthesize(), tts.speak()
RunAnywhere.vadVoice activity detectionvad.detectVoiceActivity(), vad.streamVAD()
RunAnywhere.vlmVision-languagevlm.processImage()
RunAnywhere.voiceVoice agent pipelinevoice.initializeWithLoadedModels()
RunAnywhere.modelsModel registrymodels.register(), models.available()
RunAnywhere.downloadsDownload lifecycledownloads.start(), downloads.delete()
RunAnywhere.ragRetrieval-augmented generationrag.query()
RunAnywhere.toolsTool / function callingtools.generateWithTools()

Flat aliases such as RunAnywhere.downloadModel() and RunAnywhere.loadModel() mirror the Swift/Kotlin/RN APIs for cross-platform parity.

Supported model formats

FormatUse caseBackend
GGUFLLM, some VLMrunanywhere_llamacpp
ONNX / Sherpa archivesSTT, TTS, VADrunanywhere_onnx
MLX bundlesLLM, VLM, speech on Apple siliconrunanywhere_mlx
QHexRT bundlesNPU models on Snapdragonrunanywhere_qhexrt

Built-in catalog models (e.g. smollm2-360m) are discovered automatically — no manual registration required for catalog entries.


Error Handling

Errors throw SDKException with a proto ErrorCode:

dart
try {
  final result = await RunAnywhere.llm.generate(
    'Hello!',
    LLMGenerationOptions(maxTokens: 64),
  );
} on SDKException catch (error) {
  print('SDK error [${error.errorCode}]: ${error.message}');
}

Documentation & Examples

ResourceLink
Docs sitedocs.runanywhere.ai/flutter/introduction
API referencedocs/Documentation.md
Example appexamples/flutter/RunAnywhereAI/
Contributing / platform setupdocs/DEVELOPMENT.md

FAQ

Do I need an internet connection?
Only for initial model download. Inference runs entirely on-device afterward.

Is user data sent to the cloud?
No. All inference is local. Production mode may collect anonymous telemetry (configurable).

Can I use custom models?
Yes — register GGUF, ONNX/Sherpa, or MLX bundles via RunAnywhere.models.register().

How do I test Apple MLX?
MLX execution requires a physical arm64 iOS device. The simulator slice is for compile/link validation only.


Support


License

RunAnywhere License. See LICENSE for details.