litellm/tests/unit/llms/base_llm/chat
ryan-crabbe-berri a7cf9c6c86
fix(openai-compat): send provider attribution headers on the default SDK path (+ Perplexity) (#44291)
* fix(openai-compat): send provider attribution headers on the default SDK path

Provider-specific headers set in validate_environment are never sent for
OpenAI-compatible providers on the default OpenAI SDK path, which doesn't
call it. Novita's X-Novita-Source has been silently missing as a result.

Add BaseConfig.get_attribution_headers() and merge it into the outbound
headers in _complete_custom_openai, which feeds both the SDK and the
experimental http-handler paths. Caller headers win, case-insensitively.

* feat(perplexity): send X-Pplx-Integration attribution header

Ports the change from #38565 onto the attribution-header hook so it is
sent on the default SDK path too.

Co-authored-by: Saleh Alghusson <1331721+qirh@users.noreply.github.com>

* test: capture attribution headers in-process instead of over a socket

Address review: unit tests now drive litellm.completion into an httpx
transport rather than a local HTTP server; type the header helper as
dict[str, str]; bind the merged headers to a Final instead of
rebinding headers in _complete_custom_openai.

* style: drop explanatory comments flagged by review

---------

Co-authored-by: Saleh Alghusson <1331721+qirh@users.noreply.github.com>
2026-10-07 13:21:27 -07:00
..
__init__.py feat(sail): add Sail as a provider with service_tier mapped to its completion window (#42840) 2026-09-26 12:57:48 -07:00
test_attribution_headers.py fix(openai-compat): send provider attribution headers on the default SDK path (+ Perplexity) (#44291) 2026-10-07 13:21:27 -07:00
test_transformation.py feat(sail): add Sail as a provider with service_tier mapped to its completion window (#42840) 2026-09-26 12:57:48 -07:00