litellm/tests/unit/llms/base_llm
vikashmaddi-sarvam 41b90d4880
feat(sarvam): send a litellm User-Agent on chat requests (#52012)
* feat(sarvam): send a litellm User-Agent on chat requests

The Sarvam API logs the User-Agent of each request, which is how traffic is
attributed. LiteLLM's chat path currently sends the OpenAI SDK default
User-Agent, so requests through the JSON-configured sarvam provider are
indistinguishable from direct OpenAI SDK calls.

Add an optional user_agent template to the JSON provider config and wire JSON
providers into the existing attribution-header helper, which until now only ran
for providers with a provider_config. The template reports the running LiteLLM
and Python versions (litellm/1.110.0 Python/3.12.16).

The generated JSONProviderConfig forwards get_attribution_headers to the JSON
config, so the field also works for the JSON providers that are in LlmProviders
and therefore get a provider_config.

The field is opt-in: providers without user_agent keep their current headers,
and a caller-supplied User-Agent still wins, as documented on
get_attribution_headers.

🪷 Generated with Sarvam Code

Co-authored-by: Sarvam Code <code@sarvam.ai>

* refactor(sarvam): type the user_agent field and drop comments

* fix(sarvam): keep a caller client's User-Agent and honor LITELLM_USER_AGENT

A User-Agent set as a default header on the caller's own OpenAI client now wins over the provider attribution, and LITELLM_USER_AGENT replaces the JSON provider's user_agent template. Documents the user_agent field and tightens test types

* fix(sarvam): keep a client subclass's User-Agent and honor an empty LITELLM_USER_AGENT

* test(attribution): cover a caller client header in either spelling

* refactor(attribution): type the caller client and narrow it at the call site

---------

Co-authored-by: Vikash Maddi <vikashmaddi-sarvam@users.noreply.github.com>
Co-authored-by: Sarvam Code <code@sarvam.ai>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-17 23:52:53 +00:00
..
audio_transcription test: make 38 legacy live base-class translation tests offline (#45351) 2026-10-08 23:18:25 +00:00
auth ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
batches fix(bedrock): derive the web identity session policy per AWS caller (#50592) 2026-11-08 19:13:53 +00:00
chat feat(sarvam): send a litellm User-Agent on chat requests (#52012) 2026-11-17 23:52:53 +00:00
decisions feat(decisions): add Parallel AI web-grounded decisions (#49188) 2026-11-03 04:47:02 +00:00
embedding fix(embeddings): unwrap extra_body for providers with their own embedding handlers (#51335) 2026-11-12 15:41:50 -08:00
files test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
guardrail_translation fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
harness feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway (#43885) 2026-10-01 22:27:49 +00:00
realtime test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
rerank test: make 38 legacy live base-class translation tests offline (#45351) 2026-10-08 23:18:25 +00:00
responses fix(router): prevent Responses fallback from replaying delivered tool calls (#51683) 2026-11-13 11:43:03 -08:00
search test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
vector_store test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_base_managed_resource.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_base_model_iterator.py fix(streaming): exact-match the SSE [DONE] marker in BaseModelResponseIterator (#47832) 2026-10-28 05:21:31 -07:00
test_base_utils.py fix(llms): move later developer messages for models declared system-first (#48897) 2026-10-29 04:12:13 -07:00
test_managed_resource_isolation.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_managed_resources_utils.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00