Skip to main content

Build AI Agents with Kotlin

The official Kotlin framework for building predictable, fault-tolerant and enterprise-ready AI agents across all platforms

Why Koog?

Koog is a Kotlin-based framework designed to build and run AI agents entirely in idiomatic Kotlin. It lets you create agents that can interact with tools, handle complex workflows, and communicate with users.

Multiplatform

Deploy agents across JVM, JS, WasmJS, Android, and iOS targets using Kotlin Multiplatform

Fault-Tolerant

Built-in retries and state persistence to handle failures gracefully

Enterprise-Ready

Integrate with Spring Boot and Ktor for production deployments

Type-Safe DSL

Idiomatic Kotlin DSL designed specifically for JVM and Kotlin developers

Multiple LLM Providers

Support for OpenAI, Anthropic, Google, Ollama, DeepSeek, and more

Observability

Built-in OpenTelemetry support for monitoring and debugging

Quick Example

Get started with a simple agent in just a few lines of Kotlin:
import ai.koog.agents.core.agent.AIAgent
import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
import ai.koog.prompt.executor.clients.openai.OpenAIModels

suspend fun main() {
    val apiKey = System.getenv("OPENAI_API_KEY")
    
    val agent = AIAgent(
        promptExecutor = simpleOpenAIExecutor(apiKey),
        systemPrompt = "You are a helpful assistant. Answer user questions concisely.",
        llmModel = OpenAIModels.Chat.GPT4o
    )
    
    val result = agent.run("Hello! How can you help me?")
    println(result)
}

Key Features

Intelligent History Compression

Optimize token usage while maintaining context in long-running conversations

Graph-Based Workflows

Design complex agent behaviors using intuitive graph-based workflows

Model Context Protocol

Use MCP tools in AI agents for enhanced functionality

Agent Client Protocol

Build ACP-compliant agents that communicate with standardized client applications

Knowledge Retrieval

Retain and retrieve knowledge across conversations using vector embeddings and RAG

Streaming API

Process responses in real-time with streaming support and parallel tool calls

Custom Tools

Enhance your agents with tools that access external systems and APIs

Comprehensive Testing

Debug and test agents with detailed tracing and mocking utilities

Get Started

Quickstart

Build your first AI agent in minutes

Installation

Add Koog to your Kotlin project

Core Concepts

Learn the fundamental concepts behind Koog

Examples

Explore real-world examples and use cases

Supported LLM Providers

OpenAI

GPT-4, GPT-3.5, and more

Anthropic

Claude 3 and Claude 4

Google

Gemini models

Ollama

Local LLM deployment

OpenRouter

Access multiple models

DeepSeek

DeepSeek models

Bedrock

AWS Bedrock integration

View All

See all providers

Community and Support

Slack Channel

Join our community on Slack

GitHub

Star us on GitHub and contribute

Issue Tracker

Report bugs and request features

API Reference

Explore the complete API documentation

Build docs developers (and LLMs) love