# Onde Kotlin SDK

> com.ondeinference:onde-inference is the Kotlin SDK for Onde Inference. It runs GGUF language models on the device in Android 8.0+ apps and on the JVM, with suspend functions and Flow streaming, from Maven Central. Current release: 1.5.0. Dual-licensed MIT and Apache 2.0.

- Web page: https://ondeinference.com/sdk/kotlin
- Maven Central: https://central.sonatype.com/artifact/com.ondeinference/onde-inference
- Source: https://github.com/ondeinference/onde/tree/main/sdk/kotlin

## Install

```kotlin
// build.gradle.kts
dependencies {
    implementation("com.ondeinference:onde-inference:1.5.0")
}
```

## Quick start

```kotlin
import com.ondeinference.onde.OndeInference

val onde = OndeInference(applicationContext)

lifecycleScope.launch {
    // Downloads the default model from Hugging Face on first run.
    onde.loadDefaultModel(systemPrompt = "You are a helpful, concise assistant.")

    val result = onde.chat("What is the capital of Sweden?")
    println(result.text)
}
```

## Streaming

```kotlin
lifecycleScope.launch {
    onde.stream("Write a haiku about the ocean.").collect { chunk ->
        textView.append(chunk.delta)
        if (chunk.done) println("[done]")
    }
}
```

## FAQ

### How do I add Onde to an Android app?

Add `implementation("com.ondeinference:onde-inference:1.5.0")` to `build.gradle.kts` and the `INTERNET` permission to `AndroidManifest.xml` for the first model download. Create `OndeInference(applicationContext)`, then call `loadDefaultModel` and `chat` from a coroutine.

### Which Android versions and devices are supported?

Android 8.0 (API 26) and newer. The engine ships for four ABIs: arm64-v8a, armeabi-v7a, x86_64 and x86, so it runs on phones and on emulators.

### Does the Kotlin SDK run outside Android?

Yes. It is a Kotlin Multiplatform library with a JVM target, and the JAR bundles native libraries for macOS (Apple silicon and Intel) and Linux (x86_64 and arm64).

### Which model loads by default?

`loadDefaultModel` loads Qwen 2.5 Coder 1.5B (about 941 MB, Q4_K_M) on Android and Qwen 2.5 Coder 3B (about 1.93 GB, Q4_K_M) on the JVM. It needs about 1.1 GB of free storage on Android.

### How do I stream tokens in Kotlin?

`onde.stream(message)` returns a `Flow<StreamChunk>`. Collect it in a coroutine and append each chunk's `delta` to your UI; the last chunk has `done` set to true.

### Does the Kotlin SDK need a network connection?

Only for the first model download. The model is fetched from Hugging Face the first time it loads and cached on the device. After that, inference runs on the device with no network request, and prompts never leave it.

### Is the Kotlin SDK free and open source?

Yes. The Kotlin SDK is free and dual-licensed under MIT and Apache 2.0. The engine source is at github.com/ondeinference/onde.
