How to Detect and Defend Against LLM Relay Model Substitution
API relays that aggregate models, enforce access controls, and manage cost are legitimate. This article explains how silent model substitution differs from normal gateway use, how it appears at the protocol layer, and how fixed baselines, cross-checked probes, and access-side controls turn “the model feels worse” into an auditable finding.
API relay itself is not fraud. Many teams use a unified gateway to aggregate multiple models, enforce authentication and rate limits, retry failures, and allocate cost. That is normal engineering. What deserves scrutiny is model substitution: the bill, console, or response fields claim that a purchased capability tier was used, while inference was actually performed by another tier, another generation, or an entirely different model family, with the protocol layer presenting the identity of the model the user paid for. Ordinary chat interfaces rarely expose weights, routing, or scheduling logs, so a drop in quality is often blamed on a weak prompt or on the model “having a bad day.”
How substitution works at the protocol layer
A typical call includes an identity claim, a request body, an inference process, and a response body. Substitution mainly happens in the two middle stages that the caller cannot see. After the gateway receives the request, it rewrites the model identifier, system prompt, or sampling parameters according to its own policy, then returns the result in the original interface format. The common patterns can be grouped into four types without tying them to any specific product.
The first is tier downgrade: a cheaper model with a shorter context and weaker tool use stands in for the higher-capability tier the user purchased. The second is generation swap: an earlier version with an older training cutoff is presented as a newer version with fresher knowledge and stronger instruction following. The third is route swap: an open-source or in-house small model from a completely different technical line imitates the target model’s tone. The fourth is dynamic mixing: high-capability instances are used when idle, and the gateway silently switches to cheap instances at peak load, when balance is low, or when risk controls trigger. The same key then behaves inconsistently across time windows.
The margin comes from the cost gap between capability tiers. Higher-capability models usually have longer context, slower decoding, and a higher price per token. Lower-capability models have fewer parameters, higher throughput, and a lower unit price. If users mainly accept results by subjective “does it feel good,” the middle layer has an incentive to look acceptable on most easy questions and expose the gap only on hard ones. Verification therefore cannot rely on a single casual chat. It needs probes that are hard to “act through” with a prompt.
Fix the comparison baseline first
Without a control, every anomaly can be explained as randomness. Prepare three fixed sets of material and reduce sampling randomness as much as possible: set temperature and similar random parameters close to deterministic values, freeze the system prompt and user prompt, and record the full request time, response latency, usage fields, and finish reason.
Baseline one is the official or contractually agreed direct channel, used only for comparison. Do not hand that key to the relay. Baseline two is the relay channel under test, with the model name, context window, and billing tier matching the contract. Baseline three is an explicitly labeled lower-capability control, so you know what a downgrade looks like. If a direct channel is unavailable, at least keep repeated results for the same prompt across dates and load levels, and watch for tier switching rather than ordinary variation.
A vendor-neutral record like the following turns a subjective impression into an archivable sample:
case_id: reason-03claimed_tier: highchannel: relayprompt_hash: <digest of the fixed prompt>temperature: 0latency_ms: 860usage_in: 420usage_out: 310finish: stopnotes: skipped steps mid multi-step proof; inconsistent with direct channel
Usage fields are worth reading. If a model is claimed to support long context but truncates far below the agreed window, or if input-token counts clearly disagree with text length, the middle layer may have rewritten the request or compressed history. That is not proof by itself, but it is supporting evidence that routing was changed.
Five probes that can be rechecked
A knowledge-boundary probe tests whether the claimed training or update range holds. Choose public, verifiable facts that only a newer model is likely to answer stably, such as the publication date of an already public standard or the effective date of a regulatory clause. Make the question specific about time, subject, and a retrievable source. Avoid open-ended commentary on current events. If the other side claims a recent model but is systematically ignorant of public facts inside the agreed time window, and also shows error patterns typical of an older version, suspicion should rise. Models hallucinate, so one failed item is not enough. Use a set of non-overlapping factual questions and see whether errors cluster on the cutoff.
A reasoning probe tests multi-step logic, not prose style. Use tasks that require keeping intermediate state: constrained itineraries or schedules, discussions of algorithm correctness that must state invariants, and applied problems that extract conditions before calculating. A higher tier usually stays consistent across steps. A downgraded model is more likely to skip steps, mismatch numbers, or pretend it ran a calculation when tools were unavailable. Score process consistency, not confident tone. Split the same problem into three rounds: conditions only, a step-by-step proof, and a redo in another representation. A substituted small model often cannot align round three with the conclusions of the first two rounds.
A style and instruction-following probe tests behavioral habits, but style must not be the only standard. Models differ statistically in structure, refusal boundaries, and obedience to format constraints, yet a relay can add a system prompt to imitate tone. More effective is a format contract that is hard to imitate: strict field order, no extra explanation, and a specified short error-code sentence for illegal input. If the relay systematically violates these constraints while the direct channel obeys them, the difference comes from the model or from an injected hidden prompt, not only from random sampling.
A latency probe must be read together with load. Small models usually decode faster, but a relay also queues, forwards across regions, and retries. Slow does not prove a real model, and fast does not prove a fake one. The useful signal is the distribution, not a single duration. At similar input lengths, if relay latency suddenly splits into two clusters and the fast cluster’s answer quality drops at the same time, that matches mixed routing. Record input length, output length, and whether the response was streamed, so network jitter is not mistaken for a model switch. Repeat the same prompt more than ten times. If quality jumps between full reasoning and skipped, perfunctory answers, while the direct channel has no such bimodal pattern, routing policy is more likely than sampling noise.
A tool and long-context probe tests whether capabilities in the specification are actually available. When function calling is agreed, use a question that can be answered correctly only from a tool result, and check that a tool trace appears and that arguments match the agreed schema. When long context is agreed, bury a unique marker far back and require the model to repeat it exactly at the end. Forgetting it early, inventing the marker, or pretending a tool was called all show that the specification and the actual inference do not match. If the tool trace is only a natural-language claim that something was “looked up,” with no structured call record, treat the specification as unmet.
How to avoid false judgments
Any single signal can mislead. New models also miss obscure facts. Gateway retries can cause occasional slowdowns. Safety policy can change refusal style. Split conclusions into three levels: observed, suspicious, and not as agreed. Observed means an isolated anomaly. Suspicious means two or more probe types deviate from the baseline at once. Not as agreed means that, with fixed prompts, low randomness, and repeated runs, the capability tier, knowledge boundary, or tool behavior stably fails the contract specification and closely resembles the downgrade control.
Also rule out causes on your own side. A hidden instruction appended on the relay side, truncated history, or rewritten sampling parameters can make a real model look weaker. Contracts or integration documents should therefore require that model identifiers and user messages not be rewritten without disclosure; that the response retain the actual model or route version; and that usage, finish reason, and request identifiers be traceable. A channel that cannot provide this transparency is a poor place for critical workloads, even if it temporarily “works.”
Controls on the access side
Put verification into continuous checks instead of manual chat after an incident. Run a small fixed regression set before release and daily at off-peak times, and score answers with rules: key entities for factual items, intermediate quantities for reasoning items, and pattern matching for format items. Alert when the score falls below a threshold instead of waiting for user complaints. Version the regression set so nobody can coach a fake model to a bare pass with a “more chatty” prompt.
Minimize keys and data. A relay can see full prompts and responses. Business secrets and personal information should not pass by default through an unauditable forwarder. Prefer a direct connection for core paths that can use one. When aggregation is required, choose a service willing to provide routing logs, the actual model identifier, and an explanation of abnormal switches, and state in the agreement that downgrades must be disclosed explicitly and silent replacement is forbidden. Logs should at least keep the request identifier, claimed model, returned model, latency, usage, and probe score, for a retention period that covers billing disputes.
Design cost control separately from verification. Deliberately downgrading to save money is a reasonable engineering choice, but it must be a caller-visible policy, such as selecting a low-cost tier by task label, not a swap hidden under a high-tier bill. When a model tier is shown to users, show the tier that actually ran, not the tier that was ordered. Internally, do not look only at average unit price. Mixed routing can make the bill look cheap while shifting failure cost into rework and bad decisions.
Summary
Substitution is hard to see because the interface looks almost the same, and easier to catch because capability specifications slip. Fix a baseline, cross-check knowledge boundaries, multi-step reasoning, format contracts, latency distributions, and tool traces, and write the results into traceable logs. Developers can then turn “it seems dumber” into a finding that can be rechecked. A relay can remain an aggregation and governance layer, provided routing is transparent, downgrades are explicit, and specifications match the bill. For critical workloads, transparency and auditability come before a low headline unit price.
