@@ -99,15 +99,18 @@ def test_no_warning_when_supported(self, monkeypatch, caplog):
9999
100100
101101class _FakeBundle :
102- def __init__ (self , api_key = None , base_url = None ):
102+ def __init__ (self , api_key = None , base_url = None , extra_headers = None , timeout = None ):
103103 self .api_key = api_key
104104 self .base_url = base_url
105+ self .extra_headers = extra_headers or {}
106+ self .timeout = timeout
105107
106108
107109class TestBuildIndexConfigLlmParams :
108- """``bundle``'s api_key/base_url must reach PageIndex's own LLM calls via
109- ``IndexConfig(llm_params=...)`` (#219) — without this they silently fall
110- back to LiteLLM's default provider-key/env-var lookup."""
110+ """``bundle``'s api_key/base_url/extra_headers/timeout must reach PageIndex's
111+ own LLM calls via ``IndexConfig(llm_params=...)`` (#219) — without this they
112+ silently fall back to LiteLLM's default provider-key/env-var lookup (or, for
113+ header-only gateway auth, have no credentials at all)."""
111114
112115 def test_forwards_api_key_and_base_url_when_supported (self , monkeypatch ):
113116 monkeypatch .setattr ("openkb.indexer.IndexConfig" , _FakeIndexConfigWithConcurrency )
@@ -138,6 +141,35 @@ def test_does_not_forward_when_unsupported(self, monkeypatch, caplog):
138141 assert not hasattr (cfg , "llm_params" )
139142 assert "llm_params" in caplog .text
140143
144+ def test_forwards_extra_headers_and_timeout_when_supported (self , monkeypatch ):
145+ monkeypatch .setattr ("openkb.indexer.IndexConfig" , _FakeIndexConfigWithConcurrency )
146+ bundle = _FakeBundle (extra_headers = {"Authorization" : "Bearer proxy-token" }, timeout = 30.0 )
147+ cfg = _build_index_config ({}, bundle )
148+ assert cfg .llm_params == {
149+ "extra_headers" : {"Authorization" : "Bearer proxy-token" },
150+ "timeout" : 30.0 ,
151+ }
152+
153+ def test_empty_extra_headers_is_not_forwarded (self , monkeypatch ):
154+ monkeypatch .setattr ("openkb.indexer.IndexConfig" , _FakeIndexConfigWithConcurrency )
155+ cfg = _build_index_config ({}, _FakeBundle (extra_headers = {}))
156+ assert not hasattr (cfg , "llm_params" )
157+
158+ def test_zero_timeout_is_forwarded (self , monkeypatch ):
159+ # timeout=0 is falsy but a deliberately-set value — must not be filtered
160+ # out the same way an unset (None) timeout is.
161+ monkeypatch .setattr ("openkb.indexer.IndexConfig" , _FakeIndexConfigWithConcurrency )
162+ cfg = _build_index_config ({}, _FakeBundle (timeout = 0 ))
163+ assert cfg .llm_params == {"timeout" : 0 }
164+
165+ def test_header_only_gateway_auth_is_forwarded_without_api_key (self , monkeypatch ):
166+ # Regression: proxy/gateway setups that authenticate purely via a
167+ # header (no LLM_API_KEY) must still reach PageIndex's LLM calls.
168+ monkeypatch .setattr ("openkb.indexer.IndexConfig" , _FakeIndexConfigWithConcurrency )
169+ bundle = _FakeBundle (extra_headers = {"Authorization" : "Bearer proxy-token" })
170+ cfg = _build_index_config ({}, bundle )
171+ assert cfg .llm_params == {"extra_headers" : {"Authorization" : "Bearer proxy-token" }}
172+
141173
142174class TestClosePageindexClient :
143175 """Best-effort close of PageIndex's local SQLite connection(s) — see #249."""
0 commit comments