Some OpenAI-compatible APIs require custom HTTP headers or dynamic token exchange before each request. For example, GitHub Copilot's chat API requires:
- An
Editor-Version header on every request
- Exchanging a long-lived OAuth token for a short-lived session token via a separate endpoint before each chat call
Currently there's no way to achieve either through LLMBuilder or OpenAICompatibleProvider. The OpenAIProviderConfig trait has custom_headers(), but it's only available when implementing a new provider inside the crate — not from user code.
Idea
- Add a
.header(key, value) method to LLMBuilder that forwards custom headers to the underlying provider's HTTP requests
- Add a hook (e.g.
.auth_provider(callback)) that lets users supply a function to dynamically resolve/refresh the bearer token before each request
This would allow integrating providers like GitHub Copilot without having to reimplement the entire ChatProvider trait from scratch.
Some OpenAI-compatible APIs require custom HTTP headers or dynamic token exchange before each request. For example, GitHub Copilot's chat API requires:
Editor-Versionheader on every requestCurrently there's no way to achieve either through
LLMBuilderorOpenAICompatibleProvider. TheOpenAIProviderConfigtrait hascustom_headers(), but it's only available when implementing a new provider inside the crate — not from user code.Idea
.header(key, value)method toLLMBuilderthat forwards custom headers to the underlying provider's HTTP requests.auth_provider(callback)) that lets users supply a function to dynamically resolve/refresh the bearer token before each requestThis would allow integrating providers like GitHub Copilot without having to reimplement the entire
ChatProvidertrait from scratch.