test_llm_credential
Check a candidate key without storing it — safe against a namespace that already works.
test_llm_credential(provider: str, model: str, api_key: str) -> LlmCredentialCheckParameters
providerstringrequiredThe provider to check against.
modelstringrequiredThe model to check.
api_keystringrequiredThe candidate key. Not stored.
Returns
statusstringalwaysThe check's outcome.
validbooleanPresent when the provider gave a definite answer. Absent is not false — it means the check could not reach a verdict, and treating it as a failure will have you rotating a working key.
reasonstringWhy, when there is a reason.
providerstringalwaysWhich provider answered.
Example
check = brain.test_llm_credential(provider="anthropic", model="claude-opus-5", api_key=candidate)
if check.valid is not True:
raise RuntimeError(f"candidate key not usable: {check.status} {check.reason or ''}")
installed = brain.put_llm_credential(provider="anthropic", model="claude-opus-5", api_key=candidate)
print("now using", installed.fingerprint)Brain never takes a provider key from a request
The key is registered once, through these verbs, and sealed. It is never accepted as a per-request field, never returned by any read, and never configured on the Brain server itself. Anything that looks like a deploy-time provider key is from an older design. See Namespaces.
These five verbs exist on the HTTP tier only — the wire protocol has no credential routes.
Was this page helpful?