8000 feat: aibrige BYOK by evgeniy-scherbina · Pull Request #216 · coder/aibridge · GitHub
[go: up one dir, main page]

Skip to content

feat: aibrige BYOK#216

Open
evgeniy-scherbina wants to merge 2 commits intomainfrom
yevhenii/aibridge-byok-v3
Open

feat: aibrige BYOK#216
evgeniy-scherbina wants to merge 2 commits intomainfrom
yevhenii/aibridge-byok-v3

Conversation

@evgeniy-scherbina
Copy link
@evgeniy-scherbina evgeniy-scherbina commented Mar 12, 2026

Changes

aibridge:

  • config/config.go — Added BYOKBearerToken field to Anthropic config for OAuth-based BYOK (Claude Max/Pro).
  • provider/anthropic.goCreateInterceptor detects user LLM credentials from surviving request headers and sets them on the config copy. InjectAuthHeader skips centralized key injection when user credentials are already present (passthrough BYOK).
  • intercept/messages/base.gonewMessagesService uses option.WithAuthToken() (Authorization: Bearer) when BYOKBearerToken is set, otherwise option.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 → CreateInterceptor picks it up as BYOKBearerToken → SDK sends it via WithAuthToken(). Passthrough: InjectAuthHeader sees existing Authorization, skips injection.

BYOK (personal API key): Client sends X-Api-Key: <api-key> + X-Coder-AI-Governance-BYOK-Token: <coder-token> → same flow but CreateInterceptor picks up X-Api-Key as cfg.Key → SDK sends it via WithAPIKey(). Passthrough: InjectAuthHeader sees existing X-Api-Key, skips injection.

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.

1 participant

0