litellm/tests/unit/llms/openai_like
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
..
chat fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
embedding test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
messages refactor(anthropic): rename llms/anthropic/pass_through to llms/anthropic/messages (#48510) 2026-10-27 10:08:25 -07:00
responses test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
__init__.py test: add package initializers to migrated unit test directories 2026-09-20 11:52:07 +00:00
test_abliteration_provider.py feat(abliteration): add model pricing and capabilities (#48498) 2026-10-26 18:08:29 -07:00
test_aiand_provider.py fix(aiand)!: show ai&'s name and logo, and sync ai&'s model list (#49158) 2026-10-30 10:55:26 -07:00
test_assemblyai_provider.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_charity_engine.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_cognition_provider.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_coralbricks_provider.py feat(providers): add CoralBricks as a native provider (#44700) 2026-10-12 21:56:59 +00:00
test_cortecs_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_dynamic_config.py feat: update EmpirioLabs models in model_prices_and_context_window.json (#49980) 2026-11-04 20:11:52 +00:00
test_empiriolabs_provider.py feat: update EmpirioLabs models in model_prices_and_context_window.json (#49980) 2026-11-04 20:11:52 +00:00
test_hostinger_router_provider.py feat!: add Hostinger Router as an OpenAI-compatible provider (#44863) 2026-10-31 00:38:45 -07:00
test_inferenceapis_provider.py feat(providers): add Inference APIs as OpenAI-compatible provider (#41669) 2026-10-15 08:17:36 -07:00
test_json_loader.py fix(crusoe): update base URL to current endpoint (#33121) 2026-10-15 19:10:58 -07:00
test_json_providers.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_kyma_provider.py fix(cost): split a provider-reported total between input and output by the cost map rate ratio (#49357) 2026-10-31 09:04:50 -07:00
test_libertai_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_meta_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_model_info.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_openinfer_provider.py refactor(cost-map): drop the legacy max_tokens field in favor of max_input_tokens and max_output_tokens (#48471) 2026-10-26 17:03:05 -07:00
test_pinstripes_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_prism_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_provider_affinity_forwarding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_refuseless_provider.py feat(refuseless): add provider and model pricing (#48497) 2026-10-26 18:08:42 -07:00
test_reka_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_sarvam_provider.py feat(sarvam): send a litellm User-Agent on chat requests (#52012) 2026-11-17 23:52:53 +00:00
test_scx_ai_provider.py feat(cost-map): add scx-ai DeepSeek-V4.1-flash, GLM-5.3 and Kimi-K3 (#46496) 2026-10-14 20:22:16 -07:00
test_streamlake_provider.py feat!: add StreamLake provider metadata (#41006) 2026-10-28 20:19:06 -07:00
test_tensormesh_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vispark_provider.py feat(litellm): add Vispark provider with Vision Small/Medium/Large (#41192) 2026-11-17 00:48:52 -08:00
test_wally_provider.py feat(providers): add Wally as an OpenAI-compatible provider (#45662) 2026-11-04 00:21:25 +00:00
test_xiaomi_mimo.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_zerogpu_provider.py feat(providers): add ZeroGPU as an OpenAI-compatible provider (#43874) 2026-10-28 12:40:32 -07:00