feat(rig-core): respect custom Authorization headers set via http_headers()#1553
Merged
joshua-mo-143 merged 2 commits into0xPlaygrounds:mainfrom Mar 29, 2026
Merged
Conversation
…ders() Skip auto-generated auth header insertion when the user has already set the same header manually via `http_headers()`. This allows using OpenAI-compatible providers that require a different auth scheme (e.g. `Api-Key` for Yandex Cloud instead of `Bearer`). Existing behavior is fully preserved — the auto-generated header is only skipped when a manual override is already present.
…ders() Refactor API key header insertion logic
Merged
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.
Summary
ClientBuilder::build()currently unconditionally overwrites theAuthorizationheader with the provider's default auth scheme (e.g.Bearer). This makes it impossible to use OpenAI-compatible providers that require a different auth scheme viahttp_headers().This PR adds a single
contains_keycheck so that headers set manually viahttp_headers()take precedence over auto-generated ones.Motivation
Yandex Cloud Foundation Models exposes an OpenAI-compatible API at
https://llm.api.cloud.yandex.net/v1/chat/completions, but requiresAuthorization: Api-Key <key>instead ofBearer.Currently the only workaround is to bypass
rigentirely and use rawreqwest, or to addreqwest-middlewarethat rewrites the header after rig sets it — both defeat the purpose of using the library.Change
Usage after this change
Backwards compatibility
Fully backwards-compatible. The auto-generated header is only skipped when the user has explicitly set the same header key via
http_headers(). Ifhttp_headers()is not used (the common case), behavior is identical to before.