Skip to content

feat(llm): support extra_headers in config for custom API gateways - #4

Merged
pancacake merged 1 commit into
HKUDS:mainfrom
sihyeonn:feat/extra-headers-support
Apr 9, 2026
Merged

feat(llm): support extra_headers in config for custom API gateways#4
pancacake merged 1 commit into
HKUDS:mainfrom
sihyeonn:feat/extra-headers-support

Conversation

@sihyeonn

@sihyeonn sihyeonn commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Some API gateways and enterprise proxies require custom HTTP headers in addition to the standard Authorization header. This PR adds support for an optional extra_headers field in the llm section of config.json, which is forwarded as default_headers to both the sync and async OpenAI clients.

Changes

  • catchme/services/llm.py: Read extra_headers from config and pass to OpenAI / AsyncOpenAI as default_headers
  • catchme/services/config.example.json: Document the new extra_headers field (empty dict as default)

Usage

"llm": {
    "provider": "openai",
    "api_url": "https://my-gateway.example.com/v1",
    "api_key": "sk-...",
    "model": "gpt-4o",
    "extra_headers": {
        "X-Custom-Header": "value"
    }
}

If extra_headers is omitted or empty, behaviour is identical to before.

Test plan

  • Config without extra_headers works as before (no regression)
  • Config with extra_headers sends the specified headers on every LLM call

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"
    }
}
```
@pancacake

Copy link
Copy Markdown
Collaborator

Thanks for your contribution!

@pancacake
pancacake merged commit d0331b6 into HKUDS:main Apr 9, 2026
7 checks passed
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.

2 participants