ollama/cli is a small Clojure client for Ollama's HTTP API. It provides
focused functions for chat, text generation, and embeddings while keeping the
request payloads close to Ollama's native API.
ollama.cli.chat/chatollama.cli.generate/generateollama.cli.embed/embedollama.cli.configBefore you can use ollama/cli, ensure you have the Clojure CLI installed on your machine:
Run the full test suite with:
clojure -M:test
Build the checked-in snapshot release metadata with:
clojure -T:build jar
Install the snapshot to your local Maven cache with:
clojure -T:build install
Publish the snapshot to Clojars with a deploy token:
clojure -T:build jar
./bin/publish-clojars
The .env file should define CLOJARS_USERNAME and CLOJARS_DEPLOY_TOKEN. The publish wrapper maps that token to the env var expected by deps-deploy.
Here are basic examples of how to use ollama/cli in your Clojure application:
org.clojars.robson-kfu/ollama-cli {:mvn/version "0.0.3-SNAPSHOT"}
(ns my-app
(:require [ollama.cli.chat :as chat]
[ollama.cli.embed :as embed]
[ollama.cli.generate :as generate]))
(def messages
[{:role "user"
:content "Why is the sky blue?"}])
(def model "phi3")
(def response
(chat/chat {:model model :messages messages}))
(doseq [chunk response]
(print (str chunk)))
(def generated
(generate/generate {:model model
:prompt "Summarize Rayleigh scattering"
:stream false
:think true}))
(:response generated)
(def embeddings
(embed/embed {:model "embeddinggemma"
:input ["Why is the sky blue?"
"Why is the grass green?"]}))
(:embeddings embeddings)
Additional guides:
Contributions to ollama-cli are welcome and appreciated. Please refer to the CONTRIBUTING.md for guidelines on how to make contributions.
ollama-cli is open source and is licensed under the MIT License. See the LICENSE file for more details.
If you encounter any issues or have questions, feel free to open an issue on the project's GitHub repository or contact the maintainers directly.
Thank you for using or considering ollama-cli!
Can you improve this documentation? These fine people already did:
robson, robson.santos, robson.silva & Robson Silva dos SantosEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |