Skip to content

fix(model): resolve catalog provider API keys from declared env vars#368

Open
wangyuxun6699 wants to merge 1 commit into
OpenBMB:mainfrom
wangyuxun6699:app
Open

fix(model): resolve catalog provider API keys from declared env vars#368
wangyuxun6699 wants to merge 1 commit into
OpenBMB:mainfrom
wangyuxun6699:app

Conversation

@wangyuxun6699

@wangyuxun6699 wangyuxun6699 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #339

This PR fixes credential resolution for built-in catalog providers that declare apiKeyEnvVar.

Previously, catalog providers could inherit protocol, default URL, and model defaults, but parseModelConfig ignored apiKeyEnvVar when resolving credentials. As a result, providers such as Anthropic still failed with missing_api_key unless users repeated apiKey: ${ANTHROPIC_API_KEY} in config.

Changes:

  • Use catalog apiKeyEnvVar as the default API key source when provider apiKey is absent.
  • Keep explicit apiKey config higher priority than catalog defaults.
  • Reuse existing resolveApiKey env resolution, trimming, and error behavior.
  • Preserve existing behavior for non-catalog providers and ollama.

Tests

Added coverage for:

  • Resolving Anthropic catalog credentials from ANTHROPIC_API_KEY.
  • Preserving explicit ${ENV_VAR} API key behavior.
  • Reporting missing_api_key when the catalog env var is absent.
  • Keeping non-catalog providers unchanged when no apiKey is configured.

Verified with:

  • npm run build
  • node --test --test-timeout 60000 dist/tests/model/parseModelConfig.spec.js
  • node --test --test-timeout 60000 dist/tests/model/*.spec.js
  • npx tsc -p tsconfig.json --noEmit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(model): catalog apiKeyEnvVar is ignored by credential resolution

1 participant