Skip to main content

llm-route-audit

Prove it before you route.

Test cheaper AI models on your own requests, and switch only where the answers stay just as good.

PyPI Python 3.11+ License: MIT Status: alpha

How llm-route-audit works, with an example report

The problem

Most teams send every request to their most expensive model, just to be safe. Model routers promise savings by guessing which requests are "easy", but they rarely show whether the guesses were right, so quality can drop without anyone noticing.

llm-route-audit replaces the guess with a test. It replays your real requests on cheaper models, grades each answer against the original, and tells you, task by task, where switching is safe and where it isn't.

What you get

  • Lower bills without losing quality. Switch only the tasks where a cheaper model kept up with the original.
  • Proof, not guesses. Every pass rate and cost comes with a 95% range, measured on your own requests.
  • No surprise spend. A cost estimate before anything runs, a hard spending limit, and cached answers.
  • Safe after the switch. Spot checks and user feedback catch quality drops, and a task can be sent back.
  • Private. It runs on your machine. Nothing leaves it except the model calls you approve.

How it works

  1. Test. Replay a sample of your logged requests on the models you choose to try.
  2. Grade. Compare every answer with the original: exact checks first, then an AI judge. Your own labels always win.
  3. Report. For each task, the cheapest model that kept at least 95% of the original's quality.
  4. Switch and watch. Export a routing table for your gateway or app, then keep checking quality over time.

Try it in one minute

No API key needed: the repository includes the results of a real run. Needs git and uv.

git clone https://github.com/good2idnan/llm-route-audit.git && cd llm-route-audit
uv sync
uv run llm-route-audit report examples/sample_logs.jsonl \
  --replay examples/demo/replay.jsonl --grades examples/demo/grades.jsonl --min-samples 1

Cost and quality of each strategy in the demo run

The demo run: using the cheapest model everywhere cut cost to 19%, but only 58% of answers passed. Per-task routing kept every answer passing at 26% of the cost. It covers only 5 requests, so run it on your own logs before deciding anything.

Use it on your traffic

pip install llm-route-audit
  1. Get your logs. Import them from LiteLLM, Langfuse or OpenTelemetry with llm-route-audit import, or write simple JSONL.

  2. List the models to try in candidates.yaml:

    candidates:
      - model: claude-haiku-4-5
      - model: claude-sonnet-5-5
        effort: low
    
  3. Run the audit. Grading rules go in grading.yaml (example).

    llm-route-audit analyze logs.jsonl                                     # what you spend today
    llm-route-audit replay  logs.jsonl -c candidates.yaml --max-spend 1.00 # try cheaper models
    llm-route-audit grade   logs.jsonl --config grading.yaml               # mark every answer
    llm-route-audit report  logs.jsonl                                     # where switching is safe
    llm-route-audit export  logs.jsonl --out routing-policy.yaml           # your routing table
    

Every paid step shows its cost first and asks before spending. After you switch, monitor, outcomes and status keep an eye on quality.

Works with

Models Anthropic, OpenAI, Google Gemini, OpenRouter, Ollama, any OpenAI-compatible server
Logs LiteLLM, Langfuse, OpenTelemetry, or simple JSONL
Routing LiteLLM config export, or the built-in runtime router for Python apps
Also audits tool-using agents (step by step and whole sessions) and auto-routers such as OpenRouter's

Learn more

License

MIT

Metadata

Release files for llm-route-audit 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-route-audit 0.3.3
File Size Uploaded
llm_route_audit-0.3.3.tar.gz 213.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-route-audit 0.3.3
File Interpreter ABI Platform
llm_route_audit-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 343.5 kB

Release files / llm_route_audit-0.3.3.tar.gz

Download URL llm_route_audit-0.3.3.tar.gz
Size 213.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fc2a5c1103b5dd4adabf0fb938d3d2dc7ffd6cf867e86bc1cbecc8eb1e0b831f
BLAKE2b-256 checksum
How to use checksums
1a95ce79c676b2599f7c19476c577722609ed298d44532646f0bcb09ed62e3f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / llm_route_audit-0.3.3-py3-none-any.whl

Download URL llm_route_audit-0.3.3-py3-none-any.whl
Size 130.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
703a31f0f26a4c13187563439a58d1eabdba54a15b514a7a004302df0be7a45f
BLAKE2b-256 checksum
How to use checksums
ca4ccdcf6073c0d956af9c27a1d115c80b860c96d0754bcac6b2e38e683cc945
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page