Topic
Kotlin & Android LLM Integration
12 posts on kotlin & android llm integration — part of api integration on the n4n AI blog.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
More topics in api integration
- Function Calling Fundamentals27
- Structured Outputs & JSON Mode19
- cURL LLM API Cookbook15
- Integrating GPT-5, Claude Opus 4.8, Gemini 3, Llama 4 & More via One API15
- Next.js AI Chat Integration (App Router + Vercel AI SDK)15
- FastAPI LLM Backend Integration14
- Go net/http LLM API Client14
- LangChain + OpenAI-Compatible Gateway Integration14
- Node.js OpenAI-Compatible SDK Integration14
- Python + OpenAI-Compatible SDK Integration14
- Rate Limits, Retries & Backoff Strategies14
- React Streaming Chat UI Patterns14