Skip to main content

Providers API

The providers module integrates with runtime model providers (Ollama, llama.cpp, MLX) for detecting installed models and pulling new ones.

Core Trait

ModelProvider

Trait for runtime providers:
Methods:
  • name() - Human-readable provider name
  • is_available() - Whether provider service is reachable
  • installed_models() - Set of installed model names (lowercase)
  • start_pull() - Begin downloading a model (returns handle for progress polling)

Ollama Provider

OllamaProvider

Integrates with Ollama daemon:
Configuration: Reads OLLAMA_HOST environment variable, defaults to http://localhost:11434. Example:

Pulling Models

detect_with_installed()

Single-pass detection (avoids duplicate API calls):
Returns: (available, installed_models) Example:

has_remote_tag()

Checks if model exists in Ollama registry:
Example:

llama.cpp Provider

LlamaCppProvider

Downloads GGUF files directly from HuggingFace:
Configuration:
  • Models directory: ~/.cache/llmfit/models (or $LLMFIT_MODELS_DIR)
  • Detects llama-cli and llama-server in PATH
Example:

Searching HuggingFace

Listing Repo Files

Selecting Best Quantization

Selects highest quality quantization that fits:
  1. Q8_0 (best)
  2. Q6_K
  3. Q5_K_M
  4. Q4_K_M
  5. Q3_K_M
  6. Q2_K (smallest)

Downloading GGUF Files

MLX Provider

MlxProvider

Integrates with Apple MLX framework:
Configuration:
  • MLX server URL: http://localhost:8080 (or $MLX_LM_HOST)
  • Scans ~/.cache/huggingface/hub/ for mlx-community models
  • Checks for mlx_lm Python package via python3 -c "import mlx_lm"
Platform: macOS only Example:

Pulling MLX Models

Uses HuggingFace CLI to download from mlx-community:
Requirements: MLX pulls require hf CLI:

Pull Events

PullHandle

Handle for monitoring download progress:

PullEvent

Progress events:
Example Progress Handler:

Name Mapping Helpers

Helpers for mapping HuggingFace model names to provider-specific formats:

Ollama

llama.cpp

MLX

Complete Example