Open
Conversation
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.
Changes
aibridge:
config/config.go— AddedBYOKBearerTokenfield toAnthropicconfig for OAuth-based BYOK (Claude Max/Pro).provider/anthropic.go—CreateInterceptordetects user LLM credentials from surviving request headers and sets them on the config copy.InjectAuthHeaderskips centralized key injection when user credentials are already present (passthrough BYOK).intercept/messages/base.go—newMessagesServiceusesoption.WithAuthToken()(Authorization: Bearer) whenBYOKBearerTokenis set, otherwiseoption.WithAPIKey()(X-Api-Key).How the flow works end-to-end
Centralized: Client sends
Authorization: Bearer <coder-token>→ http.go extracts token, strips all auth headers → providers get no user credentials → inject centralized key.BYOK (Claude Max/Pro): Client sends
Authorization: Bearer <oauth-token>+X-Coder-AI-Governance-BYOK-Token: <coder-token>→ http.go extracts Coder token from BYOK header, strips only BYOK header →Authorization: Bearer <oauth-token>survives →CreateInterceptorpicks it up asBYOKBearerToken→ SDK sends it viaWithAuthToken(). Passthrough:InjectAuthHeadersees existingAuthorization, skips injection.BYOK (personal API key): Client sends
X-Api-Key: <api-key>+X-Coder-AI-Governance-BYOK-Token: <coder-token>→ same flow butCreateInterceptorpicks upX-Api-Keyascfg.Key→ SDK sends it viaWithAPIKey(). Passthrough:InjectAuthHeadersees existingX-Api-Key, skips injection.