Kotlin logo

Kotlin

A concise multiplatform language developed by JetBrains

The Kotlin AI Stack: Build AI Agents With Koog, Code Smarter With Junie, and More

AI is changing how we build software, and Kotlin is ready to meet that change by empowering developers to build AI-powered apps and by enhancing the developer experience through AI-based tools.

This post explores both angles: the tools for developing AI-powered apps, both from JetBrains and from the community, and the ways Kotlin is evolving to make development more productive by incorporating AI tools.

Highlights

Using Kotlin to develop AI-powered apps

Kotlin isn’t just well-suited for AI – it’s already being used in large-scale AI systems. Deutsche Telekom, for example, used Kotlin to build one of Europe’s largest LLM-powered chatbots. At JetBrains, we rely on Kotlin to build our entire AI stack. Junie and AI Assistant in our IDEs, Koog for agents, and Kineto for no-code app creation are all written in Kotlin.

What makes Kotlin a strong fit for AI development is how naturally it supports everything from low-level model access to structured, multi-step agent logic. Let’s walk through what that looks like in practice. 

1. Starting simple: Calling AI models via SDKs

One of the simplest ways to integrate AI into your Kotlin app is by using the Java SDKs from OpenAI or Anthropic (which are both written in Kotlin under the hood). This gives you low-level access to models with full control over prompts, parameters, and data handling.

It’s perfect for experiments or building minimal AI features like a quick chatbot, summarizer, or code generator.

Here are some examples to explore:

OpenAI SDK

Anthropic SDK 

2. Leveling up: Using high-level libraries like Spring AI

When you want to move beyond raw API calls, Spring AI offers a smooth experience for Kotlin users.

It allows you to:

  • Swap model providers with minimal effort.
  • Register Kotlin functions as AI tools.
  • Embed structured AI interactions directly into your application logic.

This makes it easier to build useful features without getting bogged down in infrastructure details. 

Spring AI

If you want to see it in action, check out these resources from the Kotlin-AI-Examples repository:

Other options like LangChain4j are also available, and you can find a Kotlin-based LangChain4j Spring Boot example in the same repository.

3. Standardizing: Exposing tools via the Model Context Protocol (MCP)

As your AI tools get more useful, you’ll probably want to share them – across agents, teams, or even apps. But how do you make sure they’re accessible, consistent, and easy to plug in?

That’s where the Model Context Protocol (MCP) comes in, and there’s an official MCP Kotlin SDK to help you implement it. The MCP is a standard that defines how agents can discover and use tools without custom integrations or glue code. With the MCP Kotlin SDK, you can expose your tools in a way that works seamlessly with any compliant agent. It’s a simple way to make your Kotlin code part of a larger, connected AI system.

Kotlin MCP SDK

Learn more:

4. Using Koog: Building and running AI Agents in Kotlin

At the highest level, you may want to create intelligent agents – systems that can reason, adapt, and use tools.

JetBrains has open-sourced Koog, the JVM’s most advanced AI framework and the first to bring full-scale agentic flows to backend, Android, and iOS. With Koog, you build agents that are observable, testable, and deployable anywhere Kotlin runs.

Koog provides:

  • Persistence and checkpointing to resume agents exactly where they left off.
  • Observability via OpenTelemetry with Langfuse and W&B Weave.
  • Structured output and typed streaming for predictable results and real-time UIs.
  • Smart retries and robust error handling at both workflow and client levels.
  • Drop-in integrations with Spring Boot and a new Ktor plugin.
  • Multi-model flexibility to swap or route tasks between LLMs without losing context.
  • MCP tool support, RAG, memory, and reusable graph-based strategies for designing advanced agent logic.

Because Koog is Kotlin Multiplatform, your agents can run not just on the JVM but also on Android, JS/WasmJS, and iOS. Whether you’re prototyping a simple agent or building a more complex system with tools and memory, Koog gives you the flexibility to start small and have your project evolve as it grows.

Try Koog 

Other agent frameworks are also emerging in the Kotlin ecosystem, including:

  • Arc – a custom agent framework developed by Deutsche Telekom for their LLM-powered chatbot.
  • Embable – an open-source Kotlin-based framework built on Spring and LangChain4j.
  • Spring AI Alibaba – an extension of Spring AI focused on LLM tool orchestration.

These options, each with different approaches and integrations, reflect the growing interest in using Kotlin to build agents.

AI tooling for Kotlin

While Kotlin is a powerful language for building AI systems, it’s also being supplemented by AI-based tools to make your development workflow faster and more enjoyable. To help you stay focused and in control, we’re integrating AI tools into your IDE experience.

Junie: AI coding agent in JetBrains IDEs

Junie is JetBrains’ new AI coding agent. It can take care of your routine tasks, update complex parts of your project, or even fully take over some of them – giving you more time to focus on the fun and creative parts of coding. And it works particularly well with Kotlin.

Unlike a generic tool for autocompletion, it handles structured tasks, which means it can:

  • Build full features end to end (for example, a random talk generator for the KotlinConf app).
  • Plan architectural changes.
  • Execute tests.
  • Suggest improvements.

JetBrains is also working on Junie’s ability to contribute code to open-source projects. It’s already available in GitHub as part of an Early Access Program, where it can analyze issues, suggest fixes, and open pull requests. Join the waitlist to try it for free.

Mellum: Now open source

Powering Junie is Mellum, JetBrains’ in-house LLM for code, already in production and now open source. It powers code completion in JetBrains IDEs, and there’s a version of it fine-tuned specifically for Kotlin. 

This means the Kotlin community can now experiment with, contribute to, and build their own custom tooling on top of Mellum.

Why Kotlin?

In short, here’s what makes Kotlin a natural fit for both building with AI and being supported by it:

  • Modern language features that make code clear, safe, and concise.
  • Seamless Java interop for accessing existing AI SDKs and libraries.
  • Multiplatform support for sharing logic between server-side, mobile, and web applications.
  • A growing ecosystem of Kotlin-native AI libraries and frameworks, including Koog, the MCP Kotlin SDK, and Spring AI integration.
  • An AI-powered development experience through JetBrains AI Assistant and Junie, which is integrated into IntelliJ IDEA and available via plugins in Android Studio

Other resources to read and watch

image description