Installation
llm-diff requires Python 3.10+. The package is published on PyPI under pluto-llm-diff, which exposes the llm-diff terminal executable.
pip install pluto-llm-diffVerify your installation:
llm-diff --helpLocal Testing (100% Free & Offline via Ollama)
Run behavioral diffs entirely offline on your local machine using Ollama.
llm-diff ollama/qwen2.5:0.5b ollama/llama3.2:1bTip: If a model spec starts with the ollama/ prefix, llm-diff auto-routes to the Ollama backend. Explicitly setting --backend ollama is optional when using prefixed model specs.
Cloud Testing (Free via Groq)
Benchmark massive open-weight models (Llama 3.1 vs 3.3) for free using Groq's high-speed OpenAI-compatible API.
- Get a free API key from console.groq.com.
- Point
--openai-base-urlto Groq's endpoint.
llm-diff openai/llama-3.1-70b-versatile openai/llama-3.3-70b-versatile \
--backend openai \
--openai-base-url https://api.groq.com/openai/v1 \
--api-key your_groq_api_key_herePaid Cloud Testing (OpenAI)
To compare standard OpenAI models (e.g., gpt-4o-mini vs gpt-4o), export your OPENAI_API_KEY and run:
export OPENAI_API_KEY="sk-proj-..."
llm-diff openai/gpt-4o-mini openai/gpt-4oCLI Flags & Options
--backendFallback backend when the model spec lacks a prefix (ollama or openai). Default: ollama.
--ollama-urlBase URL for the local Ollama API server. Default: http://localhost:11434 (or OLLAMA_HOST).
--openai-base-urlBase URL for OpenAI-compatible servers. Default: https://api.openai.com/v1 (or OPENAI_BASE_URL).
--api-keyAPI key for OpenAI-compatible endpoints (or set OPENAI_API_KEY).
--jsonEmit a machine-readable JSON report instead of formatted Rich terminal tables.
--show-responsesPrint full raw model responses alongside evaluation scores for debugging.
--temperatureSampling temperature for generation. Default: 0.0 for maximum reproducibility.
--max-tokensMaximum output tokens per probe evaluation. Default: 512.
--timeoutPer-request API call timeout in seconds. Default: 120.0.
--retriesRetry attempts on transient network/API failures (timeouts, 429s, 5xx). Default: 2.
CI/CD Integration & Automation
llm-diff is designed for automated regression testing. Use --json to emit a structured report containing all probe outputs, metric deltas, and execution metadata.
Exit Codes
All probe evaluations completed successfully across both models.
Unrecoverable error: invalid arguments, missing API key, or bad base URL.
Diff completed, but one or more probes timed out or errored (ERR rows).
GitHub Actions Example
Save behavioral diff reports as pipeline artifacts:
name: LLM Behavioral Regression Test
on:
push:
branches: [ main ]
pull_request:
jobs:
behavior-diff:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install llm-diff
run: |
python -m pip install --upgrade pip
pip install pluto-llm-diff
- name: Run behavioral diff report
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
llm-diff openai/gpt-4o-mini openai/gpt-4o --json > diff-report.json
- name: Upload diff report artifact
uses: actions/upload-artifact@v4
with:
name: llm-diff-report
path: diff-report.json