-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Problem
AI Bridge drops client request headers when making upstream API calls. The messages interceptor constructs a new HTTP request via the provider SDK, which sets its own headers (SDK user-agent, API key, version, etc.) and does not include the original client headers. While we support setting individual headers via option.WithHeader, this approach is cumbersome as it requires code changes every time a new header is required.
For example, Claude Code sends Anthropic-Beta: context-management header alongside a context_management field in the request body. AI Bridge preserves the body but drops the header, causing Anthropic to reject the request with a 400. The current workaround is CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, which prevents Claude Code from sending the beta field entirely. Related to internal Slack thread: https://codercom.slack.com/archives/C096PFVBZKN/p1772115088945279
Proposed solution
Bridged routes should forward client headers to the upstream provider, similar to what passthrough routes already do via req.Header = r.Header.Clone().