mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 06:04:51 +00:00
fix(ai): remove global process.env.ANTHROPIC_API_KEY deletion (#164)
* fix(ai): remove global process.env.ANTHROPIC_API_KEY deletion The code was deleting process.env.ANTHROPIC_API_KEY to prevent the SDK from using it when OAuth tokens were provided. However, this was a global mutation that affected the entire Node.js process, causing the API key to be unavailable after the first prompt. The Anthropic SDK constructor already handles credential selection via parameters (apiKey: null, authToken: token for OAuth vs apiKey: key for regular keys), so the environment variable deletion was unnecessary. * Update CHANGELOG.md for API key fix
This commit is contained in:
parent
7785b7c93f
commit
a248e2547a
2 changed files with 4 additions and 5 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed bug where `ANTHROPIC_API_KEY` environment variable was deleted globally after first OAuth token usage, causing subsequent prompts to fail
|
||||||
|
|
||||||
## [0.17.0] - 2025-12-09
|
## [0.17.0] - 2025-12-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -289,11 +289,6 @@ function createClient(
|
||||||
...(model.headers || {}),
|
...(model.headers || {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear the env var if we're in Node.js to prevent SDK from using it
|
|
||||||
if (typeof process !== "undefined" && process.env) {
|
|
||||||
delete process.env.ANTHROPIC_API_KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = new Anthropic({
|
const client = new Anthropic({
|
||||||
apiKey: null,
|
apiKey: null,
|
||||||
authToken: apiKey,
|
authToken: apiKey,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue