Artifact 7fd3c161402d4f33b7e7634dd0e653aebe897d12b947bc44296e5590f2cd3d2d:
- File
docs/manual/credentials.md
— part of check-in
[19ef27d450]
at
2026-11-22 15:41:12
on branch cred-order
— A stored key or sign-in now takes precedence over the provider's environment variable, as in Pi
pic_cred_get and pic_cred_source_of resolve a stored credential first, then the models.json apiKey, then the variable. auth status and the /login list name the source in use and any variable it hides. (user: pi-c-agent, size: 2158) [annotate] [blame] [check-ins using] [more...]
Credentials
API keys come from pic's credential store or from the environment (ANTHROPIC_API_KEY,
OPENAI_API_KEY, OPENROUTER_API_KEY, ...), as in Pi.
pic login anthropic # the key, typed with echo off (or piped on stdin), sealed into ~/.pic/pic.sqlite
pic keys # stored keys: names and dates, never values
pic logout anthropic # remove it
/login [PROVIDER] and /logout [PROVIDER] do the same in the terminal interface. A provider with
a subscription sign-in can use that instead of a key: see subscription sign-in.
The lookup order
As in Pi, a stored credential owns its provider. A request uses the first of these that exists:
- the credential stored with
pic loginorpic auth login(an API key or a sign-in); - the
apiKeywritten inmodels.json; - the provider's environment variable.
If none exists the request fails with an error naming pic login. A stored credential that cannot
be used (a damaged row, a sign-in whose refresh failed) is an error; pic does not quietly fall
back to the variable. So an exported variable that is out of credit or stale never hides a key you
stored; pic logout PROVIDER returns the provider to its variable.
pic auth status and the provider list in /login say which one is in use, and what it hides,
for example stored key (in use; ANTHROPIC_API_KEY also set).
The store
Each stored key is sealed with ChaCha20-Poly1305 (the provider's name bound as associated data), so no plaintext key reaches the database, its WAL, a backup or a log. The sealing key comes from a passphrase. pic asks for the passphrase on the terminal the first time a stored key is needed, and keeps the key only for the life of the process; the terminal interface asks once and hands the key to its request processes through an inherited pipe, never argv, the environment's values or a file. The store protects against a stolen disk, backup or database copy; not against a weak passphrase or malware running as you.
How the key is derived and where it is kept is in the architecture notes.