Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix(llm): apply LLM_EXTRA_HEADERS on native OpenAI route even without a custom base

Ahmed Allame9ebdc502f05
diff --git a/strix/config/models.py b/strix/config/models.py
index 34e298ca..7892957d 100644
--- a/strix/config/models.py
+++ b/strix/config/models.py
@@ -362,8 +362,7 @@ def _configure_extra_headers(llm: LlmSettings) -> None:
if not headers:
return
_merge_litellm_headers(headers)
- if llm.api_base:
- _register_openai_client_with_headers(llm, headers)
+ _register_openai_client_with_headers(llm, headers)
def _merge_litellm_headers(headers: dict[str, str]) -> None:
diff --git a/tests/test_llm_extra_headers.py b/tests/test_llm_extra_headers.py
index e65b72aa..f2910156 100644
--- a/tests/test_llm_extra_headers.py
+++ b/tests/test_llm_extra_headers.py
@@ -73,6 +73,20 @@ def test_extra_headers_applied_to_native_openai_client(monkeypatch: pytest.Monke
assert str(client.base_url).rstrip("/") == "https://gateway.example/v1"
+def test_extra_headers_applied_to_native_openai_without_custom_base(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setenv("STRIX_LLM", "openai/gpt-5")
+ monkeypatch.setenv("LLM_API_KEY", "token")
+ monkeypatch.setenv("LLM_EXTRA_HEADERS", json.dumps({"X-Feature-Key": "svc"}))
+
+ configure_sdk_model_defaults(load_settings())
+
+ client = _openai_shared.get_default_openai_client()
+ assert client is not None
+ assert client.default_headers.get("X-Feature-Key") == "svc"
+
+
def test_no_extra_headers_leaves_litellm_headers_untouched(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("STRIX_LLM", "openai/some-model")
monkeypatch.setenv("LLM_API_BASE", "https://gateway.example/v1")