MCPInstall

LLM Preflight

by feronovak 3 stars feronovak/llm-preflight

Local, cross-provider preflight checks for LLM integration changes.

READMEmain

LLM Preflight

Last reviewed: 2026-11-18 · As of: v2.25.8

PyPI Tests License

Check LLM responses against the output rules your application depends on—before changing a model, prompt, schema, or provider.

Define the JSON shape, routing labels, or exact output your feature needs. Check responses against those rules, preview provider requests and estimated cost, and keep the decision, latency and cost as evidence for the change review. It also tells you which literal model IDs in your code are retired or retiring (Anthropic, OpenAI and selected Gemini models; Foundry MAI-Thinking-1 for configured models, not the source scan).

A passing run is evidence for your account, prompts and validators. It is not production approval.

Built for engineers maintaining an LLM feature. Runs locally as a CLI, GitHub Action, or MCP server. Python 3.10+; no third-party runtime dependencies.

Try it · Observed models · Use your own contract · CI and agents

Try it in 60 seconds

In a new directory, install the tool. No API key or provider request is needed:

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install llm-preflight

The activation command is for POSIX shells; PowerShell uses .\.venv\Scripts\Activate.ps1.

Already have LLM code? llm-preflight --audit-source . reports literal model IDs marked retired or retiring in the bundled snapshot. No config or key is needed. Real output from a one-file fixture repo whose app.py names claude-3-opus-20240229 (complete output):

Decision: fail — 1 file audited; 1 model reference: 1 retired, 0 retiring or stale, 0 unknown.
Exit 0 — add --ci to exit 1 on this decision.
Files: tracked by git, plus untracked files .gitignore does not exclude.
Retired:
  claude-3-opus-20240229 (1 reference) — retired 2026-01-05, replacement claude-opus-4-8
    app.py:3
    Next: llm-preflight --quick "<your prompt>" --models anthropic:claude-3-opus-20240229,anthropic:claude-opus-4-8 --dry-run

Bundled rows go stale 30 days after review; doctor and dry-run JSON show the end of the selected models' window as snapshot.valid_until (scan JSON: retirement_snapshot.valid_until).

Why not just a pytest assert? A pytest assert checks one reply inside your test suite. This adds a merge gate tied to a fresh CI record of the contract check; see How it compares.

1. Catch an invalid response

Save this as routing.json. The app accepts billing, technical or account. The config has two response fixtures: model-reply must pass and negative-control (INVALID) must fail:

{
  "prompt": "I was charged twice. Reply with only the support queue label.",
  "models": [{"name": "local-mock", "provider": "mock", "model": "local"}],
  "validation": {"allowed_values": ["billing", "technical", "account"]},
  "validation_fixtures": [
    {"name": "model-reply", "response": "billing", "expect": "pass"},
    {"name": "negative-control", "response": "INVALID", "expect": "fail"}
  ]
}
llm-preflight routing.json --contract-check --no-env-file

Both fixtures behave as expected and the command exits 0. Now change the model-reply response from billing to sales and run it again: the check fails and exits 1. Restore billing and it passes again. The 23-second session below runs the same validator (allowed_values billing, technical, account) and the same two fixtures through the same pass, fail, pass flow, with its own prompt and file name:

Real terminal session: billing passes, sales fails the same validator, and restoring billing passes again

Real CLI output with synthetic response fixtures. This checks the validator; it makes no provider requests and does not execute your application's parser. Watch the MP4.

--contract-check exits 0 when every fixture behaves as expected, 1 when one does not, and 2 for an invalid config.

2. Now a mock benchmark run

The mock benchmark uses a different config and produces a different decision:

llm-preflight init
llm-preflight benchmark.json --no-save --no-env-file

The config file is named benchmark.json because it also drives benchmark runs; the same file holds a contract's validators and fixtures.

init refuses to overwrite an existing config. Look for local-mock with PASS in the quality gate: the mock replied ok and passed the exact-output test. The overall decision is inconclusive (exit 3) because a local mock provides no live-provider evidence. The demo worked; it cannot approve a model. --no-save skips JSON/Markdown result artifacts; --no-env-file skips credential files.

Watch the interactive default template (30 seconds)

Select the mock and default Reply with ok test, review the plan, and confirm the local run. The session also reads the same decision through CLI JSON:

Interactive default-template demo: select the mock and configured test, review the plan, run locally, and inspect the expected inconclusive result as JSON

Local test: passed. Live provider: not tested. No API keys or provider calls. Watch the MP4 or start with the text walkthrough and interactive CLI JSON example.

Read the decision

For benchmark runs, read the decision before acting:

  • pass, exit 0: the configured checks passed with the required evidence.
  • fail, exit 1: a configured check failed; inspect the cause.
  • inconclusive, exit 3: evidence is insufficient; read the blocking warnings.

New

Claude Fable 5.2, Gemini 3.1 Flash-Lite, Gemini 4 Hydrogen, Gemini 4 Neon, Qwen4 Max, GPT-6.2 Sol, GPT-6.2 Astra and four more models in the comparison guide. The guide covers 31 routes; the 31st, Claude Mythos 5.2, returned HTTP 404 on all eight calls. Everything else is on the releases page.

Observed results on a support-routing contract

We ran 30 native model routes through eight synthetic support-routing and strict JSON cases each. 233 of 240 checks passed: two outputs failed their contract and five Kimi calls returned HTTP 429. 27 models passed all eight checks. These are observations for this workload as of 2026-11-19, not a ranking of general intelligence or production approval.

30 models attempted on 8 checks: 27 passed 8/8, 2 passed 7/8, Kimi 3 responses and 5 rate limits

Each request used a 1,024-token output allowance and one attempt, with no retries. Passed counts valid outputs out of API responses; API errors are separate, so Kimi's 3/3 with 5 errors is an incomplete evaluation. Latency averages API responses only. The known token-cost subtotal is $0.13850869 across 235 calls with usage; the total is unknown because the five error responses supplied no usage. Routes and settings differ, so read the comparison guide before comparing rows. It has the method and the failure analysis.

The same 30 rows as a table
ModelRouteGroupContract passedAPI errorsLatencyEst. costMeasuredAgainst 2026-10-29
GPT-6.2 AstraOpenAIPassed 8/88/803.370s$0.0082242026-11-18—
GPT-6.2 SolOpenAIPassed 8/88/801.471s$0.0020762026-11-18—
GPT-6 AstraOpenAIPassed 8/88/802.089s$0.0105802026-10-29—
GPT-6.1 SolOpenAIPassed 8/88/801.476s$0.0021162026-10-29—
GPT-6.1 TerraOpenAIPassed 8/88/801.192s$0.0012182026-10-29—
GPT-6 LunaOpenAIPassed 8/88/801.205s$0.0001742026-10-29—
Claude Fable 5.2AnthropicPassed 8/88/801.923s$0.0131602026-11-11—
Claude Fable 5.1AnthropicPassed 8/88/800.923s$0.0145002026-10-29—
Claude Opus 5.5AnthropicPassed 8/88/801.497s$0.0057402026-10-29—
Claude Sonnet 5.5AnthropicPassed 8/88/801.421s$0.0028702026-10-29—
Claude Haiku 5.5AnthropicPassed 8/88/801.758s$0.0001502026-10-29—
Gemini 4 ArgonGeminiPassed 8/88/805.186s$0.0027282026-10-29—
Gemini 4 CarbonGeminiPassed 8/88/804.687s$0.0027282026-11-11—
Gemini 4 HydrogenGeminiPassed 8/88/802.784s$0.0072212026-11-13—
Gemini 4 NeonGeminiPassed 8/88/8015.874s$0.0249722026-11-19—
Gemini 3.8 FlashGeminiPassed 8/88/802.621s$0.0027232026-10-29—
Gemini 3.6 FlashGeminiPassed 8/88/801.359s$0.0040052026-10-29—
Gemini 3.1 Flash-LiteGeminiPassed 8/88/801.050s$0.0017932026-11-11—
Grok 4.7xAIPassed 8/88/801.567s$0.0075362026-10-29—
DeepSeek V4 ProDeepSeekPassed 8/88/801.766s$0.0042202026-10-29—
DeepSeek FlashDeepSeekPassed 8/88/801.297s$0.0008092026-10-29—
Qwen4 MaxAlibaba SingaporePassed 8/88/802.676s$0.0021482026-11-17—
Qwen 3.8 MaxAlibaba SingaporePassed 8/88/803.834s$0.0060342026-10-29—
Qwen 3.8 FlashAlibaba SingaporePassed 8/88/802.689s$0.0005472026-11-11—
MiniMax M3MiniMaxPassed 8/88/802.119s$0.0006802026-11-11—
Mistral Large 4MistralPassed 8/88/807.043s$0.0059182026-11-11—
GLM 5.3Z.aiContract failures7/8 · 1 wrong queue01.511s$0.0013272026-11-18Same: invoice-request still fails
GLM 5.3 FlashXZ.aiPassed 8/88/801.067s$0.0003722026-11-18Improved: ticket-extraction now passes
GLM 5.3 FlashZ.aiContract failures7/8 · 1 fenced JSON01.226s$0.0001622026-11-18Same: ticket-extraction still fenced JSON
Kimi K3.1 ProMoonshot/KimiIncomplete3/35 rate limits1.930s$0.001778 known2026-11-18Same: the same five cases hit HTTP 429, again on a retry 10 minutes later

"Against 2026-10-29" compares the four models measured again on 2026-11-18 with their earlier row; a dash means the row was not measured again.

Your model is not here? Check it against your own contract: use the result in your own project or start with the first live run.

First live run

Start with one rule your application already enforces. The project integration guide provides a complete routing contract with accepted/rejected fixtures and a no-spend pull-request check. Match your deployed prompt and response parser; local fixture checks do not execute application code automatically.

To try a minimal provider starter instead:

llm-preflight init live.json --template provider \
  --provider openai --model gpt-6.1-sol --api-key-env OPENAI_API_KEY

The starter asks for exactly ok. Add this top-level field to live.json, keeping its existing fields, to check the validator locally:

{
  "validation_fixtures": [
    {"name": "accepted-label", "response": "ok", "expect": "pass"},
    {"name": "rejected-label", "response": "not ok", "expect": "fail"}
  ]
}

Microsoft Foundry has no starter, because every resource has its own URL: copy examples/foundry-mai-thinking-1.json and set base_url to your resource's /openai/v1 route (key in FOUNDRY_API_KEY).

Set OPENAI_API_KEY in your shell or in an uncommitted .env.production beside live.json. The config stores the variable name, never the key. Preview the check without making a generation request:

llm-preflight live.json --contract-check
llm-preflight live.json --doctor
llm-preflight live.json --pricing-check
llm-preflight live.json --dry-run

The starter has a three-request limit and a $0.05 estimated-cost cap. Resolve warnings and review the route, retry-expanded request bound, pricing and retention settings. The starter saves failed responses by default; review artifacts before sharing them.

Paid request: only after reviewing and authorizing that plan, run:

llm-preflight live.json

A direct CLI run has no separate approval prompt. Results are saved as JSON and Markdown under results/ unless you use --no-save. The CLI reads the config-adjacent .env.production without replacing existing shell values; choose another file with --env-file PATH or skip it with --no-env-file.

Render a review report

A review artifact retains the decision, contract validity, latency, usage, estimated cost and blocking warnings. Render saved schema-version-1 JSON as a standalone report without another provider request. Substitute the saved JSON path printed by your run for results/run.json:

llm-preflight report results/run.json --output report.html

The renderer omits prompts, responses, local paths and identifying run metadata. For reproducible examples, run these from a source checkout:

python3 -m llm_preflight report examples/reports/schema-baseline.json --format markdown
python3 -m llm_preflight report examples/reports/schema-break.json --format markdown

The first synthetic result passes; the second reports contract_failure, 67% contract validity and one contract-only failure. The report gallery also demonstrates a gate blocked with no_record (exit 1). These fixtures make no provider calls and cannot supply attested CI evidence.

Choose your path

CLI, CI, and MCP

Works as a CLI, GitHub Action, and local MCP server. The Action defaults to no generation requests. Rules for coding agents are in MCP for coding agents.

No preflight, no merge. With a required check configured, the offline gate requires a fresh passing CI record matching the current contract, routes, prompts and run selection. Protect the producer and gate workflows; signed records also need gh attestation verify before the gate. Follow proof of preflight to configure it. A local fixture pass or installed package does not enforce a merge policy. It doesn't certify production behaviour. It proves the check was done.

MCP for coding agents

Install the package (python3 -m pip install llm-preflight), then configure the stdio command llm-preflight-mcp in your MCP client. If you installed into a virtual environment, set command to the absolute path of that environment's llm-preflight-mcp, or install it with a pipx-style tool so it is on PATH.

{
  "mcpServers": {
    "llm-preflight": {
      "command": "llm-preflight-mcp",
      "args": ["--workspace", "/absolute/path/to/repository"]
    }
  }
}

The server has eight tools:

ToolWhat it doesCan spend money
audit_sourceFind literal model IDs in workspace files and report retirement and pricing verdictsno
validate_configValidate a benchmark config locallyno
dry_run_planReturn a redacted run and cost planno
run_preflightRun a preflight; a live run needs confirm_paid_runyes
diff_baselineCompare two saved result filesno
verifyReport a proof-of-preflight record's integrity and freshnessno
gateDecide offline whether a fresh passing CI record covers the contractno
migrate_planReport the provider-named replacement for each retired modelno

For an existing contract, begin with validate_config and dry_run_plan.

Agent rules

  • Paid runs need a person. A live run_preflight requires explicit confirmation, and confirm_paid_run is not proof that a person authorized spending: keep the client's tool approval enabled. Never infer permission for paid work from a gate result.
  • Read the structured decision (pass, fail, inconclusive) and its blocking warnings, and report missing evidence. Do not summarize it away.
  • Never weaken a validator to get a pass.

The CLI gives the same decision as JSON with --json, for example llm-preflight benchmark.json --json --no-save. Exit codes: 0 pass, 1 fail or blocked, 2 invalid input or setup failure, 3 inconclusive. The agent-smoke suite with --smoke makes six requests per model before configured retries. See the MCP guide for request/result examples and workspace boundaries, and the coding-agent workflow for CLI commands.

Safety boundary

Results apply to the configured account, route, prompts and validators at one time. Model responses remain stochastic. Deterministic validation checks the rules you declare; it does not establish semantic accuracy or production safety. Preview limits before live requests and keep paid-run authority with the person responsible for the integration.

How it compares

Use this project for a bounded contract check and reviewable evidence before an integration change. Keep the tools you already have; the table shows what this adds:

You already haveIt is good forLLM Preflight adds
A pytest assertion on a model replyUnit-level checks in your test suiteA merge gate tied to a fresh CI record of the contract check
An evaluation frameworkSemantic scoring and statistical comparisonsSpend-capped dry runs that preview the provider request and estimated cost before any live call
An observability toolProduction tracing and incident investigationRetirement and pricing snapshots for the model IDs you use, checked locally

See when to use it.

Help, documentation, and contributing

Ask for setup help or a contract example. Include the version, intended check and redacted output. Never share keys, private prompts or provider responses. Use the security policy for vulnerabilities.

The documentation homepage routes by task. Consult CLI reference, configuration and result JSON for exact behavior. Native routes and dated pricing coverage are listed in current snapshots. The AI implementation testing guide explains the intended workflow and scope.

Release notes for every version are in the changelog.

See Contributing for development and documentation standards. Released under the MIT License.

More Security & Testing MCP servers

Similar servers from the same category.

Enables deepfake detection in images through Proofly API integration, providing detailed analysis results including real/fake probability scores and individual model results for each detected face.

Security & Testing

CASB provides comprehensive visibility and control over your SaaS applications, so you can easily eliminate the risk of compromise, prevent data loss, and avoid compliance violations.

Security & Testing

Audit logs summarize the history of changes made within your Cloudflare account. Audit logs include account level actions like zone configuration changes.

Security & Testing
YaraFlux logo

YaraFlux

threatflux

Provides YARA-based malware scanning capabilities with support for local and MinIO storage backends, enabling security professionals to manage rules, scan files/URLs, and analyze results for threat detection.

filesystemstorage