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
[]
= "0.3.0"
= "0.2.3"
= { = "1", = ["macros", "rt-multi-thread"] }
Or via the umbrella crate: chat-rs = { version = "0.4.0", features = ["ollama"] }.
Usage
use OllamaBuilder;
use ;
let client = new
.with_model
.build;
let mut chat = new.with_model.build;
let mut msgs = from_user;
let response = chat.complete.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
streamfeature) - Embeddings — vector embeddings via
.with_embeddings() - Model management —
.pull()calls Ollama's native/api/pullto fetch a model if missing
Pull and Build
let client = new
.with_model
.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:
= { = "0.2.3", = ["stream"] }