feat(llm): support extra_headers in config for custom API gateways - #4
Merged
Merged
Conversation
Some API gateways (e.g. enterprise proxies) require custom HTTP headers
beyond the standard Authorization header. This change reads an optional
`extra_headers` dict from the `llm` section of `config.json` and passes
it as `default_headers` to both the sync `OpenAI` and async `AsyncOpenAI`
clients.
Example config:
```json
"llm": {
"provider": "openai",
"api_url": "https://my-gateway.example.com/v1",
"api_key": "sk-...",
"model": "gpt-4o",
"extra_headers": {
"X-Custom-Header": "value"
}
}
```
Collaborator
|
Thanks for your contribution! |
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
Some API gateways and enterprise proxies require custom HTTP headers in addition to the standard
Authorizationheader. This PR adds support for an optionalextra_headersfield in thellmsection ofconfig.json, which is forwarded asdefault_headersto both the sync and async OpenAI clients.Changes
catchme/services/llm.py: Readextra_headersfrom config and pass toOpenAI/AsyncOpenAIasdefault_headerscatchme/services/config.example.json: Document the newextra_headersfield (empty dict as default)Usage
If
extra_headersis omitted or empty, behaviour is identical to before.Test plan
extra_headersworks as before (no regression)extra_headerssends the specified headers on every LLM call