{"id":28499907,"url":"https://github.com/kotlin/kotlin-ai-examples","last_synced_at":"2025-12-30T19:47:48.466Z","repository":{"id":272446187,"uuid":"867365585","full_name":"Kotlin/Kotlin-AI-Examples","owner":"Kotlin","description":"A collection of Kotlin-based examples featuring AI frameworks such as Spring AI, LangChain4j, and more — complete with Kotlin notebooks for hands-on learning.","archived":false,"fork":false,"pushed_at":"2025-05-26T15:00:05.000Z","size":45310,"stargazers_count":114,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T21:01:48.364Z","etag":null,"topics":["agents","ai","awesome","inference","kotlin","langchain","openai","spring"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kotlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-03T23:36:12.000Z","updated_at":"2025-06-22T11:06:26.000Z","dependencies_parsed_at":"2025-01-14T14:21:59.808Z","dependency_job_id":"df9070f2-3bda-417d-8ac7-4fb8f61f4fde","html_url":"https://github.com/Kotlin/Kotlin-AI-Examples","commit_stats":null,"previous_names":["devcrocod/kotlin-spring-ai-examples","devcrocod/kotlin-ai-examples","kotlin/kotlin-ai-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Kotlin/Kotlin-AI-Examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2FKotlin-AI-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2FKotlin-AI-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2FKotlin-AI-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2FKotlin-AI-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kotlin","download_url":"https://codeload.github.com/Kotlin/Kotlin-AI-Examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2FKotlin-AI-Examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263445764,"owners_count":23467609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","ai","awesome","inference","kotlin","langchain","openai","spring"],"created_at":"2025-06-08T15:05:24.132Z","updated_at":"2025-12-30T19:47:48.461Z","avatar_url":"https://github.com/Kotlin.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"https://raw.githubusercontent.com/devcrocod/Kotlin-AI-Examples/refs/heads/master/img/kotlin_icon.svg\" width=\"30\"/\u003e Kotlin \u003cimg src=\"https://raw.githubusercontent.com/devcrocod/Kotlin-AI-Examples/refs/heads/master/img/AI_icon.svg\" width=\"30\"/\u003e AI Examples\n\n**Kotlin AI Examples** is a repository showcasing various AI frameworks integrated into Kotlin-based projects.  \nHere you’ll find ready-to-use examples for Spring AI, LangChain4j, as well as interactive Kotlin notebooks.\n\n---\n\n## Contents\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"img/kotlin_icon.svg\" width=\"15\" alt=\"\"/\u003e \u003ca href=\"#kotlin-projects-projects\"\u003eKotlin Projects\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"img/ktn_plugin_icon.svg\" width=\"15\" alt=\"\"/\u003e \u003ca href=\"#kotlin-notebooks-notebooks\"\u003eKotlin Notebooks\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"#getting-started\"\u003e🚀 Getting Started\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"#prerequisites\"\u003e⚙ Prerequisites\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n---\n\n## Kotlin Projects ([`/projects`](projects))\n\nThis section contains complete Kotlin projects demonstrating AI integrations.\n\n### Spring AI Examples ([`/projects/spring-ai`](projects/spring-ai))\n\n- **[helloworld](projects/spring-ai/helloworld)**: Basic example of using Spring AI\n- **[spring-ai-examples](projects/spring-ai/spring-ai-examples)**: A comprehensive set of Spring AI feature\n  demonstrations and examples\n- **[playground-flight-booking](projects/spring-ai/playground-flight-booking)**: An AI-powered flight booking system\n  demo using multiple providers (OpenAI, VertexAI Gemini, Azure OpenAI, Groq, Anthropic Claude)\n- **[spring-ai-mcp-server-example](projects/spring-ai/spring-ai-mcp-server-example)**: spring mcp server sample\n- **[springAI-demo](projects/spring-ai/springAI-demo)**: a Spring Boot application with Spring AI and Kotlin that loads\n  Kotlin standard library documents into a Qdrant vector store, implements endpoints for similarity search and a\n  RAG-powered chat interface, and integrates an LLM for detailed, document-driven answers.\n\n### LangChain4j Examples ([`/projects/langchain4j`](projects/langchain4j))\n\n- **[langchain4j-spring-boot](projects/langchain4j/langchain4j-spring-boot)**: Examples of using LangChain4j with Kotlin\n  and Spring\n\n### MCP Examples ([`/projects/mcp`](projects/mcp))\n\n- **[mcp-demo](projects/mcp/mcp-demo)**: this tutorial briefly describes the process of creating an MCP server in Kotlin\n  to work with stock data from FMP, connecting it to Claude for Desktop,\n  and developing a custom client based on OpenAI using Compose.\n\n---\n\n## Kotlin Notebooks ([`/notebooks`](notebooks))\n\nA collection of interactive Jupyter notebooks in Kotlin, organized by project.\n\n### Spring AI Kotlin Notebooks ([`/notebooks/spring-ai`](notebooks/spring-ai))\n\n- **[SpringAI_Overview.ipynb](notebooks/spring-ai/SpringAI_Overview.ipynb)**: overview of Spring AI with Kotlin\n\n- **[Tutorial Series](notebooks/spring-ai/tutorials)**\n  This series of interactive notebooks provides a hands-on journey through Spring AI capabilities with Kotlin.\n  Each notebook builds on the previous one, guiding you from basic concepts to advanced AI integrations.\n\n  | Notebook                                                                                   | Description                                                                     |\n  |--------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n  | **[1. Intro](notebooks/spring-ai/tutorials/1.%20Intro.ipynb)**                             | Introduction to Spring AI fundamentals and setup with Kotlin                    |\n  | **[2. Prompts](notebooks/spring-ai/tutorials/2.%20Prompts.ipynb)**                         | Working with prompt engineering techniques and best practices                   |\n  | **[3. Streaming](notebooks/spring-ai/tutorials/3.%20Streaming.ipynb)**                     | Implementing streaming responses for real-time AI interactions                  |\n  | **[4. Tools](notebooks/spring-ai/tutorials/4.%20Tools.ipynb)**                             | Connecting LLMs to external tools and functions for enhanced capabilities       |\n  | **[5. Structured Outputs](notebooks/spring-ai/tutorials/5.%20Structured%20Outputs.ipynb)** | Getting formatted, structured data from LLMs for easier application integration |\n  | **[6. Advisors](notebooks/spring-ai/tutorials/6.%20Advisors.ipynb)**                       | Using Spring AI's Advisor system to enhance and customize AI interactions       |\n  | **[7. RAG](notebooks/spring-ai/tutorials/7.%20RAG.ipynb)**                                 | Implementing Retrieval-Augmented Generation with your own data sources          |\n  | **[8. Text-to-Image](notebooks/spring-ai/tutorials/8.%20text-to-image.ipynb)**             | Converting text descriptions into generated images with Spring AI               |\n  | **[9. Text-to-Audio](notebooks/spring-ai/tutorials/9.%20text-to-audio.ipynb)**             | Creating speech from text and transcribing audio with AI models                 |\n  | **[10. Local Model](notebooks/spring-ai/tutorials/10.%20Local%20model.ipynb)**             | Running AI models locally on your machine using Ollama and Spring AI            |\n\n### AI Agents Kotlin Notebooks ([`/notebooks/agents`](notebooks/agents))\n\n| Notebook                                                                           | Description                                                                                                                                 |\n|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| **[Prompt Chaining](notebooks/agents/Prompt-Chaining%20Workflow.ipynb)**           | Implements a sequential workflow that breaks complex tasks into simpler steps, where each LLM call processes the output of the previous one |\n| **[Routing](notebooks/agents/Routing%20Workflow.ipynb)**                           | Shows how to classify inputs and direct them to specialized handlers, optimizing for different types of requests                            |\n| **[Parallelization](notebooks/agents/Parallelization%20Workflow.ipynb)**           | Demonstrates running multiple LLM tasks simultaneously using Kotlin coroutines for improved performance                                     |\n| **[Orchestrator-Workers](notebooks/agents/Orchestrator-Workers%20Workflow.ipynb)** | Implements a pattern where a central LLM breaks down tasks dynamically and delegates them to specialized worker LLMs                        |\n| **[Evaluator-Optimizer](notebooks/agents/Evaluator-Optimizer%20Workflow.ipynb)**   | Creates a feedback loop where one LLM generates responses and another evaluates them for continuous improvement                             |\n\n### LangChain4j Kotlin Notebooks ([`/notebooks/langchain4j`](notebooks/langchain4j))\n\n- **[LangChain4j_Overview.ipynb](notebooks/langchain4j/LangChain4j_Overview.ipynb)**: overview of LangChain4j with\n  Kotlin, demonstrating how to work with chat models, manage prompts, streaming, and produce structured responses.\n- **[SummarizingDocuments.ipynb](notebooks/langchain4j/SummarizingDocuments.ipynb)**: demonstrates how to split large\n  text documents into smaller chunks, summarize each chunk with an AI model, and then merge the summaries into a concise\n  final result.\n\n### OpenAI Kotlin Notebooks ([`/notebooks/openai`](notebooks/openai))\n\n- **[OpenAI Java SDK Overview](notebooks/openai/OpenAI%20Java%20SDK%20Overview.ipynb)**: overview of the OpenAI\n  Java SDK, demonstrating how to install the library, initialize clients, make basic API calls with various parameters,\n  compare prompt effectiveness, and implement function calling with a practical weather example\n  — all written in Kotlin for JVM applications.\n- **[OpenAI Image Recognition](notebooks/openai/OpenAI%20Image%20Recognition.ipynb)**: demonstrates how to use OpenAI's\n  vision capabilities to analyze images by encoding them as base64,\n  sending them to GPT-4o via the OpenAI Java client, and displaying the AI's response about the image content.\n\n### Agents ReaCtor (ARC) Kotlin Notebooks ([`/notebooks/arc`](notebooks/arc))\n\n- **[WeatherAgent](notebooks/arc/WeatherAgent.ipynb)**: demonstrates creating an agent that retrieves real-time\n  weather data for a specified location via WeatherAPI\n- **[TaskManagerAgent](notebooks/arc/TaskManagerAgent.ipynb)**: task management agent showcasing how to create\n  a conversational AI that can add, remove, and list tasks through a clean API with function calling capabilities\n- **[SummarizerAgent](notebooks/arc/SummarizerAgent.ipynb)**: demonstrates creating an agent that summarizes web\n  pages (e.g., blog posts) by processing HTML and generating concise summaries\n\n### KInference Kotlin Notebooks ([`/notebooks/kInference`](notebooks/kinference))\n\n- **[KIClassification.ipynb](notebooks/kinference/KIClassification.ipynb)**: how to set up a classification environment\n  using the KIEngine framework, manage cached data files, and perform inference on input data.\n- **[KIGPT2.ipynb](notebooks/kinference/KIGPT2.ipynb)**: how to configure and run a GPT-2 model with KIEngine, handling\n  tokenization, caching, and text generation.\n- **[ORTClassification.ipynb](notebooks/kinference/ORTClassification.ipynb)**: how to perform classification using\n  ORT-based inference, handling data loading, caching, and model execution steps.\n- **[ORTGPT2.ipynb](notebooks/kinference/ORTGPT2.ipynb)**: how to run GPT-2 inference using the ORT engine, handling\n  tokenization, caching, and generation of text outputs.\n\n### xef.ai Kotlin Notebooks ([`/notebooks/xefAI`](notebooks/xefAI))\n\n- **[xefAI_Overview.ipynb](notebooks/xefAI/xefAI_Overview.ipynb)**: xef.ai overview notebook\n\n---\n\n## Getting Started\n\nEach project in the [`projects`](projects) directory has its own README with detailed instructions on how to run and use\nthe examples.\n\n---\n\n## Prerequisites\n\n- Java 17+\n- Kotlin\n- Appropriate AI provider API keys (see each project’s README for more details)\n\n---\n\n\u003e **Note**  \n\u003e Make sure you have the necessary access credentials for your chosen AI service (OpenAI, Azure, VertexAI, etc.) and the\n\u003e required dependencies in your build scripts (Gradle/Maven).\n\n\u003cp align=\"center\"\u003e\n  ⭐ If you enjoy this repository, please give it a star!\n\u003c/p\u003e\n\n---\n\n## License\n\nThis project is licensed under the [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fkotlin-ai-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkotlin%2Fkotlin-ai-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fkotlin-ai-examples/lists"}