Summary
When defining custom providers in ~/.pi/agent/models.json, pi requires an apiKey field at validation/load time even if valid credentials for that provider already exist in ~/.pi/agent/auth.json.
This makes auth.json insufficient as the actual source of truth for provider credentials, and forces users to duplicate auth state in models.json using a fake/sentinel apiKey value just to pass schema validation.
This appears related to:
Problem
The docs say credentials can come from:
CLI --api-key
auth.json
environment variable
custom provider keys from models.json
But for custom providers defined in models.json, pi fails early unless apiKey is present in the provider config itself.
Example error:
Failed to load models.json: Provider digitflowai: "apiKey" is required when defining custom models.
This happens even when auth.json already contains:
{
"digitflowai" : { "type" : " api_key" , "key" : " ..." }
}
Reproduction
auth.json
{
"ollama-cloud" : {
"type" : " api_key" ,
"key" : " real-secret"
}
}
models.json
{
"providers" : {
"ollama-cloud" : {
"api" : " openai-completions" ,
"baseUrl" : " https://ollama.com/v1" ,
"models" : [
{ "id" : " glm-5.2" }
]
}
}
}
Actual result
pi refuses to load models.json because apiKey is missing in the provider config.
Workaround
Add a fake placeholder:
"apiKey" : " from-auth-json"
Then pi loads successfully and uses the real key from auth.json at request time.
Why this is a problem
It makes users duplicate auth state conceptually across two files.
The placeholder is not real auth, but it must exist just to satisfy validation.
Placeholder keys can create confusing UX / auth-status semantics (see Provider auth status treats placeholder API key as usable models.json key #5204 ).
It conflicts with the documented resolution order where auth.json is a first-class credential source.
Expected behavior
If a provider already has credentials in auth.json, models.json should not require a redundant apiKey field just to define custom provider models.
At minimum, one of these should happen:
Preferred
Skip the apiKey validation requirement when stored auth exists for that provider.
Acceptable fallback
Keep the requirement, but make the error actionable and explicitly say:
auth.json is not currently considered by validation
users must add a placeholder apiKey field
runtime auth will still come from auth.json
Suggested fix
During models validation/loading, check whether auth already exists for the provider before enforcing apiKey presence.
Something like:
if provider defines custom models
and provider has auth in auth.json
allow missing apiKey in models.json
Real affected custom providers in my setup
ollama-cloud
digitflowai
yairouter
volcengine-coding
Environment
pi version: 0.79.9
config dir: ~/.pi/agent
affected files:
Summary
When defining custom providers in
~/.pi/agent/models.json, pi requires anapiKeyfield at validation/load time even if valid credentials for that provider already exist in~/.pi/agent/auth.json.This makes
auth.jsoninsufficient as the actual source of truth for provider credentials, and forces users to duplicate auth state inmodels.jsonusing a fake/sentinelapiKeyvalue just to pass schema validation.This appears related to:
Problem
The docs say credentials can come from:
--api-keyauth.jsonmodels.jsonBut for custom providers defined in
models.json, pi fails early unlessapiKeyis present in the provider config itself.Example error:
This happens even when
auth.jsonalready contains:{ "digitflowai": { "type": "api_key", "key": "..." } }Reproduction
auth.json{ "ollama-cloud": { "type": "api_key", "key": "real-secret" } }models.json{ "providers": { "ollama-cloud": { "api": "openai-completions", "baseUrl": "https://ollama.com/v1", "models": [ { "id": "glm-5.2" } ] } } }Actual result
pi refuses to load
models.jsonbecauseapiKeyis missing in the provider config.Workaround
Add a fake placeholder:
Then pi loads successfully and uses the real key from
auth.jsonat request time.Why this is a problem
auth.jsonis a first-class credential source.Expected behavior
If a provider already has credentials in
auth.json,models.jsonshould not require a redundantapiKeyfield just to define custom provider models.At minimum, one of these should happen:
Preferred
Skip the
apiKeyvalidation requirement when stored auth exists for that provider.Acceptable fallback
Keep the requirement, but make the error actionable and explicitly say:
auth.jsonis not currently considered by validationapiKeyfieldauth.jsonSuggested fix
During models validation/loading, check whether auth already exists for the provider before enforcing
apiKeypresence.Something like:
auth.jsonapiKeyinmodels.jsonReal affected custom providers in my setup
ollama-clouddigitflowaiyairoutervolcengine-codingEnvironment
0.79.9~/.pi/agentmodels.jsonauth.json