feat(ai-anthropic, ai-openai): support custom HTTP headers for custom model endpoints - #17907
Open
safisa wants to merge 2 commits into
Open
feat(ai-anthropic, ai-openai): support custom HTTP headers for custom model endpoints#17907safisa wants to merge 2 commits into
safisa wants to merge 2 commits into
Conversation
safisa
force-pushed
the
feat/ai-custom-model-headers
branch
from
August 19, 2026 08:21
1ad8c6c to
cf137df
Compare
safisa
force-pushed
the
feat/ai-custom-model-headers
branch
from
August 27, 2026 21:35
cf137df to
f4cb675
Compare
… model endpoints Custom model entries can only configure 'url' and 'apiKey', so there is no way to send additional HTTP headers to the endpoint. Deployments that route LLM traffic through a gateway in front of the vendor API commonly require extra headers for audit, attribution or routing, and reject requests that omit them. The only workaround is a reverse proxy that injects them. Add an optional 'headers' map to the custom model preference entries. The headers are passed to the SDK clients as 'defaultHeaders', so they are sent with every request to that endpoint, including the Anthropic /v1/models lookup which resolves model metadata. Header values are resolved by the shared resolveCustomModelHeaders helper, which drops non-string entries since preferences are user-authored JSON, and returns undefined when nothing usable remains so default headers stay untouched. Resolves eclipse-theiaGH-17906 Signed-off-by: safi <safi@k2view.com>
Signed-off-by: safi <safi@k2view.com>
safisa
force-pushed
the
feat/ai-custom-model-headers
branch
from
September 2, 2026 12:56
f4cb675 to
4bc4423
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Adds an optional
headersmap to custom model entries forai-anthropicandai-openai, sent with every request to that endpoint.Fixes #17906
Custom model entries can only configure
urlandapiKeytoday. Deployments that route LLM traffic through a gateway in front of the vendor API commonly require additional headers for audit, attribution or routing, and reject requests that omit them — the only workaround being a reverse proxy that injects them.The map is passed to the SDK clients as
defaultHeaders, so it also covers the Anthropic/v1/modelslookup that resolves model metadata — a gateway enforcing the headers rejects that request too, which otherwise degrades the model's capabilities silently.Values are resolved through a shared
resolveCustomModelHeadershelper inai-core: preferences are user-authored JSON, so entries with a non-string value are dropped, andundefinedis returned when nothing usable remains, leaving the default request headers untouched.How to test
urlpoints at a local endpoint that logs the headers it receives, and add aheadersentry.headersentry the request is unchanged.npx mocha packages/ai-core/lib/common/language-model.spec.jscoversresolveCustomModelHeaders.Verified against a local HTTP server standing in for a gateway: the headers are present on
/v1/messagesand/v1/chat/completionsfor both providers through the fullrequest()path, and absent when not configured.Follow-ups
Only static per-model values are in scope here. Per-request or per-user header values (e.g. attributing a request to the signed-in user) would need request-scoped plumbing through the language model request pipeline, and are left out deliberately.
Breaking changes
The new
headersfield and the widened constructors are optional, so existing adopters are unaffected.Attribution
Contributed on behalf of K2view
Review checklist
Reminder for reviewers