ollama4j/ollama4j

A simple Java library for interacting with Ollama server.

What it solves

Ollama4j provides a Java-native way to interact with the Ollama server, eliminating the need for Java developers to write manual HTTP requests to the Ollama REST API. It acts as a type-safe wrapper and binding that simplifies the integration of local LLMs into Java applications.

How it works

The library functions as a client-side wrapper that communicates directly with an Ollama server. It provides a structured Java API to manage models, send prompts, and handle responses, translating Java method calls into the appropriate API requests for the Ollama backend.

Who it’s for

Java developers who want to integrate local large language models (LLMs) into their software projects, such as Minecraft mods, web UIs, or data generation tools, without dealing with raw REST API calls.

Highlights

  • Comprehensive LLM Features: Supports single-turn text generation, multi-turn chat with history, and reasoning/thinking modes.
  • Advanced Tooling: Includes built-in tool/function calling via annotations and support for the Model Context Protocol (MCP).
  • Multimodal Capabilities: Supports image inputs for vision-capable models.
  • Model Management: Provides utilities to pull, create, delete, and list models directly from Java.
  • Developer Utilities: Features a type-safe options builder, async generation APIs, and built-in Prometheus metrics for performance monitoring.