Skip to content

ollama4j/ollama4j

Folders and files

NameName
Last commit message
Last commit date
Mar 19, 2025
Jul 27, 2024
Mar 19, 2025
Mar 18, 2025
Jul 27, 2024
Mar 11, 2025
Jul 15, 2024
Jan 23, 2024
Oct 26, 2023
Mar 11, 2025
Mar 11, 2025
Jan 23, 2024
Dec 1, 2023
Mar 18, 2025

Repository files navigation

Ollama4j

ollama4j-icon

A Java library (wrapper/binding) for Ollama server.

Find more details on the website.

GitHub stars GitHub forks GitHub watchers Contributors GitHub License

GitHub last commit codecov

Run Unit and Integration Tests Build Status

Table of Contents

How does it work?

Loading
  flowchart LR
    o4j[Ollama4j]
    o[Ollama Server]
    o4j -->|Communicates with| o;
    m[Models]
    subgraph Ollama Deployment
        direction TB
        o -->|Manages| m
    end

Requirements

Java

Installation

Note

We are now publishing the artifacts to both Maven Central and GitHub package repositories.

Track the releases here and update the dependency version according to your requirements.

For Maven

In your Maven project, add this dependency:

<dependency>
    <groupId>io.github.ollama4j</groupId>
    <artifactId>ollama4j</artifactId>
    <version>1.0.93</version>
</dependency>

Using GitHub's Maven Package Repository

  1. Add GitHub Maven Packages repository to your project's pom.xml or your settings.xml:
<repositories>
    <repository>
        <id>github</id>
        <name>GitHub Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/ollama4j/ollama4j</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
  1. Add GitHub server to settings.xml. (Usually available at ~/.m2/settings.xml)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>github</id>
            <username>YOUR-USERNAME</username>
            <password>YOUR-TOKEN</password>
        </server>
    </servers>
</settings>
  1. In your Maven project, add this dependency:
<dependency>
    <groupId>io.github.ollama4j</groupId>
    <artifactId>ollama4j</artifactId>
    <version>1.0.93</version>
</dependency>

For Gradle

  1. Add the dependency
dependencies {
    implementation 'io.github.ollama4j:ollama4j:1.0.93'
}

API Spec

Tip

Find the full API specifications on the website.

Development

Make sure you have pre-commit installed.

With brew:

brew install pre-commit

With pip:

pip install pre-commit

Setup dev environment

make dev

Build

make build

Run unit tests

make unit-tests

Run integration tests

Make sure you have Docker running as this uses testcontainers to run the integration tests on Ollama Docker container.

make integration-tests

Releases

Newer artifacts are published via GitHub Actions CI workflow when a new release is created from main branch.

Examples

The ollama4j-examples repository contains examples for using the Ollama4j library. You can explore it here.

⭐ Give us a Star!

If you like or are using this project to build your own, please give us a star. It's a free way to show your support.

Who's using Ollama4j?

# Project Name Description Link
1 Datafaker A library to generate fake data GitHub
2 Vaadin Web UI UI-Tester for interactions with Ollama via ollama4j GitHub
3 ollama-translator A Minecraft 1.20.6 Spigot plugin that translates all messages into a specific target language via Ollama GitHub
4 AI Player A Minecraft mod that adds an intelligent "second player" to the game Website, GitHub,
Reddit Thread
5 Ollama4j Web UI A web UI for Ollama written in Java using Spring Boot, Vaadin, and Ollama4j GitHub
6 JnsCLI A command-line tool for Jenkins that manages jobs, builds, and configurations, with AI-powered error analysis GitHub
7 Katie Backend An open-source AI-based question-answering platform for accessing private domain knowledge GitHub
8 TeleLlama3 Bot A question-answering Telegram bot Repo
9 moqui-wechat A moqui-wechat component GitHub
10 B4X A set of simple and powerful RAD tool for Desktop and Server development Website
11 Research Article Article: Large language model based mutations in genetic improvement - published on National Library of Medicine (National Center for Biotechnology Information) Website

Traction

Star History Chart

Get Involved

Open Issues Closed Issues Open PRs Closed PRs Discussions

Contributions are most welcome! Whether it's reporting a bug, proposing an enhancement, or helping with code - any sort of contribution is much appreciated.

🏷️ License and Citation

The code is available under MIT License.

If you find this project helpful in your research, please cite this work at

@misc{ollama4j2024,
    author       = {Amith Koujalgi},
    title        = {Ollama4j: A Java Library (Wrapper/Binding) for Ollama Server},
    year         = {2024},
    month        = {January},
    url          = {https://github.com/ollama4j/ollama4j}
}

References

Credits

The nomenclature and the icon have been adopted from the incredible Ollama project.

Thanks to the amazing contributors

Appreciate the work?

Buy Me A Coffee