pi-mono
pi-mono copied to clipboard
Support shell command execution for API key resolution in models.json
Add ! prefix support to apiKey field in models.json to execute shell commands and use stdout as the API key. This allows users to store API keys in secure credential managers like macOS Keychain, 1Password, Bitwarden, or HashiCorp Vault.
Example
{
"providers": {
"my-provider": {
"baseUrl": "https://api.example.com",
"apiKey": "!security find-generic-password -ws 'anthropic'",
"api": "anthropic-messages",
"models": [...]
}
}
}
API Key Resolution
The apiKey field now supports three formats:
-
"!command"- Executes the command and uses stdout (trimmed) - Environment variable name (e.g.,
"MY_API_KEY") - Uses the value of the environment variable - Literal value - Used directly as the API key
Changes
-
packages/coding-agent/src/core/model-registry.ts: Added command execution support toresolveApiKeyConfig() -
packages/coding-agent/test/model-registry.test.ts: Added 9 tests for API key resolution -
packages/coding-agent/README.md: Updated documentation -
packages/coding-agent/CHANGELOG.md: Added changelog entry
Fixes #697