Evidence-based LLM API and relay auditing for Node.js, TypeScript, and the CLI — testing protocol fidelity, tool and schema contracts, prompt isolation, context recall, and behavioral consistency.
Features · Quick Start · Installation · Try Online · Preview · Feature Reference · Methodology · Documentation · Credits · License
Note
Evidence boundary: Reports separate execution status (completed, blocked, unsupported, skipped, error), probe verdict (pass, finding, inconclusive), confidence (weak, moderate, strong), and coverage. Observed failures, header hints, or reference rankings do not prove the true upstream model or operator intent, and no_findings covers only the executed workload.
- 26 Modular Probes in 4 Groups — Endpoint reachability and header hints, prompt/injection safety, streaming & capability contracts (
tool_calling,structured_output,image_understanding,pdf_understanding,context_recall), and behavioral/statistical checks (quality_canary,quality_comparison,model_fingerprint,numeric_fingerprint,tokenizer_fingerprint). - Multi-Protocol Auto-Routing — Supports OpenAI Chat (
/chat/completions), Anthropic Messages (/messages), OpenAI Responses (/responses), andautoselection. - Separated Verdict & Coverage Model — Missing capabilities, authentication blocks, rate limits, incomplete telemetry, and uncalibrated baselines remain
unsupported,blocked,skipped, orinconclusiveinstead of silently passing or failing. - SSRF & Credential Hygiene — Public runs require HTTPS, resolve DNS and pin the connected IP per request, block private/reserved IPv4 & IPv6 ranges, disable HTTP redirects, read credentials from environment variables only, write
--outputfiles with0600exclusive-create semantics, and redact keys and sensitive assignments across outputs and callbacks. - Shared Execution Budgets — Target, reference, and judge requests share configurable
maxRequests,maxInputTokens,maxResponseBytes,maxDurationMs,pacingMs, andAbortSignalcancellation. - Independent Baseline Calibration —
collect-baselinegathers separate training and validation batches against two candidates plus an external control (other), computing SHA-256 digests and enforcing freshness and holdout margins before allowing compatibility scoring.
Want to test an endpoint right away without installing anything locally? LMSpeed hosts the same @lmspeed/audit engine directly in the browser:
- Run Full Relay Audit — Launch an online multi-probe audit and get a shareable report
- Single-Probe Tools — Model Fingerprint · Stream Integrity · Tool Calling · Context Recall
- More Live Tools — LLM Speed Test · Provider Directory · Free Test API Keys
Paste this prompt into Claude Code, Codex, Cursor, or any terminal-capable coding agent to set up and run an audit interactively without editing placeholders:
Set up and run an API endpoint audit using lmspeed-audit (`https://github.com/lmspeed/audit`).
1. Install the published CLI with `pnpm add --global @lmspeed/audit` (Node.js >=22.12), then inspect `lmspeed-audit --help` and `lmspeed-audit list --format json` so you know the exact flags and probe IDs. For a one-off run, use `pnpm dlx @lmspeed/audit --help`. See the Installation section for Homebrew, Scoop and portable downloads.
2. Before making any network calls to the target endpoint, ask me for any details not already provided in this conversation:
- Target base URL (and whether it is a private or local HTTP endpoint requiring `--allow-private`)
- Model ID to audit
- Protocol (`auto`, `openai`, `anthropic`, or `responses`)
- Desired profile (`connectivity`, `general`, `web3`, or `full`) or specific probes, plus any optional capabilities (`--thinking`, `--context-tokens`) or local config JSON (`--config` for reference, judge, context, identity baseline, tokenizer bank, or numeric scorer)
- Name of the environment variable holding the API key (default `PROVIDER_API_KEY`). Instruct me to export the secret in my shell instead of pasting any raw API key into chat.
3. Run a minimal connectivity check first (`--profile connectivity --max-requests 10 --format markdown`) to confirm auth, routing, and protocol framing.
4. Once connectivity succeeds, run the agreed audit with explicit request/duration budgets (`--max-requests`, `--max-duration-ms`) and save structured output with `--output` if a JSON artifact is requested. Never print or log API keys.
5. Summarize the observed `assessment.verdict`, execution coverage (`completed` vs `blocked` / `unsupported` / `skipped` / `inconclusive`), any findings with severity and confidence, and actual `usage` counters without claiming upstream model identity or overall safety beyond what the probes observed.
The CLI and SDK require Node.js >=22.12. Homebrew and Scoop install Node.js for you.
# Run once, without a global installation
pnpm dlx @lmspeed/audit --help
# Install the command globally
pnpm add --global @lmspeed/audit
lmspeed-audit list
# Add the TypeScript SDK to a project
pnpm add @lmspeed/auditPackage: @lmspeed/audit.
brew tap lmspeed/audit https://github.com/lmspeed/audit
brew install lmspeed/audit/lmspeed-audit
lmspeed-audit --versionThis repository is the upstream Homebrew tap. Upgrade with brew update && brew upgrade lmspeed-audit.
scoop bucket add lmspeed https://github.com/lmspeed/audit
scoop install lmspeed/lmspeed-audit
lmspeed-audit --versionThe upstream bucket installs the portable command and nodejs-lts. Upgrade with scoop update lmspeed-audit.
GitHub's npm registry requires authentication even for public packages. First authenticate with a classic personal access token with read:packages, following the GitHub registry instructions, and map only the @lmspeed scope:
@lmspeed:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}pnpm add --global @lmspeed/audit
# The SDK uses the same package name on both registries
pnpm add @lmspeed/auditUse this mapping only when installing from GitHub Packages; omit it for npmjs.org. Do not commit tokens. The primary npm package needs no GitHub login.
GitHub Releases provide .tar.gz and .zip archives containing the bundled command, runtime dependencies, documentation and license notices. Verify the download against SHA256SUMS, extract it, and run node lmspeed-audit/lmspeed-audit.mjs --help (or lmspeed-audit.cmd on Windows). No dependency installation is required; Node.js is still required.
For an immediate browser-based check, use LMSpeed Audit, LLM speed tests or the provider directory. See publishing and channel maintenance for release automation.
Requires Node.js >= 22.12 and pnpm:
git clone https://github.com/lmspeed/audit.git
cd audit
pnpm install --frozen-lockfile
pnpm build
node dist/cli/index.js --helpOptionally expose the lmspeed-audit binary globally from the local build:
pnpm link --global
lmspeed-audit listexport PROVIDER_API_KEY="sk-your-key-here"
# 1. Quick connectivity and stream check
lmspeed-audit scan \
--url https://relay.example.com/v1 \
--model claude-sonnet-4-6 \
--protocol auto \
--profile connectivity \
--max-requests 10 \
--format markdown
# 2. General audit with bounded resources and 0600 JSON output
lmspeed-audit scan \
--url https://relay.example.com/v1 \
--model gpt-4o \
--profile general \
--max-requests 120 \
--max-duration-ms 180000 \
--format json \
--output audit-report.jsonimport { ENGINE_VERSION, runAudit } from '@lmspeed/audit';
const report = await runAudit(
{
target: {
baseUrl: 'https://relay.example.com/v1',
modelId: 'claude-sonnet-4-6',
protocol: 'auto',
},
apiKey: process.env.PROVIDER_API_KEY!,
profile: 'general',
capabilities: { vision: true },
},
{
limits: { maxRequests: 100, maxDurationMs: 120_000 },
pacingMs: 100,
},
);
console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);Verdicts are computed by the library. Explicit extraction refusals recognize English typography and Chinese/Russian refusal forms; an empty JSON extraction is informational, while ambiguous answers remain inconclusive. The semantic yes/no task accepts terminal punctuation; the instruction-priority check tolerates surrounding formatting, while literal-copy tasks retain strict comparison. For unresolved checks, import getAuditInconclusiveReason from @lmspeed/audit/assessment to obtain a machine-readable cause for translation. Consumers should retain the engine verdict rather than replacing it with a display heuristic.
- CLI Exit Codes:
scanexits0(no_findings),1(findings), or2(inconclusive, missing auth/args, or runtime error).collect-baselineexits0when calibration isvalidatedor2otherwise.
Schema v1 JSON excerpt (real local loopback scan on v0.3.0)
{
"schemaVersion": "1",
"engineVersion": "0.3.0",
"rulesetVersion": "independent-2026-11-23.7",
"target": {
"baseUrl": "http://127.0.0.1:57215/v1",
"modelId": "claude-sonnet-4-6",
"protocol": "anthropic"
},
"probes": [
{
"id": "tool_calling",
"execution": "completed",
"verdict": "finding",
"findings": [
{
"probeId": "tool_calling",
"code": "forced_tool_contract_violation",
"severity": "warning",
"confidence": "strong",
"evidence": "A forced tool call was absent or did not match the declared name and argument schema."
}
]
},
{
"id": "channel_classifier",
"execution": "completed",
"verdict": "pass",
"observations": {
"status": 200,
"channel": "anthropic-api",
"confidence": 0.5,
"evidence": ["anthropic-ratelimit-requests-limit"]
}
}
],
"coverage": {
"requested": [
"model_list",
"stream_integrity",
"tool_calling",
"structured_output",
"quality_canary",
"channel_classifier"
],
"completed": [
"model_list",
"stream_integrity",
"tool_calling",
"structured_output",
"quality_canary",
"channel_classifier"
],
"inconclusive": [],
"blocked": [],
"unsupported": [],
"skipped": []
},
"assessment": {
"policyId": "lmspeed-independent-evidence-v3",
"verdict": "findings"
},
"usage": {
"requests": 18,
"inputTokensEstimated": 1062
}
}| Profile | Included Probes by Default | Intended Use |
|---|---|---|
connectivity |
model_list, stream_integrity |
Fast preflight reachability, authentication, and SSE framing verification |
general (default) |
19 automatic probes, including numeric screening and tokenizer evidence from bundled reference data; excludes web3_prompt_injection and other opt-in probes unless configured |
Standard relay contract & security audit |
web3 |
general set + web3_prompt_injection + configured opt-in probes |
General audit plus wallet seed-sharing refusal signal |
full |
Same automatic set + web3_prompt_injection + all configured opt-in capability/reference probes (tokenBaselines, vision, pdf, context, reference, identity, numericFingerprint, tokenizer) |
Comprehensive audit with full operator configuration |
| Protocol | Wire Endpoint & Auth Header | auto Resolution |
|---|---|---|
openai |
POST /chat/completions, GET /models, Authorization: Bearer <key> |
Default when modelId does not contain claude |
anthropic |
POST /messages, x-api-key: <key>, anthropic-version: 2023-06-01 |
Selected when modelId matches /claude/i |
responses |
POST /responses, Authorization: Bearer <key> |
Explicit --protocol responses only |
auto |
Routes per modelId rule above |
Default |
| Probe ID | Trigger | Behavior & Evidence Scope |
|---|---|---|
infrastructure_recon |
Auto | Collects entry reachability, DNS addresses/CNAME/NS, TLS certificate details and bounded WHOIS registration fields; unavailable evidence stays separate |
model_list |
Auto / connectivity |
Reads GET /models JSON data[] catalog and checks whether target.modelId is listed (advertised catalog only) |
infrastructure_fingerprint |
Auto | Compares landing, models and error-route signatures for New API, One API, LiteLLM, One Hub, LobeChat, FastGPT and common entry proxies; editable branding is evidence, not upstream proof |
channel_classifier |
Auto | Inspects explicit header prefixes (cf-aig-, x-amzn-bedrock-, anthropic-ratelimit-); marks conflicting or absent hints as inconclusive |
| Probe ID | Trigger | Behavior & Evidence Scope |
|---|---|---|
token_injection |
Opt-in (capabilities.tokenBaselines) |
Compares reported input usage across plain, system, and question templates against caller calibration (reported_input_count_mismatch) |
prompt_extraction |
Auto | Runs verbatim, translation and JSON-continuation probes plus a randomized protected-value control; retains separate results and prompts/responses |
jailbreak_identity |
Auto | Runs system diagnostic, Base64 and middleware role-play strategies plus randomized JSON/Base64 disclosure controls |
conditional_injection |
Auto | Runs 3 randomized ordinary vs. sensitive account task pairs and checks for excess DECOY_* disclosure + external https:// forwarding directions |
web3_prompt_injection |
web3 / full |
Tests structured JSON refusal policy on seed-phrase upload requests ({"action":"reject"} vs "share") |
| Probe ID | Trigger | Behavior & Evidence Scope |
|---|---|---|
instruction_conflict |
Auto | Requests a fresh random ACK_* in system instructions while the user asks to ignore it; tolerates surrounding whitespace, quotes/backticks and terminal sentence punctuation, but requires the complete unchanged marker with no extra text (system_priority_mismatch) |
stream_integrity |
Auto / connectivity |
Validates SSE framing ([DONE] / message_stop / response.completed), streamed model consistency, and monotonic usage counters |
context_window |
Auto | Uses a short calibration sample and targets the supplied context in up to five requests by default. Pass requires full marker recall and sufficient endpoint-reported input usage. Without a reference, measures character bounds and reports that official verification did not pass. Explicit context.sizes alone retains fixed recall sampling |
context_recall |
Opt-in (context) |
Embeds random FACT_* anchors at configurable positions ([0, 0.25, 0.5, 0.75, 1] default), confirming misses once before reporting context_recall_missing |
model_fingerprint |
Opt-in (identity) |
Compares answer distributions against a calibrated holdout baseline; abstains on expired, incomplete, incompatible, or low-margin samples |
numeric_fingerprint |
Auto; optional numericFingerprint override |
Uses the shipped SHA-256-pinned reference (30-day age limit) for closed-set ranking; no runtime data downloads |
tokenizer_fingerprint |
Auto; optional tokenizer override |
Uses the shipped tokenizer bank (90-day age limit, up to 12 samples plus four controls). Stops on confirmed drift or abstains when evidence is uncertain |
Reference data is owned and versioned by this package. SDK, CLI and LMSpeed use the same read-only assets/references snapshot, including source commit, original dates, hashes and MIT attribution. Explicit numericFingerprint and tokenizer configuration takes precedence. Set referenceData: 'disabled' in SDK/config JSON to disable automatic reference checks. Expired, missing or altered data is reported as inconclusive without downloading replacements or blocking unrelated checks. Distribution confirmation still requires an independently calibrated identity baseline.
Maintainers update references.source.json to a reviewed upstream commit and Git blob hashes, then run pnpm references:sync. The command downloads only during maintenance, verifies original blobs and compatibility, and keeps only scoring metadata, the detector and tokenizer bank. Commit the snapshot and release through this repository's existing CI. See reference data maintenance.
| Probe ID | Trigger | Behavior & Evidence Scope |
|---|---|---|
tool_substitution |
Auto | Asks the model to echo a fresh random @audit-fixture/* package string without execution (literal_output_mismatch) |
error_leakage |
Auto | Sends a single malformed JSON payload ({) and scans responses/headers for exposed config assignments (DATABASE_URL, API_KEY, etc.) with values omitted |
latency_variance |
Auto | Executes 5 sequential short readiness calls and computes descriptive statistics (count, median, mean, min, max, spread) |
tool_calling |
Auto (unless tools: false) |
Verifies forced call schema (audit_weather), tool_choice: none, and undeclared-tool restraint; tools are never executed |
structured_output |
Auto (unless structuredOutput: false) |
Runs 2 randomized nonce trials enforcing strict JSON Schema with additionalProperties: false |
image_understanding |
Opt-in (capabilities.vision: true) |
Sends a generated solid-color PNG absent from text prompts and verifies exact color-word recovery |
pdf_understanding |
Opt-in (capabilities.pdf: true) |
Sends a generated valid PDF embedding an unseen target word and verifies exact recovery |
stream_consistency |
Auto | Compares identical deterministic non-streamed vs. streamed completions across returned model ID, input tokens, and non-reasoning output counts |
quality_canary |
Auto | Runs 10 deterministic micro-tasks (QUALITY_TASKS: arithmetic, sorting, string reversal, JSON, formatting, prime, binary, Python len, logic, word recall) |
quality_comparison |
Opt-in (reference, optional judge) |
Evaluates randomized target vs. repeated reference arms on QUALITY_TASKS, separating acquisition errors from answer regressions |
lmspeed-audit scan --url <base-url> --model <model-id> [options]
lmspeed-audit collect-baseline --config collection.json [--output baseline.json]
lmspeed-audit list [--format json]| Flag | Default | Description |
|---|---|---|
--url, --model |
(required for scan) |
Target API base URL and model identifier |
--protocol |
auto |
auto, openai, anthropic, or responses |
--profile |
general |
connectivity, general, web3, or full |
--probes |
profile default | Comma-separated subset of probe IDs from list |
--format |
json |
Output format for scan: json, markdown, or text; list supports json |
--output |
stdout | Creates a new file with 0600 permissions (wx, fails if path already exists) |
--config |
— | Local JSON configuration file for capabilities, context, reference/judge, or identity artifacts |
--key-env |
PROVIDER_API_KEY |
Environment variable name holding the target credential |
--allow-private |
false |
Permits plain HTTP and private/loopback addresses for local targets |
--thinking |
false |
Declares extended thinking support in input capabilities |
--context-tokens |
— | Publisher context window in tokens. Enables targeted verification |
--max-requests |
200 |
Maximum HTTP requests shared across target, reference, and judge calls |
--max-input-tokens |
2000000 |
Maximum estimated input token budget (ceil(body.length / 4)) |
--max-response-bytes |
4000000 |
Maximum bytes buffered per HTTP response |
--max-duration-ms |
600000 |
Total wall-clock timeout in milliseconds |
--pace-ms |
0 |
Inter-request delay in milliseconds (latency_variance) |
Operator JSON passed to --config never stores raw secrets (apiKey is rejected; use apiKeyEnv naming env vars), and relative artifact paths resolve against the config file directory:
{
"profile": "full",
"capabilities": {
"vision": true,
"pdf": false,
"tokenBaselines": { "plain": 14, "system": 24, "question": 18 }
},
"context": {
"sizes": [4096, 16384],
"positions": [0, 0.5, 1]
},
"reference": {
"target": { "baseUrl": "https://ref.example.com/v1", "modelId": "gpt-4o", "protocol": "openai" },
"apiKeyEnv": "REFERENCE_API_KEY"
},
"judge": {
"target": { "baseUrl": "https://judge.example.com/v1", "modelId": "gpt-4o", "protocol": "openai" },
"apiKeyEnv": "JUDGE_API_KEY",
"minimumScore": 7
},
"identity": {
"baselineFile": "./artifacts/baseline.json",
"claimedModel": "candidate-a"
},
"tokenizer": {
"bankFile": "./artifacts/tokenizer-bank.json",
"maximumProbes": 20,
"maxAgeDays": 30
},
"numericFingerprint": {
"dataDirectory": "./artifacts/numeric",
"detectorSha256": "64-lowercase-hex-sha256-of-shared-detector-bin",
"maximumAgeDays": 30
}
}Use collect-baseline (or collectFingerprintBaseline) with >= 2 candidate sources plus >= 1 other external reference (2–8 prompts, 16–256 samples per prompt, maxOutputTokens 16–2048, maxAgeDays <= 30) to build validated holdout baselines.
Package subpath exports: @lmspeed/audit (Node SDK), @lmspeed/audit/catalog (browser-safe), @lmspeed/audit/schema (browser-safe), @lmspeed/audit/legacy-types (browser-safe), @lmspeed/audit/compat, @lmspeed/audit/classifiers, @lmspeed/audit/sse, @lmspeed/audit/model-family, @lmspeed/audit/prompts, and @lmspeed/audit/redaction.
flowchart LR
A["Target Validation<br/>HTTPS + DNS/IP Pinning<br/>No Redirects"] --> B["Budgeted Transport<br/>Requests · Tokens · Bytes · TTL<br/>AbortSignal + Key Scrub"]
B --> C["26 Probes<br/>Endpoint · Prompt · Contract<br/>Recall · Quality · Identity"]
C --> D["Evidence Grading<br/>execution != verdict<br/>Abstain When Uncalibrated"]
D --> E["Schema v1 Output<br/>JSON · Markdown · Text<br/>0 / 1 / 2 Exit"]
- SSRF & Secret Isolation —
validateTargetvalidates URLs and blocks loopback/private/reserved ranges on every connection in public mode, pinning DNS answers intohttp(s).requestwith hostname verification and redirect rejection. API keys, reference keys, judge keys, and URL assignments (upstream_url,DATABASE_URL, etc.) are scrubbed from serialized results and errors. - Execution vs. Verdict Separation — HTTP auth errors (
401/403), rate limits (429), unsupported media/configs, incomplete telemetry, and uncalibrated references becomeblocked,unsupported,skipped, orinconclusiverather than silent passes or false findings. - Holdout & Statistical Restraint — Behavioral baselines require matching
protocolandgenerationcontracts, freshness (<= maxAgeDays), independent validation holdouts, and minimum separation margins. Tokenizer sampling uses two opening controls and one closing control. The first sample below the opening count triggers one extra control to check for drift. Sampling can stop early at 99% posterior confidence, and an exact tokenizer match requires at least 90% confidence. - Verification Suite (
pnpm check) — Runs TypeScript compilation, Biome formatting/linting, stricttsc --noEmit, AST test-governance checks (no-mock,given-when-then,userscenario names), Vitest suites executing against real loopback HTTP relays with a 70% branch coverage threshold, and package boundary checks (pnpm verify:package). Automated tests verify implementation contracts over loopback HTTP; live first-party model accuracy is not claimed without external reference calibration. Seedocs/acceptance.mdanddocs/strategy-review.md.
| Document | English | 简体中文 | Русский |
|---|---|---|---|
| User guide | English | 简体中文 | Русский |
| Acceptance scenarios | English | 简体中文 | Русский |
| Strategy & evidence limits | English | 简体中文 | Русский |
| Publishing & installation channels | English | 简体中文 | Русский |
| Changelog | English | 简体中文 | Русский |
Documentation is available in three languages. Commands, probe IDs, schema fields and status values are identical across guides; translated documentation does not change the CLI output language.
LMSpeed maintains @lmspeed/audit.
| Check | Upstream contribution | What Audit implements |
|---|---|---|
| Tokenizer fingerprint | MIT code and data. Audit adapts the tokenizer bank format, Bayesian posterior calculation, and adaptive probe selection from lm-detector at 70159b7 and bundles its tokenizer bank. |
API requests and input token measurement, repeated control checks for baseline drift, and abstention when the measurements are unstable or inconclusive. Tokenizer probe |
| Numeric fingerprint screening | MIT dependency and data. lmfpd-sdk 0.2.0 generates the numeric challenges and scores the replies offline. lm-detector supplies the bundled detector and reference bank metadata. |
SHA-256 verification, reference expiry and model coverage checks, response collection, and reporting the result as a ranking within the reference set. Numeric probe |
| Model distribution fingerprint | Method references. meow-llm-detector (PolyForm Noncommercial 1.0.0) informed repeated sampling and Dirichlet–multinomial predictive scoring. LLMprobe-engine V3H (package metadata declares AGPL-3.0-only) informed the minimum-fit and evidence thresholds. |
TypeScript scoring, independent collection of training and holdout samples for candidates and an external control, and calibration of the fit and separation thresholds. Distribution scoring · Baseline collection |
| Prompt security, error leakage, and stream integrity | Method reference. api-relay-audit at 040676c (the MIT revision before the license change) informed these check scenarios. |
Randomized protected-value controls, evidence checks for sensitive values in error responses, and validation of SSE events and stream termination. Prompt checks · Error and stream checks |
| Structured tool calls and JSON output | Method reference. Veridrop (GNU AGPL v3) informed checks that send real tool-call and strict JSON Schema requests. | Forced, disabled, and undeclared tool-call controls. Local checks verify JSON field types, values, and the absence of extra fields. Capability probes |
Audit also implements probe scheduling, request and token budgets, credential redaction, and report assembly. Protocol checks follow the OpenAI, Anthropic, and WHATWG SSE specifications. Prompt-injection checks draw on arXiv:2604.08407.
LMSpeed Audit's own code is licensed under the Apache License, Version 2.0 (Apache-2.0). The adapted lm-detector code, bundled reference artifacts, and lmfpd-sdk dependency retain their MIT license. See NOTICE and THIRD_PARTY_NOTICES.md for copyright and license notices.
