n4nAI

Topic

Kotlin & Android LLM Integration

12 posts on kotlin & android llm integration — part of api integration on the n4n AI blog.

API integrationHow-to

WorkManager for background LLM API calls in Android

Implement reliable Android WorkManager LLM API calls with Kotlin: background jobs, retries, constraints, and progress reporting for production apps.

3 min read
API integrationGuide

ViewModel and StateFlow patterns for LLM chat apps

Practical patterns for building Android LLM chat apps with ViewModel and StateFlow: model state, stream tokens, handle cancellation, and avoid common pitfalls.

4 min read
API integrationHow-to

Unit testing LLM API calls in Kotlin with MockWebServer

Step-by-step kotlin mockwebserver llm api testing tutorial: mock OpenAI-compatible endpoints, assert requests, and run deterministic LLM client unit tests.

3 min read
API integrationHow-to

Streaming LLM responses in Android with Kotlin Flow

Learn how to implement android kotlin flow streaming llm responses over SSE with OkHttp, coroutines, and Compose for live token updates.

3 min read
API integrationHow-to

Storing LLM API keys in Android DataStore

Learn how to implement secure android datastore api key storage for LLM credentials with encrypted DataStore, Kotlin code, and step-by-step integration.

3 min read
API integrationTutorial

Parsing LLM responses in Kotlin with kotlinx.serialization

Hands-on Kotlin tutorial: parse LLM API responses with kotlinx.serialization llm api parsing, covering data models, streaming, and error handling.

2 min read
API integrationComparison

Ktor client vs Retrofit for Android LLM integration

A pragmatic head-to-head comparing Ktor and Retrofit for Android LLM integration across latency, streaming, ergonomics, and cost model.

5 min read
API integrationHow-to

Handling rate limits in Kotlin LLM API clients

Practical patterns for building resilient Kotlin LLM API clients that handle rate limits with retries, backoff, and fallback to keep workloads running.

3 min read
API integrationHow-to

Kotlin coroutines for async LLM API calls

Step-by-step guide to using Kotlin coroutines for async LLM API calls: build a suspended, streaming OpenAI-compatible client with Ktor, timeouts, and verification.

3 min read
API integrationTutorial

Calling the OpenAI API from Kotlin with Retrofit

Hands-on Kotlin Retrofit tutorial for the OpenAI API: step-by-step models, auth, streaming, and error handling with runnable code.

2 min read
API integrationTutorial

Building an Android chat app with n4n and Jetpack Compose

Step-by-step guide to building an Android chat app with n4n and Jetpack Compose: OpenAI-compatible streaming, Kotlin retrofit, and Compose UI.

2 min read
API integrationTutorial

Building a Jetpack Compose chat UI for an LLM API

Step-by-step tutorial to build a Jetpack Compose chat UI for an LLM API in Kotlin, covering streaming, state management, and error handling.

2 min read