applyAuthHeader writes the appropriate authorization header for the provider. OpenAI/Anthropic/most providers use Bearer; Anthropic historically uses x-api-key + anthropic-version, but accepts Bearer too via the OpenAI-compatible path. Default to Bearer when provider is empty (passthrough mode where
(req *http.Request, provider, key string)
| 412 | // is empty (passthrough mode where the operator doesn't claim a |
| 413 | // provider). |
| 414 | func applyAuthHeader(req *http.Request, provider, key string) { |
| 415 | switch provider { |
| 416 | case providerAnthropic: |
| 417 | req.Header.Set("x-api-key", key) |
| 418 | if req.Header.Get("anthropic-version") == "" { |
| 419 | req.Header.Set("anthropic-version", "2023-06-01") |
| 420 | } |
| 421 | default: |
| 422 | req.Header.Set("Authorization", "Bearer "+key) |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // isHopByHopHeader returns true for headers that should not be |
| 427 | // forwarded from the client request to the upstream (RFC 7230 §6.1 |
no test coverage detected