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

# Configuration

> SDK configuration options and settings

## SDK Initialization

On Android, initialization requires three steps in this exact order:

```kotlin theme={null}
import com.runanywhere.sdk.storage.AndroidPlatformContext
import com.runanywhere.sdk.foundation.bridge.extensions.CppBridgeModelPaths

// 1. Initialize Android platform context (must be first)
AndroidPlatformContext.initialize(context)

// 2. Initialize SDK
RunAnywhere.initialize(environment = SDKEnvironment.DEVELOPMENT)

// 3. Set model storage base directory
val runanywherePath = context.filesDir.resolve("runanywhere").also { it.mkdirs() }
CppBridgeModelPaths.setBaseDirectory(runanywherePath.absolutePath)
```

<Warning>
  `AndroidPlatformContext.initialize()` **must** be called before `RunAnywhere.initialize()`. The
  `CppBridgeModelPaths.setBaseDirectory()` call tells the native C++ bridge where model files are
  stored on disk.
</Warning>

## SDKEnvironment

| Environment   | Log Level | Description                         |
| ------------- | --------- | ----------------------------------- |
| `DEVELOPMENT` | Debug     | Full logging, local testing         |
| `STAGING`     | Info      | Staging backend, moderate logging   |
| `PRODUCTION`  | Warning   | Production backend, minimal logging |

## LLM Generation Options

```kotlin theme={null}
data class LLMGenerationOptions(
    val maxTokens: Int = 100,           // Maximum tokens to generate
    val temperature: Float = 0.8f,      // Creativity (0.0-2.0)
    val topP: Float = 1.0f,             // Nucleus sampling (0.0-1.0)
    val stopSequences: List<String> = emptyList(),
    val streamingEnabled: Boolean = false,
    val preferredFramework: InferenceFramework? = null,
    val systemPrompt: String? = null
)
```

### Temperature Guide

| Value   | Use Case         | Description               |
| ------- | ---------------- | ------------------------- |
| 0.0-0.3 | Code, facts      | Deterministic, consistent |
| 0.4-0.7 | General Q\&A     | Balanced                  |
| 0.8-1.0 | Creative writing | More variety              |
| 1.1-2.0 | Brainstorming    | High creativity           |

## STT Options

```kotlin theme={null}
data class STTOptions(
    val language: String = "en",
    val detectLanguage: Boolean = false,
    val enablePunctuation: Boolean = true,
    val enableDiarization: Boolean = false,
    val maxSpeakers: Int? = null,
    val enableTimestamps: Boolean = true,
    val vocabularyFilter: List<String> = emptyList(),
    val audioFormat: AudioFormat = AudioFormat.PCM,
    val sampleRate: Int = 16000
)
```

## TTS Options

```kotlin theme={null}
data class TTSOptions(
    val voice: String? = null,
    val language: String = "en-US",
    val rate: Float = 1.0f,          // 0.0-2.0
    val pitch: Float = 1.0f,         // 0.0-2.0
    val volume: Float = 1.0f,        // 0.0-1.0
    val audioFormat: AudioFormat = AudioFormat.PCM,
    val sampleRate: Int = 22050,
    val useSSML: Boolean = false
)
```

## VAD Configuration

```kotlin theme={null}
data class VADConfiguration(
    val threshold: Float = 0.5f,
    val minSpeechDurationMs: Int = 250,
    val minSilenceDurationMs: Int = 300,
    val sampleRate: Int = 16000,
    val frameSizeMs: Int = 30
)
```

## Memory Considerations

Model memory requirements vary by size and quantization:

| Model Type   | Memory  | Device Requirements |
| ------------ | ------- | ------------------- |
| LLM 0.5B Q8  | \~500MB | Any Android 7.0+    |
| LLM 0.5B Q4  | \~300MB | Any Android 7.0+    |
| LLM 1B Q4    | \~600MB | 4GB+ RAM            |
| LLM 3B Q4    | \~2GB   | 6GB+ RAM            |
| Whisper Tiny | \~75MB  | Any device          |
| Whisper Base | \~150MB | Any device          |
| TTS Voice    | \~50MB  | Any device          |

<Warning>
  Always check available memory before loading large models. Loading models that exceed available
  RAM will crash the app.
</Warning>

## Model Registry

Register custom models:

```kotlin theme={null}
val modelInfo = RunAnywhere.registerModel(
    id = "my-custom-model",           // Optional, generated from URL if null
    name = "My Custom Model",
    url = "https://...",
    framework = InferenceFramework.LLAMA_CPP,
    modality = ModelCategory.LANGUAGE,
    memoryRequirement = 500_000_000L,  // 500MB
    supportsThinking = false
)
```

## InferenceFramework

```kotlin theme={null}
enum class InferenceFramework {
    ONNX,              // ONNX Runtime (STT/TTS/VAD)
    LLAMA_CPP,         // llama.cpp (LLM)
    FOUNDATION_MODELS, // Platform foundation models
    SYSTEM_TTS,        // System text-to-speech
    BUILT_IN,          // Simple built-in services
    NONE,              // No model needed
    UNKNOWN
}
```

## ModelCategory

```kotlin theme={null}
enum class ModelCategory {
    LANGUAGE,              // LLMs (text-to-text)
    SPEECH_RECOGNITION,    // STT (voice-to-text)
    SPEECH_SYNTHESIS,      // TTS (text-to-voice)
    VISION,                // Image understanding
    IMAGE_GENERATION,      // Text-to-image
    MULTIMODAL,            // Multiple modalities
    AUDIO                  // Audio processing
}
```

## SDK Lifecycle

```kotlin theme={null}
// Check initialization state
val isInit = RunAnywhere.isInitialized
val servicesReady = RunAnywhere.areServicesReady

// Get SDK version
val version = RunAnywhere.version

// Get current environment
val env = RunAnywhere.environment

// Reset SDK (clear all state)
RunAnywhere.reset()

// Cleanup resources without full reset
RunAnywhere.cleanup()
```
