mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* 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>
|
||
|---|---|---|
| .. | ||
| chat | ||
| embedding | ||
| messages | ||
| responses | ||
| __init__.py | ||
| test_abliteration_provider.py | ||
| test_aiand_provider.py | ||
| test_assemblyai_provider.py | ||
| test_charity_engine.py | ||
| test_cognition_provider.py | ||
| test_coralbricks_provider.py | ||
| test_cortecs_provider.py | ||
| test_dynamic_config.py | ||
| test_empiriolabs_provider.py | ||
| test_hostinger_router_provider.py | ||
| test_inferenceapis_provider.py | ||
| test_json_loader.py | ||
| test_json_providers.py | ||
| test_kyma_provider.py | ||
| test_libertai_provider.py | ||
| test_meta_provider.py | ||
| test_model_info.py | ||
| test_openinfer_provider.py | ||
| test_pinstripes_provider.py | ||
| test_prism_provider.py | ||
| test_provider_affinity_forwarding.py | ||
| test_refuseless_provider.py | ||
| test_reka_provider.py | ||
| test_sarvam_provider.py | ||
| test_scx_ai_provider.py | ||
| test_streamlake_provider.py | ||
| test_tensormesh_provider.py | ||
| test_vispark_provider.py | ||
| test_wally_provider.py | ||
| test_xiaomi_mimo.py | ||
| test_zerogpu_provider.py | ||