> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> RunAnywhere Kotlin SDK for Android

<div style={{ marginBottom: '24px' }}>
  <button
    id="copy-all-btn"
    onClick={() => {
  const btn = document.getElementById('copy-all-btn')
  btn.innerText = 'Copying...'
  fetch('/llms-full.txt')
    .then((res) => (res.ok ? res.text() : Promise.reject()))
    .then((text) => {
      const sections = text.split(/(?=^# )/m)
      const filtered = sections.filter((s) =>
        s.includes('Source: https://docs.runanywhere.ai/kotlin/')
      )
      if (filtered.length === 0) throw new Error('empty')
      return filtered.join('\n')
    })
    .catch(() => document.getElementById('full-guide-content').innerText)
    .then((text) => navigator.clipboard.writeText(text))
    .then(() => {
      btn.innerText = 'Copied!'
      setTimeout(() => {
        btn.innerText = 'Copy Full Kotlin SDK Docs for AI Agent'
      }, 2000)
    })
}}
    style={{
  background: 'linear-gradient(135deg, #ff6900 0%, #fb2c36 100%)',
  color: 'white',
  border: 'none',
  padding: '12px 24px',
  borderRadius: '8px',
  fontSize: '16px',
  fontWeight: '600',
  cursor: 'pointer',
  display: 'flex',
  alignItems: 'center',
  gap: '8px',
}}
  >
    Copy Full Kotlin SDK Docs for AI Agent
  </button>
</div>

<div id="full-guide-content">
  ## Overview

  The **RunAnywhere Kotlin SDK** is a production-grade, on-device AI SDK for Android. It enables developers to run AI models directly on Android devices without requiring network connectivity for inference, ensuring minimal latency and maximum privacy for your users.

  The SDK provides a unified interface to multiple AI capabilities:

  <CardGroup cols={3}>
    <Card title="LLM" icon="brain" href="/kotlin/llm/chat">
      Text generation with streaming support via Kotlin Flows
    </Card>

    <Card title="VLM" icon="eye" href="/kotlin/vlm">
      Vision language models for image understanding
    </Card>

    <Card title="LoRA" icon="layer-group" href="/kotlin/lora">
      Hot-swap fine-tuned adapters at runtime
    </Card>

    <Card title="RAG" icon="magnifying-glass" href="/kotlin/rag">
      On-device retrieval-augmented generation
    </Card>

    <Card title="STT" icon="microphone" href="/kotlin/stt/transcribe">
      Speech-to-text transcription with Whisper models
    </Card>

    <Card title="TTS" icon="volume-high" href="/kotlin/tts/synthesize">
      Neural voice synthesis with Sherpa-ONNX
    </Card>

    <Card title="Tool Calling" icon="wrench" href="/kotlin/tool-calling">
      Function calling with typed tool definitions
    </Card>

    <Card title="VAD" icon="waveform" href="/kotlin/vad">
      Real-time voice activity detection
    </Card>

    <Card title="Voice Agent" icon="phone" href="/kotlin/voice-agent">
      Full VAD → STT → LLM → TTS pipeline
    </Card>
  </CardGroup>

  ## Key Capabilities

  * **Multi-backend architecture** – Choose from LlamaCPP (GGUF models) or ONNX Runtime
  * **GPU acceleration** – Hardware-accelerated inference on supported devices
  * **Kotlin-first** – Built with Coroutines and Flows for async operations
  * **LoRA fine-tuning** – Hot-swap adapters at runtime without reloading models
  * **On-device RAG** – Vector search and grounded generation, fully offline
  * **Production-ready** – Built-in analytics, logging, and model lifecycle management

  ## Core Philosophy

  <AccordionGroup>
    <Accordion title="On-Device First" icon="microchip">
      All AI inference runs locally, ensuring low latency and data privacy. Once models are
      downloaded, no network connection is required for inference.
    </Accordion>

    <Accordion title="Modular Architecture" icon="puzzle-piece">
      Backend engines are optional modules—include only what you need. This keeps your APK size
      minimal.
    </Accordion>

    <Accordion title="Privacy by Design" icon="shield-check">
      Audio and text data never leaves the device unless explicitly configured. Only anonymous
      analytics are collected by default.
    </Accordion>

    <Accordion title="Platform Parity" icon="equals">
      API mirrors the iOS Swift SDK for consistent cross-platform development.
    </Accordion>
  </AccordionGroup>

  ## Features

  ### Language Models (LLM)

  * On-device text generation with streaming support
  * Kotlin Flow-based token streaming
  * System prompts and customizable generation parameters
  * Support for thinking/reasoning models
  * LlamaCPP backend for GGUF models

  ### Speech-to-Text (STT)

  * Real-time streaming transcription
  * Batch audio transcription
  * Multi-language support
  * Whisper-based models via ONNX Runtime

  ### Text-to-Speech (TTS)

  * Neural voice synthesis with Sherpa-ONNX
  * System voices via Android TTS
  * Streaming audio generation for long text
  * Customizable voice, pitch, rate, and volume

  ### Voice Activity Detection (VAD)

  * Energy-based speech detection with Silero VAD
  * Configurable sensitivity thresholds
  * Real-time audio stream processing

  ### Vision Language Models (VLM)

  * Multimodal image + text inference with Kotlin Flow streaming
  * VLMImage from file paths with photo picker integration
  * Multi-file model registration with GGUF files
  * Cancellation support and state checking

  ### LoRA Adapters

  * Hot-swap fine-tuned adapters at runtime without reloading the base model
  * Stack multiple adapters simultaneously with independent scale factors
  * Compatibility checking before loading
  * Adapter catalog for discovery and management

  ### RAG (Retrieval-Augmented Generation)

  * Fully on-device document Q\&A pipeline
  * ONNX embedding models with vector similarity search
  * Automatic text chunking with configurable size and overlap
  * Grounded LLM generation with retrieved context
  * Timing metrics for retrieval and generation phases

  ### Tool Calling

  * Register typed tool definitions via RunAnywhereToolCalling
  * Automatic tool execution with configurable limits
  * Multi-tool chaining for complex workflows
  * ToolValue factory methods with string and number support

  ### Voice Agent Pipeline

  * Full VAD → STT → LLM → TTS orchestration
  * Complete voice conversation flow
  * Streaming and batch processing modes

  ## System Requirements

  | Platform | Minimum Version |
  | -------- | --------------- |
  | Android  | API 24 (7.0+)   |

  **Kotlin:** 2.0+

  **Gradle:** 8.0+

  <Note>
    ARM64 devices are recommended for best performance. GPU acceleration provides significant speedups
    on supported devices.
  </Note>

  ## SDK Modules

  | Module                 | Purpose                                   |
  | ---------------------- | ----------------------------------------- |
  | `runanywhere-core`     | Core SDK (required)                       |
  | `runanywhere-llamacpp` | LLM/VLM text generation + LoRA (GGUF)     |
  | `runanywhere-onnx`     | STT/TTS/VAD via ONNX Runtime              |
  | `runanywhere-rag`      | RAG pipeline (embeddings + vector search) |

  ## Architecture

  ```mermaid theme={null}
  graph TB
      A(Your Android App)
      A --> B(RunAnywhere SDK)

      B --> C(LLM + LoRA)
      B --> D(STT)
      B --> E(TTS)
      B --> F(VAD)
      B --> G(VLM)
      B --> K(RAG)

      B --> H2(VoiceAgent - Orchestration)

      C & D & E & F & G & K & H2 --> H(Native Layer - C++)

      H --> I("llama.cpp (LLM/VLM/LoRA)")
      H --> J(ONNX Runtime + Sherpa-ONNX)
      H --> L(RAG Engine)

      style A fill:#334155,color:#fff,stroke:#334155
      style B fill:#ff6900,color:#fff,stroke:#ff6900
      style C fill:#475569,color:#fff,stroke:#475569
      style D fill:#475569,color:#fff,stroke:#475569
      style E fill:#475569,color:#fff,stroke:#475569
      style F fill:#475569,color:#fff,stroke:#475569
      style G fill:#475569,color:#fff,stroke:#475569
      style K fill:#475569,color:#fff,stroke:#475569
      style H2 fill:#ff6900,color:#fff,stroke:#ff6900
      style H fill:#fb2c36,color:#fff,stroke:#fb2c36
      style I fill:#475569,color:#fff,stroke:#475569
      style J fill:#475569,color:#fff,stroke:#475569
      style L fill:#475569,color:#fff,stroke:#475569
  ```

  ## Next Steps

  <CardGroup cols={2}>
    <Card title="Installation" icon="download" href="/kotlin/installation">
      Add the SDK to your project via Gradle
    </Card>

    <Card title="Quick Start" icon="rocket" href="/kotlin/quick-start">
      Build your first AI feature in minutes
    </Card>
  </CardGroup>
</div>
