Skip to content

Commit 1846a85

Browse files
authored
feat: add support for extra headers in ChatLiteLLM (#35)
* feat: add support for extra headers in ChatLiteLLM * feat: add structured output support with schema validation in ChatLiteLLM * Revert "feat: add structured output support with schema validation in ChatLiteLLM" This reverts commit 1debfb5.
1 parent 3e6ef60 commit 1846a85

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

langchain_litellm/chat_models/litellm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class ChatLiteLLM(BaseChatModel):
265265
api_base: Optional[str] = None
266266
organization: Optional[str] = None
267267
custom_llm_provider: Optional[str] = None
268+
extra_headers: Optional[Dict[str, str]] = None
268269
request_timeout: Optional[Union[float, Tuple[float, float]]] = None
269270
temperature: Optional[float] = None
270271
"""Run inference with this temperature. Must be in the closed
@@ -329,6 +330,11 @@ def _client_params(self) -> Dict[str, Any]:
329330
"force_timeout": self.request_timeout,
330331
"api_base": self.api_base,
331332
}
333+
# Forward any extra headers to the client and include in params
334+
if self.extra_headers is not None:
335+
# set attribute on client for runtime usage
336+
setattr(self.client, "extra_headers", self.extra_headers)
337+
creds["extra_headers"] = self.extra_headers
332338
return {**self._default_params, **creds}
333339

334340
def completion_with_retry(

0 commit comments

Comments
 (0)