SDK Initialization
RunAnywhere.initialize(
apiKey = "your-api-key", // Optional for development
baseURL = "https://api.runanywhere.ai", // Custom API endpoint
environment = SDKEnvironment.DEVELOPMENT
)
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
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
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
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
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 |
Always check available memory before loading large models. Loading models that exceed available
RAM will crash the app.
Model Registry
Register custom models:
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
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
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
// 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()