A Kotlin client for an API gateway can be a thin wrapper around blocking HTTP calls, with a coroutine adapter bolted on. The nRouter Kotlin guide goes the other way: the SDK is coroutines-first from the start β suspend functions for calls, a cold Flow for streaming, and typed error subclasses you can branch on.
Full guide: https://nrouter.ai/docs/sdks/kotlin
Setup
The guide publishes the artifact to your local Maven cache ( ./gradlew clean check publishToMavenLocal ), then it's a normal Gradle dependency:
dependencies { implementation ( "ai.nrouter:nrouter-sdk-kotlin:3.1.2" ) }
Enter fullscreen mode
Exit fullscreen mode
NRouter() reads NROUTER_API_KEY from the environment, targets https://api.nrouter.ai/v1 , and dispatches on Dispatchers.IO , so calls don't block your caller's context. (For Android apps, the guide points to the separate nrouter-sdk-android artifact.)
A call, and what comes back
suspend fun main ( ) { val client = NRouter ( )
val result = client . chatCompletions ( JSONObject ( ) .β¦