Skip to main content

ollama_client/
lib.rs

1//! # ollama-client
2//!
3//! A Rust client library for the [Ollama](https://ollama.com) API.
4//!
5//! Covers all Ollama API endpoints: chat, generate, embeddings, model management
6//! (list, show, copy, delete, pull, push, create), running models, blobs, and version.
7//!
8//! ## Async usage
9//!
10//! ```no_run
11//! use ollama_client::{OllamaClient, types::Message};
12//!
13//! # async fn example() -> ollama_client::Result<()> {
14//! let client = OllamaClient::new();
15//! let response = client.chat()
16//!     .model("gemma4")
17//!     .messages(vec![Message::user("Hello!")])
18//!     .send()
19//!     .await?;
20//! println!("{}", response.message.content);
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! ## Blocking usage (feature `blocking`, enabled by default)
26//!
27//! ```no_run
28//! use ollama_client::blocking::BlockingClient;
29//! use ollama_client::types::Message;
30//!
31//! # fn example() -> ollama_client::Result<()> {
32//! let client = BlockingClient::new();
33//! let response = client.chat()
34//!     .model("gemma4")
35//!     .messages(vec![Message::user("Hello!")])
36//!     .send()?;
37//! println!("{}", response.message.content);
38//! # Ok(())
39//! # }
40//! ```
41
42pub mod client;
43pub mod error;
44pub mod streaming;
45pub mod types;
46
47#[cfg(feature = "blocking")]
48pub mod blocking;
49
50pub use client::{OllamaClient, OllamaClientBuilder};
51pub use error::{OllamaError, Result};
52
53// M-TYPES-SEND: compile-time assertions that key types are Send + Sync.
54fn _assert_send_sync() {
55    fn send<T: Send>() {}
56    fn sync<T: Sync>() {}
57    send::<OllamaClient>();
58    sync::<OllamaClient>();
59    send::<OllamaClientBuilder>();
60    send::<OllamaError>();
61}