jaz.credentials
New to JAZ? This is generated API reference. Start with the docs and the concepts overview.
Public API of the jaz.credentials submodule (import from jaz.credentials, e.g. from jaz.credentials import ...).
Keys are stored per provider tag — the provider prefix of a model string ("openai" for
"openai/gpt-5-mini"), which is also the name the console’s set_credential('<provider>')
takes:
{ "openai": {"api_key": "sk-..."}, "anthropic": {"api_key": "sk-ant-..."}}The file is created mode 0o600 (owner read/write only) inside a 0o700 directory.
A backend resolves its key from, in order: an explicit api_key passed to it, the provider’s
environment variable (OPENAI_API_KEY, ANTHROPIC_API_KEY), then this file. So an exported
variable still wins for a one-off run, and the file is the persistent fallback that makes jaz
work in a fresh shell.
The default LiteLLM backend picks the entry by the provider it routes the model
to, so openai/gpt-5-mini uses the "openai" key. It is exact for providers authenticated by
a single API-key variable; for ones needing several (azure) or not using an API key at all
(bedrock, vertex_ai), configure the environment rather than storing a key here.
Because the environment variable outranks this file, a stale OPENAI_API_KEY left in a
shell rc silently overrides a key stored here, and the resulting authentication error names
neither. If a key stored here seems to be ignored, check for an exported variable first.
API_KEY_FIELD
Section titled “API_KEY_FIELD”credentials_path
Section titled “credentials_path”credentials_path() -> PathReturn the path of the credentials file (whether or not it exists).
load_credentials
Section titled “load_credentials”load_credentials() -> Mapping[str, Mapping[str, Any]]Read the credentials file, returning {provider: {field: value}}.
Returns an empty mapping when the file does not exist.
Raises
ValueError— The file exists but is not a JSON object of per-provider objects. The message names the path but never the stored values.
resolve_credential
Section titled “resolve_credential”resolve_credential(provider: str, field: str = API_KEY_FIELD) -> str | NoneReturn the stored field for provider, or None if there is none.
provider is the upstream API provider — "openai", "anthropic", or whatever name
a backend looks itself up under.
A missing file, a missing provider entry, and a missing field are all simply “no credential”; only a malformed file raises.
This is the opt-in hook: the store only takes effect for a backend that calls it. The default
LiteLLM backend calls it per request, with the provider it routes the model
to. A custom backend that never calls it will not read a key stored under its tag.