feat(executor): support $-based custom headers from downstream request headers

- Propagate request headers into custom-header resolution for OpenAI/Gemini/XAI/Codex execution and websocket flows.
- Resolve auth `header:` values like `$ABC` from incoming request headers at request time and omit headers when no value is available.
- Add documentation for the dynamic custom-header behavior in `config.example.yaml`.

Closes: #5053
This commit is contained in:
Luis Pater
2026-08-18 19:33:37 +08:00
parent f3e836ce6c
commit e424bfad00
20 changed files with 646 additions and 59 deletions

View File

@@ -79,7 +79,7 @@ func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, re
if err != nil {
return resp, err
}
applyCodexHeaders(httpReq, auth, apiKey, true, e.cfg)
applyCodexHeaders(httpReq, auth, apiKey, true, e.cfg, opts.Headers)
applyModelHeaderOverrides(httpReq.Header, baseModel)
applyCodexIdentityConfuseHeaders(httpReq.Header, &identityState)
var authID, authLabel, authType, authValue string
@@ -239,7 +239,7 @@ func (e *CodexExecutor) executeCompact(ctx context.Context, auth *cliproxyauth.A
if err != nil {
return resp, err
}
applyCodexHeaders(httpReq, auth, apiKey, false, e.cfg)
applyCodexHeaders(httpReq, auth, apiKey, false, e.cfg, opts.Headers)
applyModelHeaderOverrides(httpReq.Header, baseModel)
applyCodexIdentityConfuseHeaders(httpReq.Header, &identityState)
var authID, authLabel, authType, authValue string