Loading the Model
While cloud APIs let you use models immediately after creating a client, LeapSDK requires you to explicitly load the model first — because the model runs locally. This step generally takes a few seconds depending on model size and device performance. On cloud API, you create an API client:- Kotlin
- Swift
Requesting Generation
In the cloud API,client.chat.completions.create returns a stream object:
generateResponse on the conversation object to get a stream for generation. Since the model runner already contains all model information, you don’t need to specify the model name again:
- Kotlin
- Swift
Processing Generated Content
In cloud API Python code, a for-loop retrieves the content:- Kotlin
- Swift
In LeapSDK, call
onEach on the Kotlin Flow to process content. Call collect() to start generation:Async Context
Most LeapSDK APIs are asynchronous. You need an async context to execute them:- Kotlin
- Swift
LeapSDK Android APIs use Kotlin coroutines. Use
viewModelScope in a ViewModel: