Short answer
To check whether a Claude API relay really sends your requests to Claude, use the extended-thinking signature: send a signed thinking block back unchanged (a genuine Anthropic backend accepts it), then send it back with the signature altered (a genuine backend rejects it with Invalid signature in thinking block). Asking the model who it is, asking for its knowledge cutoff or reading the model field proves nothing. Even the signature test only shows that requests reach Anthropic's Claude, not which Claude model answered, so run it regularly and on the models you pay for.
This guide is published by APIVAI, a gateway for Claude and GPT models. The tests work on any relay that supports the native Anthropic format, including ours; our own results are near the end.
Why people worry about model substitution
Buying Claude through a reseller, relay or gateway means trusting that a request for claude-sonnet-4-6 reaches Claude Sonnet 4.6. Several sources suggest that trust is often misplaced:
- Research. A CISPA paper, "Real Money, Fake Models" (arXiv 2603.01919, accepted to ACM CCS 2026), audited "shadow APIs" used in 187 academic papers. On the three it examined in depth, 45.83% of model-fingerprint checks did not match the claimed model.
- Forums. Chinese developer forums have their own words for it: 以次充好 (passing off something cheaper), 掺水 (watering down), 降智 (the model "got dumber"). A typical exchange on V2EX: "How do they guarantee it isn't another model?" Reply: "They don't, and they mix them."
- Marketplaces. On Hacker News, a user describes being routed to heavily quantized versions of a model "while paying maybe 15% less".
Substitution is not the only cause of "it feels worse today". Anthropic itself published a postmortem in 2025 about infrastructure bugs that degraded some Sonnet responses, and different system prompts or context handling change answers too. That is why the test needs to be mechanical, not a matter of impression.
Checks that prove nothing
| Check | Why it fails |
|---|---|
| Ask "which model are you?" | A relay can inject a system prompt, and genuine models misname themselves anyway (in a survey of 190 models, about 60% answered with a name that wasn't their own) |
| Ask for the knowledge cutoff | We asked Claude Haiku 4.5 ten times on 2026-10-19 and got "April 2024" every time, while Anthropic's page for the model gives its reliable knowledge cutoff as February 2025: the genuine model is consistently wrong, and a relay can make any model give the same answer with a system prompt |
Read the model field | The relay fills it in |
| Judge the quality of answers | Too noisy: real regressions, prompts and context all change quality |
How the thinking-signature test works
With extended thinking enabled, Anthropic returns each thinking block together with an opaque signature. In a conversation with tool calls, the previous assistant turn, thinking blocks included, has to be sent back on the next request, and Anthropic checks the signature (extended thinking docs). A forged or edited signature is rejected:
400 invalid_request_error: messages.1.content.0: Invalid `signature` in `thinking` block
The test uses that check three times:
- Ask a question that makes the model call a tool, with thinking on. The answer contains a signed
thinkingblock and atool_useblock. - Send that turn back unchanged, with a tool result. A genuine backend answers 200.
- Send it back again with the last characters of the signature replaced. A genuine backend answers 400 with the error above.
The third request carries the proof. A relay serving another model can produce a string that looks like a signature, but it cannot make Anthropic's verifier accept the real signature and refuse the edited one unless your requests actually reach Anthropic.
The same responses carry weaker hints worth recording: message IDs that start with msg_, tool-call IDs that start with toolu_, and usage objects with service_tier and a nested cache_creation object. Each of these can be forged on its own.
Run the test once
Python with requests, native Anthropic format. On Claude Haiku the three requests cost a small fraction of a cent; on Sonnet, around a cent.
import os, requests
BASE = os.environ["RELAY_BASE_URL"] # e.g. https://your-relay.example (no /v1)
KEY = os.environ["RELAY_API_KEY"]
MODEL = os.environ.get("MODEL", "claude-sonnet-4-6")
H = {"x-api-key": KEY, "anthropic-version": "2023-06-01", "content-type": "application/json"}
TOOLS = [{"name": "get_weather", "description": "Get the weather for a city",
"input_schema": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]
THINK = {"type": "enabled", "budget_tokens": 1024}
Q = {"role": "user", "content": "What is the weather in Paris? Use the tool."}
def call(messages):
r = requests.post(f"{BASE}/v1/messages", headers=H, timeout=120, json={
"model": MODEL, "max_tokens": 1600, "thinking": THINK, "tools": TOOLS, "messages": messages})
return r.status_code, r.json()
s, a = call([Q])
blocks = a.get("content", [])
print("1st:", s, a.get("id"), [b["type"] for b in blocks])
print("usage fields:", sorted(a.get("usage", {}).keys()))
tool = next((b for b in blocks if b["type"] == "tool_use"), None)
think = next((b for b in blocks if b["type"] == "thinking"), None)
if not (tool and think and think.get("signature")):
raise SystemExit("No thinking block with a signature: cannot run the test (try another model or prompt).")
def second(content):
return call([Q, {"role": "assistant", "content": content},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": tool["id"], "content": "Sunny, 18C"}]}])
s2, b2 = second(blocks)
print("2nd, signature unchanged:", s2, "(expect 200)")
bad = [dict(b, signature=b["signature"][:-8] + "AAAAAAAA") if b["type"] == "thinking" else b for b in blocks]
s3, b3 = second(bad)
print("3rd, signature tampered:", s3, b3.get("error", {}).get("message", ""), "(expect 400 Invalid `signature`)")| Unchanged signature | Edited signature | What it means |
|---|---|---|
| 200 | 400 "Invalid signature" | Requests reach Anthropic's Claude, and the relay passes thinking blocks through intact |
| 200 | 200 | Nobody verifies signatures: the backend is not Anthropic |
| 400 | 400 | The relay breaks thinking blocks, often because it converts requests to the OpenAI format; multi-turn Claude Code sessions will fail on it too |
Watch a relay over time
A single run shows one moment, and relays change their routing. The monitor below runs the same three requests for each model you list, appends one JSON line per check to a log, compares it with the previous check of the same model, and sends a Telegram message when something changes.
It records four signals:
| Signal | What a change suggests |
|---|---|
| Signature verdict | Requests no longer reach Anthropic, or thinking blocks are now being broken |
| Input token count for a fixed request | The same request to the same model always produces the same count. A different count means a different tokenizer (another model family) or a system prompt the relay added |
ID formats and usage fields | A different channel behind the relay |
| Latency | Weak signal: reported only when it triples |
import json, os, re, time
import requests
BASE = os.environ["RELAY_BASE_URL"].rstrip("/")
KEY = os.environ["RELAY_API_KEY"]
MODELS = [m.strip() for m in os.environ.get("MODELS", "claude-haiku-4-5").split(",") if m.strip()]
LOG = os.environ.get("LOG_FILE", "relay_watch.jsonl")
HEADERS = {"x-api-key": KEY, "anthropic-version": "2023-06-01", "content-type": "application/json"}
TOOLS = [{"name": "get_weather", "description": "Get the weather for a city",
"input_schema": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]
THINKING = {"type": "enabled", "budget_tokens": 1024}
QUESTION = {"role": "user", "content": "What is the weather in Paris? Use the tool."}
def post(model, messages):
t = time.time()
r = requests.post(f"{BASE}/v1/messages", headers=HEADERS, timeout=180, json={
"model": model, "max_tokens": 1600, "thinking": THINKING, "tools": TOOLS, "messages": messages})
try:
body = r.json()
except ValueError:
body = {}
return r.status_code, body, int((time.time() - t) * 1000)
def check(model):
res = {"ts": time.strftime("%Y-%m-%dT%H:%M:%S"), "model": model}
status, a, ms = post(model, [QUESTION])
res.update(status=status, latency_ms=ms)
if status != 200:
res["verdict"] = f"error {status}: {a.get('error', {}).get('message', '')[:120]}"
return res
blocks = a.get("content", [])
usage = a.get("usage", {})
tool = next((b for b in blocks if b.get("type") == "tool_use"), None)
think = next((b for b in blocks if b.get("type") == "thinking"), None)
res.update(
id_format=bool(re.match(r"^msg_[0-9A-Za-z]{20,}$", a.get("id", ""))),
tool_id_format=bool(tool and tool.get("id", "").startswith("toolu_")),
usage_fields=all(k in usage for k in ("service_tier", "cache_creation")),
# The same request to the same model always gives the same number of input tokens.
# A different number means a different tokenizer (another model) or an added system prompt.
input_tokens=usage.get("input_tokens"),
)
if not (tool and think and think.get("signature")):
res["verdict"] = "no signed thinking block: signature test not possible"
return res
def second(content):
return post(model, [QUESTION, {"role": "assistant", "content": content},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": tool["id"], "content": "Sunny, 18C"}]}])
s2, _, _ = second(blocks)
bad = [dict(b, signature=b["signature"][:-8] + "AAAAAAAA") if b.get("type") == "thinking" else b for b in blocks]
s3, b3, _ = second(bad)
rejected = s3 == 400 and "signature" in json.dumps(b3).lower()
res.update(roundtrip=s2, tampered=s3, tamper_rejected=rejected)
if s2 == 200 and rejected:
res["verdict"] = "ok"
elif s2 == 200 and s3 == 200:
res["verdict"] = "SIGNATURES NOT CHECKED"
else:
res["verdict"] = f"thinking blocks broken ({s2}/{s3})"
return res
def last_runs():
prev = {}
if os.path.exists(LOG):
with open(LOG, encoding="utf-8") as f:
for line in f:
try:
r = json.loads(line)
prev[r["model"]] = r
except (ValueError, KeyError):
pass
return prev
def differences(old, new):
if not old:
return []
out = []
for k in ("verdict", "input_tokens", "id_format", "tool_id_format", "usage_fields"):
if old.get(k) != new.get(k):
out.append(f"{k}: {old.get(k)} -> {new.get(k)}")
if old.get("latency_ms") and new.get("latency_ms") and new["latency_ms"] > 3 * old["latency_ms"]:
out.append(f"latency_ms: {old['latency_ms']} -> {new['latency_ms']}")
return out
def notify(text):
token, chat = os.environ.get("TG_TOKEN"), os.environ.get("TG_CHAT")
if token and chat:
requests.post(f"https://api.telegram.org/bot{token}/sendMessage", timeout=30, data={"chat_id": chat, "text": text})
if __name__ == "__main__":
prev = last_runs()
with open(LOG, "a", encoding="utf-8") as f:
for m in MODELS:
r = check(m)
f.write(json.dumps(r, ensure_ascii=False) + "\n")
diff = differences(prev.get(m), r)
print(m, r["verdict"], r.get("input_tokens"), f"{r['latency_ms']} ms", "; ".join(diff))
if diff or r["verdict"] != "ok":
notify(f"relay_watch {m}: {r['verdict']}\n" + "\n".join(diff))Environment variables: RELAY_BASE_URL (without /v1), RELAY_API_KEY, MODELS (comma-separated), LOG_FILE, and optionally TG_TOKEN and TG_CHAT for Telegram. Run it from cron, for example every six hours:
0 */6 * * * . /opt/relay-watch/env && python3 /opt/relay-watch/relay_watch.py >> /opt/relay-watch/cron.log 2>&1
Read the history with jq:
jq -r '[.ts, .model, .verdict, .input_tokens, .latency_ms] | @tsv' relay_watch.jsonl | tail -20
How to read a change
| What changed | Likely cause |
|---|---|
Verdict became SIGNATURES NOT CHECKED | The edited signature is no longer refused: Anthropic is not processing the requests |
Verdict became thinking blocks broken | The relay started converting requests and loses signatures |
input_tokens changed, nothing else did | A system prompt was added or changed, or the request goes to a model with a different tokenizer. Check first whether Anthropic released a new version of the model |
msg_ / toolu_ IDs or usage fields disappeared | The channel behind the relay changed |
| Errors 402 or 429 | Budget or rate limits of the key, not substitution |
| Only latency went up | More likely load than substitution; watch whether it lasts |
What no outside test can tell you
- It proves "Anthropic's Claude", not "which Claude". A relay that quietly sends Opus requests to Sonnet, both on Anthropic, passes with a genuine signature. The input token count does not help here either, because models of one family can share a tokenizer. Tier swaps show up only in cost and latency compared with the official API on identical requests, or in a small set of hard tasks run from time to time.
- It shows the moment of the test. Repeat it, and on the models you actually use.
- It needs the native Anthropic format. OpenAI-format endpoints drop thinking signatures, so the test cannot run there.
- Passing means "no evidence of substitution", not proof. The academic audits reach the same conclusion; only hardware attestation (TEE) would prove which model runs, and no resale channel offers it.
Our own results
We ran the tests against APIVAI on 19 October 2026: the one-off test on Claude Haiku 4.5 through the public endpoint and on Claude Sonnet 4.6 on the same backend, and the monitor on Claude Haiku 4.5.
- First request:
msg_011…message ID,toolu_…tool ID,usagewithservice_tier,inference_geoand a nestedcache_creationobject, and a signed thinking block. - Unchanged signature: 200. Edited signature: 400
Invalid signature in thinking block. - The monitor recorded the same input token count (759) on consecutive runs; when we edited the logged count by hand, the next run reported the change.
- Not present:
anthropic-ratelimit-*response headers, so we do not offer them as a signal.
That is everything these tests show, within the limits above.
FAQ
Can I run the test against an OpenAI-format endpoint?
No. OpenAI-format endpoints do not carry thinking signatures, so there is nothing to verify. Point the script at the relay's native Anthropic address (the one Claude Code uses); if a relay only offers the OpenAI format, this test cannot check it.
How often should I run it?
Every few hours is enough for most uses; every six hours on two models is 24 requests a day. Running it more than once an hour adds little, because substitution is not a minute-by-minute event. Check the models you actually pay for.
How much does one check cost?
Three short requests per model: a small fraction of a cent on Claude Haiku and about a cent on Claude Sonnet, at the relay's own prices.
Will it notice if Opus is replaced with Sonnet?
No. Both are Anthropic models, so the signature is genuine either way, and they may share a tokenizer. To catch a tier swap, compare cost and latency with the official API on identical requests, or keep a few hard tasks that the cheaper model gets wrong.
If a relay passes, can I stop worrying?
Passing means there is no sign of substitution at the time of the test, nothing more. Keep monitoring, keep an eye on your bill per request, and prefer relays that show per-request token counts and costs you can reconcile.