mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 13:03:42 +00:00
Add API keys in settings.json, fixes #295
This commit is contained in:
parent
e234e8d18f
commit
bb1da1ec51
4 changed files with 72 additions and 20 deletions
|
|
@ -258,10 +258,16 @@ If no model is provided:
|
|||
|
||||
### API Keys
|
||||
|
||||
API key resolution priority:
|
||||
1. `settings.json` apiKeys (e.g., `{ "apiKeys": { "anthropic": "sk-..." } }`)
|
||||
2. Custom providers from `models.json`
|
||||
3. OAuth credentials from `oauth.json`
|
||||
4. Environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, etc.)
|
||||
|
||||
```typescript
|
||||
import { defaultGetApiKey, configureOAuthStorage } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Default: checks models.json, OAuth, environment variables
|
||||
// Default: checks settings.json, models.json, OAuth, environment variables
|
||||
const { session } = await createAgentSession();
|
||||
|
||||
// Custom resolver
|
||||
|
|
@ -271,7 +277,7 @@ const { session } = await createAgentSession({
|
|||
if (model.provider === "anthropic") {
|
||||
return process.env.MY_ANTHROPIC_KEY;
|
||||
}
|
||||
// Fall back to default
|
||||
// Fall back to default (pass settingsManager for settings.json lookup)
|
||||
return defaultGetApiKey()(model);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue