chat-ollama 0.2.4

Ollama provider for chat-rs (OpenAI-compatible endpoint).
Documentation

chat-ollama

Ollama provider for chat-rs. Thin wrapper over chat-completions targeting Ollama's OpenAI-compatible endpoint at http://localhost:11434/v1, with extras (.pull() against the native /api/pull).

Install

[dependencies]
chat-core = "0.4.0"
chat-ollama = "0.2.4"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Or via the umbrella crate: chat-rs = { version = "0.5.0", features = ["ollama"] }.

Usage

use chat_ollama::OllamaBuilder;
use chat_core::{builder::ChatBuilder, types::messages};

let client = OllamaBuilder::new()
    .with_model("llama3.2")
    .build();

let mut chat = ChatBuilder::new().with_model(client).build();

let mut msgs = messages::from_user(vec!["Hello!"]);
let response = chat.complete(&mut msgs).await?;

No API key required by default. Honors OLLAMA_HOST if you point at a remote daemon.

Capabilities

  • Completions — text generation with tool calling and structured output
  • Streaming — token-by-token output (requires stream feature)
  • Embeddings — vector embeddings via .with_embeddings()
  • Model management.pull() calls Ollama's native /api/pull to fetch a model if missing

Pull and Build

let client = OllamaBuilder::new()
    .with_model("llama3.2")
    .pull().await?   // downloads the model if not present
    .build();

Custom Endpoint / Transport

Override the base URL with .with_base_url(...) or supply a custom transport with .with_transport(...). OLLAMA_HOST is read automatically if set.

Feature Flags

Streaming is gated on the stream feature:

chat-ollama = { version = "0.2.3", features = ["stream"] }