TheStage Android SDK

Attention

Access to the Android SDK requires an API token from the TheStage AI Platform. Pricing is by arrangement — open a Service Request at app.thestage.ai/contact; there is no public rate card. See TheStage Android SDK Product Terms and Licensing & Device Identity.

License: LICENSE in the repository; commercial summary: TheStage Android SDK Product Terms

Overview

On-device speech, language, vision and audio inference for Android on Qualcomm Snapdragon. The SDK runs compiled engines on the Hexagon NPU (TheStage’s own NPU runtime for the language, vision and speech-recognition models; the QNN runtime for the others), uses a model’s portable CPU build where it publishes one and the phone’s chip has no NPU build, downloads engines from HuggingFace on first use, and exposes a unified infer / infer_stream API for every pipeline. No server in the hot path.

There are two consumption surfaces: the native Kotlin singleton (TheStageAI) and the Flutter plugin (thestage_android_sdk → TheStageFlutterSDK). They mirror each other one-to-one; Dart consumers always go through the JSON path.

Version

1.1.1 — pin this tag (ref: v1.1.1); do not float

Platform

Android, minSdk 28, compileSdk 35, arm64-v8a only

Backend

Hexagon NPU (TheStage NPU runtime and QNN / HTP); a portable CPU build where a model publishes one

Token

one online check per process (cached in-memory); a fresh launch re-validates online

Engines ship per model through HuggingFace (or Google Play AI packs — see AI Packs (Google Play delivery)); each pipeline page lists its models in a Supported models table, and model cards (contracts + acknowledgments) live at huggingface.co/TheStageAI. Pass the HF id as engines_path; the SDK downloads and caches it on first start and resolves the model_type from the repo id, so you pass model_type only for a local bundle. model_name is your own handle for the loaded model.

Task

HF engines

model_type

Notes

Chat LLM

TheStageAI/LFM2.5-230M · LFM2.5-350M · LFM2.5-1.2B · LFM3-1.7B · Qwen3.5-0.8B · Qwen3.5-2B · Qwen3.5-4B · Qwen3.5-9B (8 Elite and 8 Elite Gen 5 only)

the-stage-llm

on-device chat; MTP / thinking per model, see LLM (Language Model)

VLM

TheStageAI/LFM2.5-VL-450M · LFM2.5-VL-1.6B · gemma-4-E2B-it

lfm2-vl · gemma4-vl

images + prompt → text, see VLM (Vision-Language)

ASR

TheStageAI/thewhisper-large-v3-turbo

whisper

any length; SDK windows long audio

TTS

TheStageAI/neutts-nano-multilingual · neutts-multilingual · neutts

neutts

9 languages (neutts is English-only), see TTS (NeuTTS)

VAD

TheStageAI/silero-vad

silero-vad

512-sample chunks @ 16 kHz

Turn detect

TheStageAI/smart-turn-v3

smart-turn

DNN end-of-turn; used by the voice agent

Speaker ID

TheStageAI/redimnet2

speaker-id

192-d embedding, 2 s window

Diarization

TheStageAI/Nemotron-3-Diarization

nemotron-diarization

who spoke when; streaming segments, see Diarization

Full agent

compose the above

—

see Voice Agent

Omit revision in normal apps — the SDK resolves each repo to the commit this SDK version pins (see Revisions and model cache below).

Supported Devices

Phones with Snapdragon 8 Gen 2 (SM8550), 8 Gen 3 (SM8650), 8 Elite (SM8750) or 8 Elite Gen 5 (SM8850). A model publishes either one NPU build per chip or a single NPU build that serves all of them (the language and vision-language models), and some also publish a portable CPU build; the SDK downloads the one that fits the phone (see Model Management, Choosing the device). The availability check (Model Management, Availability) tells you before a download whether a model has a build for the device.

device

Leave device unset: the SDK takes the best bundle the model publishes for this phone — its NPU bundle where there is one for the chip, otherwise its portable CPU bundle. Pass "npu" or "cpu" only to require one; the load then fails, naming the chip and what the repo publishes, instead of quietly running somewhere else. "gpu" is refused. See Model Management (Choosing the device).

model_type

The examples on these pages pass only model_name and engines_path, which is all a published repo needs: the SDK resolves the model type from the repo id. Pass model_type explicitly when loading from a local directory or a repo the SDK does not know, since there is no repo id to resolve from:

TheStageAI.start_model(
    model_name = "stt",
    engines_path = "/data/local/tmp/my_whisper_bundle",
    model_type = "whisper",
)

Prerequisites

Requirement

Minimum

Notes

Android device

Android 9 (API 28)

physical Qualcomm Snapdragon, arm64-v8a

Android SDK (compile)

API 35

Flutter (only for the Flutter examples)

3.38

with Dart 3.10.7+ (the voice-agent examples need it; the plugin alone needs Dart 3.5)

JDK

17

Qualcomm QNN runtime

2.51.0

com.qualcomm.qti:qnn-runtime:2.51.0 from Qualcomm’s Maven repo; your app module declares it, Flutter or native (see below)

Qualcomm QAIRT SDK (optional)

2.51.0

only for the optional libs in Qualcomm QAIRT Runtime Libs (Genie Backend); must be 2.51.0

The NPU backend requires one of the supported Snapdragon chips (8 Gen 2, 8 Gen 3, 8 Elite, 8 Elite Gen 5). On other hardware only the models that publish a portable CPU build load; the others fail with an error naming the chip and what the model publishes.

Obtaining an API Token

Every SDK call begins with initialize(api_token = ...). You need a valid API token from the TheStage AI Platform before any pipeline will load.

  1. Sign in at app.thestage.ai.

  2. Go to Profile → API tokens tab.

  3. Click Generate API token, add a description, and press Generate token.

  4. Copy the token immediately — you will not be able to view it again after leaving the page.

For the full walkthrough with screenshots, see SSH Keys and API Tokens.

Once you have a token, pass it to the SDK at startup:

Kotlin:

import ai.thestage.qlip.TheStageAI

TheStageAI.registerContext(context)
TheStageAI.initialize(api_token = "your-api-token")

Flutter:

import 'package:thestage_android_sdk/thestage_android_sdk.dart';

await TheStageFlutterSDK.initialize(api_token: 'your-api-token');

registerContext (Kotlin only) takes any Android Context — your Application, an Activity, or a Service. The SDK keeps only the applicationContext (no Activity leak) and uses it to reach app-private storage, preferences, and other platform services. Call it once per process, before initialize. Flutter apps never call it — the plugin registers the context automatically when the engine attaches.

The token is validated online once per process (cached in-memory); a fresh app launch re-validates online — there is no offline grace window, so the device must be reachable on first use. If initialize fails with Token validation failed, check the token and the network connection. A billable seat is the pair (apiToken, deviceId). The deviceId is derived from Android’s ANDROID_ID, scoped per app: it survives reinstall and “clear data” and resets only on a factory reset — see Licensing & Device Identity.

Attention

Keep your API token secret. Never commit it to source control. For Flutter apps, use --dart-define-from-file=secrets.json and add secrets.json to .gitignore — see Secrets below.

Example Apps

The repository ships ready-to-run Flutter examples under examples/ — each has its own README.md with app-specific notes.

Example

Description

tutor_tts

Mixed-language streaming TTS: a language tutor that switches language per span. Start here.

voice_agent

Full voice-assistant loop, mic → VAD → STT → LLM → streaming TTS.

voice_agent_custom_nodes

The voice agent plus custom graph nodes + ephemeral VLM captions + screen recording.

tutor_small_llms

A small LLM turns a receipt, a chat or an SMS into structured data.

engine_bench

On-device LLM / TTS / ASR / VLM benchmark with JSON export.

Alongside the examples, the repo contains TheStageCore.aar (the pre-built SDK binary: inference engine, license gate, ONNX Runtime / QNN / Genie runtimes — opaque; you link it, you don’t build it), onnxruntime-android.aar (the QNN-enabled ONNX Runtime AAR the core links against, supplied by the app at runtime), plugin/thestage_android_sdk/ (the Flutter plugin over platform channels; your app module supplies the AARs — Dart entrypoint plugin/thestage_android_sdk/lib/thestage_android_sdk.dart), docs/ (per-pipeline reference guides), scripts/setup.sh (one-time host setup: AAR symlinks + secrets bootstrap for the Flutter examples), RELEASE.md (what’s new, the AAR checksums and the model commits this version pins) and VERSION (the SDK line this checkout ships, 1.1.1).

To run an example:

# 1. One-time host setup: symlink the AARs into the plugin and
#    bootstrap each example's secrets.json. Idempotent.
./scripts/setup.sh

# 2. Put your TheStage API token (TS_API_TOKEN) into the
#    secrets.json that setup.sh created.
$EDITOR examples/tutor_tts/secrets.json

# 3. Build & run on a connected Snapdragon device.
cd examples/tutor_tts
flutter pub get
flutter run --release \
    --dart-define-from-file=secrets.json \
    -d <YOUR_DEVICE_ID>

In the app, tap Load model (the first load downloads neutts-nano-multilingual), pick a phrase, then Play. flutter devices lists attached devices. The other examples follow the same recipe (examples/voice_agent runs its LLM on-device by default; OPENAI_API_KEY in its secrets.json is needed only for the remote LLM provider). See each example’s README.md for app-specific notes.

Integration: Native Kotlin (Gradle)

You can consume the AARs directly from a Kotlin/Android app, no Flutter involved. Copy the two prebuilt AARs into your app module’s libs/.

The Qualcomm QNN runtime (the signed per-SoC HTP skel libraries the NPU backend needs) is published on Qualcomm’s public Maven repository — no login required. Declare that repository in your settings.gradle.kts alongside the usual ones:

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        // Qualcomm QNN / QAIRT runtime artifacts (public, no auth).
        maven { url = uri("https://qpm-download.qualcomm.com/maven/release") }
    }
}

Then in your app module’s build.gradle.kts:

dependencies {
    // The precompiled TheStage core (opaque engine/license/runtime)
    // and the QNN-enabled ONNX Runtime AAR.
    implementation(files("libs/TheStageCore.aar"))
    implementation(files("libs/onnxruntime-android.aar"))

    // Qualcomm QNN runtime — 19 libs: libQnnHtp / HtpPrepare / System /
    // Gpu / Dsp plus the per-SoC HTP skel + stub libraries
    // (V68, V69, V73, V75, V79, V81, and Dsp V66). Resolved from the
    // Qualcomm Maven repo declared above.
    implementation("com.qualcomm.qti:qnn-runtime:2.51.0")

    // Transitive deps of the core (not pulled via files(...)).
    implementation("com.google.code.gson:gson:2.11.0")
    implementation("com.squareup.okhttp3:okhttp:4.12.0")
    implementation(
        "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0"
    )
}

Note

The qnn-runtime Maven artifact does not contain the libraries of the GenAiTransformer Genie backend. No currently published model needs them — see Qualcomm QAIRT Runtime Libs (Genie Backend) below for when you would.

Because both TheStageCore.aar and onnxruntime-android.aar bundle native .so libraries, add a packaging block to your app module so the merge picks one copy of each duplicate, and restrict the ABI to arm64-v8a:

android {
    defaultConfig {
        minSdk = 28
        ndk { abiFilters += "arm64-v8a" }
    }
    packaging {
        jniLibs.pickFirsts.add("lib/arm64-v8a/libonnxruntime.so")
        jniLibs.pickFirsts.add("lib/arm64-v8a/libonnxruntime4j_jni.so")
        jniLibs.pickFirsts.add("lib/arm64-v8a/libc++_shared.so")
    }
}

QNN’s FastRPC skel libraries load from an APK only when they are extracted at install time, so set android:extractNativeLibs="true" on your <application> (or useLegacyPackaging = true in the jniLibs packaging block). Then drive the singleton from Kotlin — register the app Context once, then initialize with your token:

// Once, at app start (e.g. Application.onCreate).
TheStageAI.registerContext(context)

// Suspend — validates the token online (once per process).
TheStageAI.initialize(api_token = "th_…")

TheStageAI.start_model(
    model_name = "stt",
    engines_path = "TheStageAI/thewhisper-large-v3-turbo",
)

val result = TheStageAI.infer(
    model_name = "stt",
    input_json = mapOf(
        "audio" to pcm_16k_mono,   // FloatArray, mono, [-1, 1]
        "language" to "en",
    ),
)

registerContext is native-only (the Flutter plugin registers the Context for you). initialize, start_model, infer and infer_stream are suspend functions — call them from a coroutine.

Qualcomm QAIRT Runtime Libs (Genie Backend)

You probably do not need this. Every model this SDK currently publishes runs with only the com.qualcomm.qti:qnn-runtime Maven artifact, which resolves with no account and no manual steps — including the Genie-backed ones. Genie requests the QnnHtp backend, and QnnHtp comes from Maven.

Most of the libs below belong to a different Genie backend (GenAiTransformer) that no currently published bundle asks for. The exception is libQnnHtpNetRunExtensions.so: the NeuTTS bundles use it to apply their HTP performance settings. Without it NeuTTS still runs, at the default HTP settings. Set QAIRT to get it, if you are running a bundle that needs the other libs, or if a Genie pipeline fails with the dlopen error at the end of this section.

If you do need them, they are not on Maven and this SDK does not redistribute them, because they are Qualcomm’s to license. You copy them from your own QAIRT install.

1. Get the QAIRT SDK (version 2.51.0). Download the Qualcomm AI Runtime SDK (QAIRT — the Qualcomm AI Engine Direct / QNN runtime), version 2.51.0, via Qualcomm Package Manager (qpm.qualcomm.com — a free Qualcomm account is required; search for “Qualcomm AI Runtime SDK”). Install it and note the versioned directory, e.g. ~/Qualcomm/AIStack/QAIRT/2.51.0.260929. The libs live under <install>/lib/aarch64-android/.

2.51.0 specifically. TheStageCore.aar ships its own Genie build compiled against QAIRT 2.51.0, so backend libs from another QAIRT are an ABI mismatch. You do not need stock libGenie.so.

Note

This pin is about the libs you install — not about model bundles. The bundles this SDK downloads are compiled with an older QAIRT and load correctly on 2.51: an older context binary is forward-compatible, and only a newer one is rejected (with Could not create context from binary … err 5000). You never have to match your QAIRT install to the bundles.

2. Copy the libs in.

QAIRT=~/Qualcomm/AIStack/QAIRT/2.51.0.260929 ./scripts/setup.sh

That copies them into the plugin’s jniLibs/arm64-v8a/, from where AGP merges them into every app you build. (To do it by hand instead, copy them into your own app’s src/main/jniLibs/arm64-v8a/.)

Library

Role

In 2.51

libQnnGenAiTransformer.so

GenAI transformer backend

yes

libQnnGenAiTransformerModel.so

GenAI transformer model backend

yes

libQnnCpu.so

QNN CPU fallback backend

yes

libQnnHtpNetRunExtensions.so

HTP performance settings (NeuTTS)

yes

libQnnGenAiTransformerCpuOpPkg.so

GenAI transformer CPU op package

no — dropped by Qualcomm; skipped automatically

setup.sh treats the first four as required and the last as optional, so a 2.51 install is not reported as broken. On older QAIRT installs that still ship it, it is copied too.

3. Check it worked.

ls plugin/thestage_android_sdk/android/src/main/jniLibs/arm64-v8a/
# libQnnCpu.so  libQnnGenAiTransformer.so  libQnnGenAiTransformerModel.so
# libQnnHtpNetRunExtensions.so

If a Genie pipeline is still missing them at runtime it fails on first use with:

dlopen failed: library "libQnnGenAiTransformer.so" not found

The Snapdragon-only QNN NPU backend (the qnn-runtime Maven artifact above) is what everything else uses; only the Genie pipelines that request GenAiTransformer need this extra QAIRT copy step.

Integration: Flutter Plugin

Add the plugin as a git: dependency in your app’s pubspec.yaml, pinned to the tag:

dependencies:
  thestage_android_sdk:
    git:
      url: https://github.com/TheStageAI/AndroidSDK.git
      path: plugin/thestage_android_sdk
      ref: v1.1.1

The plugin declares the prebuilt AARs compileOnly, so your app module must supply them at runtime. Copy TheStageCore.aar and the ONNX Runtime AAR into your app’s libs/ and wire them up as in the Integration: Native Kotlin (Gradle) section above, then:

import 'package:thestage_android_sdk/thestage_android_sdk.dart';

await TheStageFlutterSDK.initialize(api_token: 'th_…');

await TheStageFlutterSDK.start_model(
  model_name: 'stt',
  engines_path: 'TheStageAI/thewhisper-large-v3-turbo',
);

final result = await TheStageFlutterSDK.infer(
  model_name: 'stt',
  input_json: {
    'audio': pcm_16k_mono,   // Float32List, mono, [-1, 1]
    'language': 'en',
  },
);
print(result[0]['transcription']);

The fastest way to see a real app is to copy one of the examples/ apps.

Kotlin / Flutter Parity

The Kotlin singleton (TheStageAI) and the Flutter TheStageFlutterSDK mirror each other one-to-one. Dart consumers always go through the JSON path.

Operation

Kotlin

Flutter (Dart)

Initialize

TheStageAI.registerContext(context) then TheStageAI.initialize(api_token = "...")

await TheStageFlutterSDK.initialize(api_token: '...')

Start a model

TheStageAI.start_model(model_name =, engines_path =, device =, config =)

await TheStageFlutterSDK.start_model(model_name:, engines_path:, device:, config:)

Stop a model

TheStageAI.stop_model(model_name = "llm")

await TheStageFlutterSDK.stop_model(model_name: 'llm')

Single-shot inference

TheStageAI.infer(model_name =, input_json =) -> List<Map<String, Any>>

await TheStageFlutterSDK.infer(model_name:, input_json:) -> List<Map<String, dynamic>>

Streaming inference

TheStageAI.infer_stream(model_name =, input_json =) -> Flow<InferenceStreamChunk>

TheStageFlutterSDK.infer_stream(model_name:, input_json:, stream_id:?) -> Stream<Map<String, dynamic>>

Push text into a TTS stream

val s = TheStageAI.open_tts_streamer(model_name = "tts"); s.send(text); s.finish(); collect s.output

await TheStageFlutterSDK.send(stream_id:, text:); await TheStageFlutterSDK.finish_stream(stream_id:)

Cancel a running stream

cancel the collecting coroutine, or s.cancel() on a TTS streamer

await TheStageFlutterSDK.stop_stream(stream_id:)

Push audio into an ASR stream

TheStageAI.stream_append(model_name =, input_json =); stream_finish(model_name =)

await TheStageFlutterSDK.stream_append(model_name:, input_json:); stream_finish(model_name:)

Installed models and updates

installed_models(), available_updates(), remove_model(model_type =, repository =)

same names on TheStageFlutterSDK

Reclaim space

TheStageAI.maintain(); reset_models() to clear everything

await TheStageFlutterSDK.maintain(); reset_models()

Load progress

start_model(on_load_progress = { p: LoadProgress -> … })

Single global stream TheStageFlutterSDK.on_progress ({model_name, phase}, plus progress while downloading or status when parked)

Audio buffer type

FloatArray

Float32List (never Float64List)

Both surfaces use the same model_name strings and the same input_json shape; the Flutter path is JSON-only.

Load Progress

phase is the signal to drive your UI from, and it is always present. progress is only sent while a transfer is measurable:

Phase

Progress

Notes

downloading

0.00 – 1.00

HuggingFace repo download (skipped on cache hit)

waiting_for_wifi

absent

AI-pack download parked until an unmetered network. The user can act: prompt them to join Wi-Fi

waiting_for_confirmation

absent

AI-pack download needs the user’s OK for metered data. Show Play’s confirmation dialog

extracting

absent

Bundle unpack to local cache (skipped on cache hit)

loading

absent

Pipeline construction, including first-run NPU context compile

ready

1.00 (terminal)

Emitted on success only

Unpacking and NPU compilation report nothing intermediate, so those phases send no progress rather than a number that would sit frozen. Bind a determinate bar when progress is present and an indeterminate one when it is absent — in Flutter, LinearProgressIndicator(value:) takes null for exactly this.

Flutter — events from every active start_model are multiplexed through one global Stream. Filter by model_name to disambiguate concurrent loads:

TheStageFlutterSDK.on_progress.listen((event) {
  // event['model_name'] : String  — model handle passed to start_model
  // event['phase']      : String  — always present; see the table above
  // event['progress']   : double? — 0.0 … 1.0 while downloading;
  //                                 ABSENT on the other phases
  // event['status']     : String? — 'waiting_for_wifi' |
  //                                 'waiting_for_confirmation'
  // event['downloaded_bytes'] : int?  — during 'downloading' only
  // event['total_bytes']      : int?  — during 'downloading' only

  final phase = event['phase'] as String?;
  final p = (event['progress'] as num?)?.toDouble();
  // `p == null` is the cue for an indeterminate indicator, not a
  // reason to reset the bar to zero.
});

A complete first-run example — subscribe before start_model so the download / extract / load phases are reported as the engines arrive:

import 'package:thestage_android_sdk/thestage_android_sdk.dart';

await TheStageFlutterSDK.initialize(api_token: 'your-api-token');

// Subscribe to load progress for any model_name.
TheStageFlutterSDK.on_progress.listen((event) {
  if (event['model_name'] != 'stt') return;
  // `progress` is sent only while downloading; absent elsewhere.
  final p = event['progress'] as num?;
  print('[stt] ${event['phase']}'
      '${p == null ? '' : ' ${(p * 100).toStringAsFixed(0)}%'}');
});

await TheStageFlutterSDK.start_model(
  model_name: 'stt',
  engines_path: 'TheStageAI/thewhisper-large-v3-turbo',
);

final result = await TheStageFlutterSDK.infer(
  model_name: 'stt',
  input_json: {
    'audio': pcm_16k_mono,   // Float32List, mono, [-1, 1]
    'language': 'en',
  },
);
print(result[0]['transcription']);

Byte counters

progress alone cannot say whether 40% means 40 MB or 4 GB. During the downloading phase the event also carries downloaded_bytes and total_bytes, so an app can show “120 MB of 300 MB” or warn before a large download on a metered connection.

Both keys are absent — not null, not zero — when the server declared no Content-Length, so check for presence rather than trusting a value:

final total = event['total_bytes'] as int?;
if (total != null) {
  final done = event['downloaded_bytes'] as int;
  label = '${done >> 20} MB of ${total >> 20} MB';
}

In Kotlin the same values are LoadProgress.downloaded_bytes and LoadProgress.total_bytes, both Long?.

The phase strings and the terminal contract are identical on both surfaces, and on both a fraction is present only while downloading. See Model Management for loading, prefetch and the installed-model lifecycle.

Revisions and model cache

Omit revision in normal apps. Each SDK release pins every model it supports to an exact HF commit, so the bytes a release downloads never change under it; a blank revision resolves that pin. Passing a revision overrides the pin.

Downloaded models live in the app’s private files directory, out of reach of other apps and of the user’s media, in one slot per repo, pinned commit and variant:

  • Every repo has its own slot. Repos that share a model type — all the text LLMs are the-stage-llm — are installed side by side, so switching between them loads from disk after the first download.

  • Nothing is keyed on the SDK version, so upgrading the SDK re-downloads nothing while the pins stay where they are.

  • A load never replaces what is installed. When this build pins a newer commit, available_updates() reports it and the installed bundle keeps serving until the app takes the update; the replaced revision is then reclaimed.

  • Reclaim space through the SDK, not by deleting directories: remove_model for one model, maintain() for whatever nothing claims, reset_models() to start over.

The full cache layout, the update calls and the reclaim calls are in Model Management.

Upgrading from 1.0.x

  • Kotlin LoadProgress.fraction is Double?: it carries transfer progress (0..1) only while downloading and 1.0 on ready, and is null in every other phase. Drive the UI from phase.

  • Dart start_model device defaults to '', the best available bundle for the phone (it was 'gpu'). 'gpu' is refused; 'npu' and 'cpu' are constraints that fail when the model publishes no such bundle.

  • A load never replaces an installed bundle. Take updates with available_updates() and prefetch_model(replace_existing: true).

  • Models are cached per repo and pinned commit. Copies cached by 1.0.x are not reused: each model downloads once more on its first load after the upgrade. reset_models(), which clears every staged model, also reclaims the old copies.

  • The deviceId changes once: an install upgrading from 1.0.x registers as a new device, then keeps the new id across reinstalls (see Licensing & Device Identity).

  • Dart TTSController.downloadProgress is double? (null outside downloading). Its modelType defaults to 'neutts' (was 'neutts-multilingual') and its revision to '', the pinned commit (was 'develop').

  • Voice agent: every *_device field of TheStageAgentConfig (and the matching Flutter config keys) defaults to "", the best available bundle for each component (they were "npu" / "cpu"). A 1.0.x agent config that forces device "npu" fails for components that publish only a CPU bundle, such as VAD — drop those overrides.

  • Voice agent set_voice reports failures: Kotlin throws, and the Flutter call completes with an error, for an unknown voice id or language, a relative voice_dir or one without voice.json, or a failed reload. The current voice stays. In 1.0.x these errors were swallowed.

  • The Dart names TheStageVoiceAgentFlutter, TheStageAgentNode, TheStageAgentState, TheStageAudioPlayer and camelCase members such as llmDeltas or setVoice still compile as deprecated aliases of TSVoiceAgent, TSAgentNode, TSAgentState, TSAudioPlayer and the snake_case names in Voice Agent.

  • Voice-agent config: the Flutter keys turn_detection_mode and allow_interruptions: false are still read, as turn_end_mode and interrupt_mode: 'none'. In Kotlin, turn_detection_mode, interrupt_trigger and allow_interruptions are read-only properties derived from turn_end_mode and interrupt_mode.

  • A voice agent on the on-device LLM gets the built-in voice tool preset (weather, time, search, Wikipedia, calculator, phone actions) and DefaultTools.voice_system_prompt when the config sets neither. Set llm_tools: 'none' for replies without tools; the new tool_calling state needs a case in an exhaustive switch over TSAgentState (see Voice Agent).

Audio I/O Contract

All audio crossing the public SDK surface — VAD input, Whisper input, NeuTTS output — uses PCM float, mono, samples normalized to [-1.0, 1.0]. On Kotlin this is FloatArray; the Flutter plugin marshals the same data as Float32List (never Float64List). Sample rate depends on the pipeline:

Pipeline

Direction

Sample rate

Frame / chunking

Notes

Silero VAD

input

16 000 Hz

exactly 512 samples per call (32 ms)

Stateful LSTM. Reset state between independent utterances; the model keeps a 64-sample internal carry-over, so you don’t overlap chunks yourself.

Whisper

input

16 000 Hz

any length

Long audio is auto-split into bundle-defined windows (the shipping thewhisper-large-v3-turbo bundle uses 10 s windows).

NeuTTS

output

24 000 Hz

streamer emits per-sentence chunks (variable length); batch mode emits one buffer of full duration

NeuCodec drives the rate (hop=320, token_rate=50).

Speaker ID

input

16 000 Hz

2.0 s window (pad / trim)

Practical consequences:

  • The mic stack must run at 16 kHz mono Float for VAD and ASR.

  • TTS output is always 24 kHz, even though VAD/ASR are 16 kHz. Resample TTS to 16 kHz or drive the player at 24 kHz if you route everything through one playback path.

Troubleshooting

Symptom

Likely cause

Fix

Token validation failed at first start

Missing / bad token, or offline on first run

Pass a valid token; be online for the one-time check

dlopen failed: … libQnnGenAiTransformer.so not found

A bundle that wants the GenAiTransformer Genie backend, without the QAIRT libs

Copy the QAIRT 2.51 libs — see Qualcomm QAIRT Runtime Libs (Genie Backend). No currently published model needs them

An error-level log line containing does not support usesCrossAttention on a VLM call

Benign. Logged by the bundled runtime; generation is unaffected

Ignore it

Could not create context from binary … err 5000

A bundle compiled with a newer QAIRT than the SDK’s runtime

Update the SDK; side-loaded bundles must be compiled with QAIRT ≤ 2.51

FastRPC / NPU skel won’t load in a native app

.so compressed in the APK

Set android:extractNativeLibs="true"

Duplicate .so at merge

ORT + core ship the same lib

Add the jniLibs.pickFirsts block above

First infer very slow

HF download

Wait for ready; later runs use the cache

Load fails naming the chip and what the repo publishes

device asks for a build the model does not publish for this phone

Leave device unset for the best available build

Phone runs low on storage

Models stay in app storage until removed

remove_model for one model, maintain() for what nothing uses

Flutter audio glitches / NaNs

Float64List or wrong rate

Use Float32List; match the audio table above

Flutter git dependency won’t resolve

Floating ref

Pin ref: v1.1.1

Secrets

The Flutter example apps read tokens at build time via String.fromEnvironment(...) and --dart-define-from-file=secrets.json. Each ships a secrets.example.json template — copy it to secrets.json and fill in your keys. secrets.json is covered by .gitignore; real keys never belong in source.

Also see

  • LLM (Language Model) — on-device chat (LFM2.5, LFM3, Qwen3.5) with streaming, multi-turn history, MTP and thinking

  • ASR (Whisper) — Whisper speech-to-text with automatic VAD chunking and long-audio stitching

  • VLM (Vision-Language) — on-device images + prompt → text (LFM2.5-VL, Gemma 4), batch and streaming

  • TTS (NeuTTS) — multilingual (9 languages) and nano (English) neural TTS with batch + push-based streaming

  • VAD (Voice Activity Detection) — Silero VAD: stateful per-chunk speech detection

  • Streaming — TTS / LLM streaming patterns, back-pressure, sentence segmentation, Flutter consumers

  • Voice Agent — end-to-end voice assistant (VAD → STT → LLM → TTS) with neural end-of-turn detection and barge-in

  • Model Management — choosing the device, availability probing, prefetch, installed models and updates, reclaiming space, revisions, the on-device model cache, per-component load/unload, bundled-engine paths, process-memory reporting

  • AI Packs (Google Play delivery) — ship models via Google Play AI packs (aipack:// engines source): pack modules, device targeting, delivery modes, availability

  • Speaker Embedding — ReDimNet2 speaker-id: enroll + cosine verification, and voice-agent speaker gating

  • Diarization — who spoke when (nemotron-diarization) and who said what (nemotron-multispeaker): streaming segments, speaker enrollment, and wiring the composite from models you already started

  • Licensing & Device Identity — how (apiToken, deviceId) is derived on Android, what counts as a device, reinstall behavior, device-integrity enforcement, online-validation behavior

  • TheStage Android SDK Product Terms — commercial / licensing summary: seat model and pricing via Service Request (no public rate card)

  • Logging & Diagnostics — the diagnostics ring, session log file, and the Flutter logs stream (no user content, sanitized paths)