Kotlin for AI-powered app development
Kotlin provides a modern and pragmatic foundation for building AI-powered applications.
It can be used across platforms, integrates well with established AI frameworks, and supports common AI development patterns.
Koog
Koog is an open‑source framework from JetBrains for building AI agents, from simple to complex. It provides multiplatform support, Spring Boot and Ktor integrations, an idiomatic DSL, and production‑ready features out of the box.
Create a simple agent in a few lines
Key features
Support for multiplatform development. Multiplatform support enables agentic application development for the JVM, JavaScript, WebAssembly, Android, and iOS.
Reliability and fault-tolerance. With built-in retries, Koog lets developers handle failures such as timeouts or tool errors. Agent persistence makes it possible to restore full agent state machines instead of just chat messages.
Built-in history compression techniques for long contexts. Koog comes with advanced strategies to compress and manage long-running conversations without extra setup.
Enterprise-ready integrations. Koog integrates with popular JVM frameworks like Spring Boot and Ktor.
Observability with OpenTelemetry exporters. Koog offers ready-to-use integration with popular observability providers such as W&B Weave and Langfuse for monitoring and debugging AI applications.
LLM switching and seamless history adaptation. Koog allows switching to a different LLM with a new set of tools at any point, without losing the existing conversation history. It also enables rerouting between multiple LLM providers, including OpenAI, Anthropic, Google, and others. You can run agents locally with local models through Koog's integration with Ollama.
Integration with JVM and Kotlin applications. Koog provides an idiomatic, type-safe DSL specifically for the JVM and Kotlin developers.
Model Context Protocol (MCP) integration. Koog enables the use of MCP tools in agents.
Knowledge retrieval and memory. With embeddings, ranked document storage, and shared agent memory, Koog itself actively retains knowledge across conversations.
Streaming capabilities. Koog lets developers process responses in real-time with streaming support and parallel tool calls.
Where to start
Explore Koog capabilities in the Overview.
Build your first Koog agent with the Getting started guide.
See the latest updates in the Koog release notes.
Learn from the examples.
Model Context Protocol (MCP) Kotlin SDK
The MCP Kotlin SDK is a Kotlin Multiplatform implementation of the Model Context Protocol. The SDK lets developers build AI-powered applications in Kotlin and integrate with LLM surfaces across the JVM, WebAssembly, and iOS.
With the MCP Kotlin SDK, you can:
Provide context to LLMs in a structured and standardized way by separating context handling from LLM interaction.
Build MCP clients that consume resources from existing servers.
Create MCP servers that expose prompts, tools, and resources to LLMs.
Use standard communication transports such as stdio, SSE, and WebSocket.
Handle all MCP protocol messages and lifecycle events.
Explore other AI-powered application scenarios
Thanks to seamless Java interoperability and Kotlin Multiplatform, you can combine Kotlin with established AI SDKs and frameworks, build backend and desktop/mobile UIs, and adopt patterns like RAG and agent‑based workflows.
Connect to major model providers
Use Kotlin to connect to major model providers such as OpenAI, Anthropic, Google, and others:
OpenAI — official Java SDK for the OpenAI API. It covers responses and chats, images, and audio.
Anthropic (Claude) — official Java SDK for the Claude Messages API. It includes modules for Vertex AI and Bedrock integrations.
Google AI (Gemini / Vertex AI) — official Java SDK with a single client that switches between Gemini API and Vertex AI.
Azure OpenAI — official Java client for the Azure OpenAI Service. It supports chat completions and embeddings.
AWS Bedrock — official SDKs to invoke foundation models. It includes the Kotlin SDK and Java SDK for Bedrock and Bedrock Runtime.
Create RAG pipelines and agent-based apps
Spring AI — multi-provider abstraction for prompts, chats, embeddings, tools and function calling, and vector stores.
LangChain4j — JVM toolkit with Kotlin extensions for prompts, tools, retrieval-augmented generation (RAG) pipelines, and agents.
What's next
Complete the Create a Kotlin app that answers questions with Spring AI tutorial to learn more about using Spring AI with Kotlin in IntelliJ IDEA
Join the Kotlin community to connect with other developers building AI applications with Kotlin