Thank you for your interest in contributing to ollama-client-rs. This project provides a high-performance, idiomatic, and infrastructure-first Rust client for the Ollama API.
We focus on being a precision thin layer—prioritizing raw API fidelity, reliability, and architectural clarity.
- Rust: Latest stable version (Edition 2021).
- Ollama: A running Ollama instance with at least one model pulled (e.g.
ollama pull llama3.1:8b).
-
Clone the repository:
git clone https://github.com/Adriftdev/ollama-client.git cd ollama-client -
Configure Environment (optional): By default the client connects to
http://127.0.0.1:11434/api. Override with:OLLAMA_HOST=http://your-host:11434/api OLLAMA_MODEL=llama3.1:8b
-
Run Examples: Verify your setup by running the basic example:
cargo run --example basic
This crate is part of the rain ecosystem. To maintain consistency across clients (e.g., gemini-client-rs), we adhere to a shared set of interface patterns:
- Builder Pattern: Clients should always implement
new,with_client, andwith_api_url. - Pinned Streams: All streaming methods must return
Pin<Box<dyn Stream>>to simplify caller integration. - Standardized Telemetry: Use the internal
telemetry_*!macros. Never use rawtracingcalls directly in the client logic. - Error Mapping: Maintain a flat, descriptive
OllamaErrorenum usingthiserror.
When contributing to the core client, adhere to these principles:
- Thin Layer Philosophy: The client is a transport and mapping layer. Avoid adding complex state machines, orchestration logic, or "agentic" capabilities. These belong in higher-level crates (like
rain). - Transparent Proxy: Preserving byte-for-byte fidelity and API structure is a priority. Avoid abstractions that hide underlying API features.
- Rust Type Safety: Leverage Rust's type system to make API constraints explicit and compile-time safe.
- Zero-Overhead Abstractions: Ensure the mapping from request structs to JSON is efficient and follows the public API documentation precisely.
- Follow Rust API Guidelines.
- Use
thiserrorfor all library-level error definitions. - Avoid
anyhowin the core library; it is reserved for examples and tests.
We maintain strict quality gates. PRs will not be merged if they contain Clippy warnings.
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warningsAlways use the standardized macros to ensure consistent mapping of error kinds and span data for cloud-native observability.
Every PR must be verified across multiple feature configurations:
-
Core Tests:
cargo test -
Feature-Specific Tests: Verify the
tracingfeature and other optional dependencies:cargo test --features tracing -
Example Verification: Ensure basic examples remain functional:
cargo check --examples
- Open an Issue: Discuss major changes before implementation.
- Fork and Branch: Work on a feature branch (
feat/your-featureorfix/your-fix). - Conventional Commits: We use conventional commit messages (e.g.,
feat: add tool calling support). - PR Review: All PRs require approval and passing CI checks.
- Report security vulnerabilities via GitHub Issues or contact the maintainers directly.