Brain Docs

Reference

Python SDKInstallationHTTP clientWire clientSync vs async
put_llm_credentialget_llm_credentialtest_llm_credentialverify_llm_credentialdelete_llm_credential
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Python SDKCredentialstest_llm_credential

test_llm_credential

Check a candidate key without storing it — safe against a namespace that already works.

PURPOSE

Check a key without storing it. Nothing is written and nothing existing is touched, so it is safe to run against a namespace that already has a working credential — which is exactly what you want when rotating.

POST/v1/llm-credential/testBearer API keystable
test_llm_credential(provider: str, model: str, api_key: str) -> LlmCredentialCheck

Parameters

ParameterTypeRequired
providerstringrequired

The provider to check against.

modelstringrequired

The model to check.

api_keystringrequired

The candidate key. Not stored.

Returns

FieldTypePresence
statusstringalways

The check's outcome.

validboolean

Present 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.

reasonstring

Why, when there is a reason.

providerstringalways

Which 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.

See also
put_llm_credential

Was this page helpful?

get_llm_credential

See which provider key is installed — provider, model and fingerprint, never the key.

verify_llm_credential

Re-check the stored key — a key that worked at registration can be revoked later.

On this page

ParametersReturnsExample
Suggest an editOpen in Playground