Large Language Model API Authenticity Checks: What They Can and Cannot Prove
A cryptographic signature can help verify the integrity of an LLM API response and the identity claimed by the signing party, but it cannot independently prove which model weights actually generated the response. This article compares common detection methods, explains their limitations, and presents an Ed25519 verification example.
In everyday large language model API usage, developers may worry about paying for a flagship model while receiving output from a cheaper one. Some proxy services or aggregation platforms may forward requests to a lower-cost model and return the response unchanged. Because model output is inherently probabilistic, users often cannot determine the actual model from the response alone.
1. Why Model Substitution Is Difficult to Detect
Large language models are black boxes from the user’s perspective. Different models may produce similar answers to the same question, while the same model can generate noticeably different responses under different sampling settings, such as Temperature.
Users can see the generated text, but not the routing records behind the request. Model providers face a similar challenge. When a user reports that a model has become less capable, the provider may have no independently verifiable evidence to confirm whether the request actually reached the expected model.
2. Common Detection Methods and Their Limitations
Four detection methods are commonly used today. Each verifies a different object and has its own limitations.
| Method | What it verifies | Required conditions | Limitations and false-positive scenarios |
|---|---|---|---|
| Identity prompting | The model’s self-declared identity | None | A proxy can set any identity through the system prompt, so the response is not evidence |
| Style comparison | The language style and quality of the response | A large number of samples and a comparison baseline | Results are affected by Temperature, prompts, and sampling, so they are only indicative |
| Field validation | Metadata fields in the response | The provider’s returned fields must be trustworthy | A proxy can modify or forge the fields; they may only show that the request passed through a particular gateway |
| Cryptographic signatures | The integrity of the signed payload and the signer’s identity | The provider must publish a public key and protect the private key | The provider must support signing, and the proof has a limited scope, as explained below |
3. What a Signature Mechanism Can Prove
A signature-based mechanism works as follows: the provider signs a payload on the server with a private key. The payload includes the model ID, timestamp, nonce, and a hash of the response content. After receiving the response, the client verifies the signature with the provider’s public key. If a proxy modifies either the response text or the model ID, signature verification fails.
Under the appropriate conditions, this mechanism can prove three things:
- The payload was issued by the party that possesses the corresponding private key.
- The model ID, timestamp, and response content in the payload were not modified after signing.
- The same signature cannot pass verification after the allowed time window has expired or after it has been reused, provided that the client performs the required checks.
However, a signature alone cannot prove the following:
- It cannot directly prove which model weights were used internally. A signature only proves that the provider claimed a particular model ID. Which model actually executed the request depends on the provider’s server-side implementation.
- It cannot prevent the provider itself from acting dishonestly. If the provider signs an incorrect model ID for a request, the signature remains valid.
- It cannot replace proper key management. If the private key is leaked, an attacker can generate valid-looking signatures.
Therefore, the claim that “a proxy cannot forge the signature” is reliable only when all of the following conditions are satisfied:
- The private key has not been compromised.
- The signing service is not exposed to the proxy.
- The client obtains and validates the correct public key.
- The provider honestly binds the model ID when issuing the signature.
If any one of these conditions is missing, the conclusion becomes weaker.
4. Signature Verification Example
The following example uses the Ed25519 signature algorithm. It includes two parts: a verify_proof function and a local self-test. In the self-test, the private key is generated by the script and is used only for demonstration. In a real deployment, the provider holds the private key, while the client receives only the public key.
The provider’s actual field names, signature algorithm, and payload format must follow its published specification. The payload fields below are only an example and must be replaced according to the provider’s API documentation.
import hashlibimport jsonimport timefrom cryptography.exceptions import InvalidSignaturefrom cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKeyMAX_SKEW_SECONDS = 300def build_payload(model, timestamp, nonce, content):"""Build a canonical payload with fixed fields and ordering.The signer and verifier must use the same rules."""payload = {"model": model,"timestamp": timestamp,"nonce": nonce,"content_hash": hashlib.sha256(content.encode("utf-8")).hexdigest(),}return json.dumps(payload,sort_keys=True,separators=(",", ":"),ensure_ascii=False,).encode("utf-8")def verify_proof(public_key, proof, content, expected_model, seen_nonces):"""proof is the provider's authenticity data and containsmodel, timestamp, nonce, and signature."""if proof["model"]
