Verifying AI Responses: How to Detect Model Swapping in Third-Party AI API Relays

    When using third-party AI API relay services, callers may pay for a flagship model but receive responses from a cheaper or modified model. This article explains why asking a model to identify itself is insufficient, why style-based checks only prove connection authenticity, and how cryptographic response proofs can help verify model identity, input, output, and inference parameters. It also covers the trust assumptions, limitations, and a practical verification checklist for developers.

    1. The trust problem in AI API calls: paying for flagship models but receiving cheaper answers

    When calling large language models through a third-party relay service, many users encounter inconsistent quality: the API parameters specify the highest-tier model, but answers may range from expert-like to awkward. This is often not because the model is having a bad day, but because a chain of incentives may be at work.

    You pay for a high-priced model, while the relay service may forward your request to a cheaper model in the backend and return the response unchanged. The swap is invisible to the caller. In addition to model swapping, two more hidden cases exist:

    • Undisclosed quality reduction: The provider claims it did not change the model, but reduces inference budget or shortens reasoning length, causing lower output quality.
    • Distilled impersonation: A smaller model is trained on many real conversations to imitate the target model’s style and then passed off as the original.

    These behaviors share a common point: from the answer content alone, the caller can hardly prove what was actually purchased. One important prerequisite must be stated: a response anti-forgery proof only works when the upstream model provider or a trusted execution environment helps issue it. If only the relay service signs the response itself, the trust problem remains.

    2. Why asking “Who are you?” does not work, and what verification is effective

    The simplest idea is to ask in the conversation, “Which model are you?” But this does not work. The relay service can simply add “You are a certain flagship model” to the system prompt, and any replaced model will play along. Since prompts are controllable, self-reported identity has zero credibility.

    Example: if the system prompt requires the model to identify itself as a flagship model, a cheaper model behind the relay will still claim to be that flagship model. Self-reported identity verifies prompt compliance, not the actual model identity.

    Most common community detection methods remain indirect: comparing response styles, checking returned fields, or validating reasoning signatures. Their common weakness is that they can at most prove that “the upstream connection reached some provider,” but cannot answer whether “the most expensive tier or a cheaper tier is running.” Style can be imitated, fields can be forged, and signatures may identify only the service rather than the specific tier. They prove “connection authenticity,” not “tier authenticity.”

    Common mistakes include: only checking whether identifier fields exist in the response, judging only by whether the answer “looks like” a certain model, and treating relay self-signed credentials as upstream proof. To detect undisclosed quality reduction, one can compare latency, output length, inference budget fields, and historical baselines, but content alone is still insufficient.

    3. The core shift: from trust to verifiable proof

    To escape the guessing loop, the approach must shift from guessing whether the answer looks right to proving response origin cryptographically. This is the core problem addressed by AI response anti-forgery proofs: allowing the model provider to attach a publicly verifiable cryptographic credential to each inference output.

    The basic assumption is simple: if an output was truly produced by a specific model with a given input, the provider can make an unforgeable and tamper-proof commitment to it; anyone who obtains the credential can verify it independently. This follows the lineage of digital signatures, except the signed object is expanded to a binding of “model identity + input + output + key parameters.”

    4. How AI response proofs work: trusted signers are the key

    The typical flow is “generate proof during generation, verify with public key”: when the server generates the answer, it packages key elements and signs them; the client verifies with a public key and compares the model identifier with what was purchased. The following is pseudocode that only illustrates the flow. sha256, serialize, and now need to be implemented according to dependencies:

    1. # Pseudocode: The server produces a verifiable credential while generating the response
    2. def generate_with_proof(request_id, model_id, prompt, model_params):
    3. output = model.generate(prompt, model_params)
    4. payload = {
    5. "request_id": request_id, # Bind to the invocation log
    6. "model": model_id, # Claimed model tier
    7. "model_fingerprint": weight_hash, # Model weight/configuration fingerprint
    8. "prompt_hash": sha256(prompt),
    9. "output_hash": sha256(output),
    10. "params": model_params, # Temperature, inference budget, etc.
    11. "timestamp": now(),
    12. }
    13. # signing_key must come from the upstream model provider or a trusted execution environment.
    14. # The relay service must not control the private key, and the public key must be distributed through a trusted channel.
    15. proof = signing_key.sign(serialize(payload))
    16. return output, payload, proof
    17. # Client: anyone can verify independently
    18. def verify(output, payload, proof, public_key, purchased_model):
    19. assert public_key.verify(serialize(payload), proof), "Invalid credential"
    20. assert sha256(output) == payload["output_hash"], "Response was tampered with"
    21. assert payload["model"] == purchased_model, "Model tier mismatch"
    22. assert payload["model_fingerprint"] == trusted_fingerprint, "Model fingerprint mismatch"
    23. return True

    The value is that verification becomes deterministic cryptographic checking. However, the prerequisites must be limited: the public key must be trusted, the signing private key must not be accessible to the relay service, and the model identifier and inference configuration must be verifiable; otherwise, the relay service could still pass checks by issuing proofs itself.

    5. Comparison and boundaries: what it can solve and what remains limited

    Risk Provable by Prerequisite Remaining risk
    Model swapping Model identifier included in the signed payload Signer is trustworthy Relay self-signing is invalid
    Undisclosed quality reduction Parameters/budget can be bound and checked Parameters are verifiable Budget definitions are not unified
    Distilled impersonation Without the private key, credentials are hard to forge Public key distribution is reliable Trust root is compromised

    Limitations include: dependence on provider cooperation; the proof establishes source authenticity rather than optimal quality; and the trust root is anchored to the trustworthiness of the provider’s public key.

    6. An actionable verification checklist for developers

    1. Request credential fields: request_id, model, model_fingerprint, prompt_hash, output_hash, params, timestamp.
    2. Verify the public key source and signer identity, and confirm that it is not self-signed by the relay service.
    3. Bind invocation logs to request_id.
    4. Replay the output hash comparison.
    5. Check the inference budget and model fingerprint.
    6. In procurement and operations, define the credential format, key rotation, log retention, abnormal alerting, and contract dispute handling.

    7. Conclusion

    The meaning of response anti-forgery proofs is to turn “what exactly did I buy?” from a guess into reproducible verification. They do not magically improve quality, and they still require a trusted signer, but they can prevent swapping, tampering, and impersonation from hiding in a fog of trust.