litellm/tests/router_unit_tests
Martin Gauthier dd087c8cca
🐛 fix: propagate headers in router embedding calls (#18844)
Fix router embedding methods to properly propagate proxy model
configuration headers to LLM API calls by calling
_update_kwargs_before_fallbacks() just like completion() does.

Previously, router.embedding() and router.aembedding() manually
set num_retries and metadata but didn't call
_update_kwargs_before_fallbacks(), which meant default_litellm_params
(including headers) were not propagated correctly.

Changes:
- Replace manual kwargs setup with _update_kwargs_before_fallbacks()
  in _embedding method (litellm/router.py:3318)
- Apply Black formatting to router.py for consistency
- Add comprehensive unit tests for header propagation
- Add integration tests for various router configurations

Tests verify:
- Headers from default_litellm_params are included in embedding calls
- Metadata (model_group) is properly set
- Consistency between completion() and embedding() behavior
- Support for deployment-specific headers, fallbacks, and retries
2026-01-09 23:57:18 +05:30
..
conftest.py [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
create_mock_standard_logging_payload.py (refactor) - migrate router.deployment_callback_on_success to use StandardLoggingPayload (#7015) 2024-12-03 20:29:25 -08:00
gettysburg.wav test(router_code_coverage.py): check if all router functions are dire… (#6186) 2024-10-14 22:44:00 -07:00
README.md test(router_code_coverage.py): check if all router functions are dire… (#6186) 2024-10-14 22:44:00 -07:00
test_completion_no_copy.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_default_deployment_copy.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_pre_call_checks_optimization.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_prompt_management_check.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_router_adding_deployments.py Support env var vertex credentials for passthrough + ignore space id on watsonx deployment (throws Json validation errors) (#11527) 2025-06-07 20:31:05 -07:00
test_router_batch_utils.py fix(batch_utils.py): improve batch utils to handle newlines within batch content 2025-11-05 16:15:09 -08:00
test_router_cooldown_utils.py fix(router): add minimum request threshold for error rate cooldown (#17464) 2025-12-12 04:36:10 -08:00
test_router_embedding_headers.py 🐛 fix: propagate headers in router embedding calls (#18844) 2026-01-09 23:57:18 +05:30
test_router_embedding_integration.py 🐛 fix: propagate headers in router embedding calls (#18844) 2026-01-09 23:57:18 +05:30
test_router_endpoints.py Remove redundant comments about setting litellm.callbacks (#18711) 2026-01-06 23:58:01 +05:30
test_router_handle_error.py fix(handle_error.py): add unit tests 2025-08-11 18:25:30 -07:00
test_router_helper_utils.py test_routing_strategy_init 2026-01-07 14:21:03 +05:30
test_router_index_management.py [Oct Staging Branch] (#15460) 2025-10-17 17:52:25 -07:00
test_router_prompt_caching.py [Fix] - Router's Cache: Fix routing for requests with same cacheable prefix but different user messages (#16951) 2025-11-21 19:13:40 -08:00

Router component unit tests.

Please name all files with the word 'router' in them.

This is used to ensure all functions in the router are tested.