fix(models): inherit baseUrl and api from provider config#2740
fix(models): inherit baseUrl and api from provider config#2740gumadeiras merged 4 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where custom provider configurations (baseUrl and api) were not being inherited by inline model definitions. When users configured a custom provider with these settings at the provider level, individual models within that provider would fail to inherit these configurations, causing requests to fail with 401 errors or be sent to incorrect endpoints.
Changes:
- Updated
buildInlineProviderModelsto inheritbaseUrlandapifrom provider configuration to inline models - Modified
InlineModelEntrytype to includebaseUrlfield - Updated
resolveModelfallback model creation to includebaseUrlfrom provider config
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return (entry?.models ?? []).map((model) => ({ | ||
| ...model, | ||
| provider: trimmed, | ||
| baseUrl: entry?.baseUrl, | ||
| api: model.api ?? entry?.api, | ||
| })); |
There was a problem hiding this comment.
The existing test for buildInlineProviderModels does not verify the new behavior introduced in this fix. The test should be updated to verify that baseUrl and api are correctly inherited from the provider configuration.
Consider adding a test case that verifies:
baseUrlis inherited from the provider when models don't specify itapiis inherited from the provider when models don't specify it- Model-level
apitakes precedence over provider-levelapiwhen both are present
2cd7dd0 to
79e4cf8
Compare
|
CI is failing due to the workspace dependency issue ( |
When using custom providers with inline model definitions, the baseUrl and api properties from the provider config were not being passed to the individual models. This caused requests to be sent to the wrong endpoint or with the wrong API format. Changes: - buildInlineProviderModels now copies baseUrl from provider to models - buildInlineProviderModels now inherits api from provider if not set on model - resolveModel fallback path now includes baseUrl from provider config Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>
Add test cases to verify: - baseUrl is inherited from provider when model does not specify it - api is inherited from provider when model does not specify it - model-level api takes precedence over provider-level api - both baseUrl and api can be inherited together Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
79e4cf8 to
db40dca
Compare
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
`buildInlineProviderModels()` reads `baseUrl` and `api` from the provider config but omits `headers`. This causes custom HTTP headers (e.g. User-Agent overrides) configured in `models.providers` to be silently ignored for all chat/reply API requests. The pi-ai Anthropic provider already supports `model.headers` via `mergeHeaders()`, and the runner entry already reads `providerConfig?.headers` — only the main reply path was missing it. This is a follow-up to openclaw#2740 which fixed the same class of bug for `baseUrl` but missed `headers`. Fixes openclaw#15682
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
Summary
baseUrlandapiwere not inherited byinline model definitions
Problem
When configuring a custom provider with
baseUrlandapiat the providerlevel: