litellm/litellm/litellm_core_utils
Ishaan Jaff b41ce5c92f
[Feat] - Track cost + add tags for health checks done by LiteLLM Proxy (#12880)
* refactor to use add_user_api_key_auth_to_request_metadata

* add get_litellm_internal_health_check_user_api_key_auth

* add get_litellm_internal_health_check_user_api_key_auth

* add _update_model_params_with_health_check_tracking_information

* add HealthCheckHelpers

* refactor to use clean helpers

* test_update_model_params_with_health_check_tracking_information

* test_get_litellm_internal_health_check_user_api_key_auth

* test_add_user_api_key_auth_to_request_metadata

* fix _update_model_params_with_health_check_tracking_information
2025-07-22 18:45:57 -07:00
..
audio_utils [Feat] Add Eleven Labs - Speech To Text Support on LiteLLM (#12119) 2025-06-27 17:50:49 -07:00
llm_cost_calc Fix allow strings in calculate cost (#12200) 2025-07-01 11:37:15 -07:00
llm_response_utils Fix SambaNova 'created' field validation error - handle float timestamps (#11971) 2025-06-23 07:53:21 -07:00
prompt_templates Anthropic - add tool cache control support (#12668) 2025-07-18 11:14:03 -07:00
specialty_caches [Bug]: Performance Fix Max langfuse clients reached: 20 is greater than 20 (#11285) 2025-05-30 22:34:39 -07:00
tokenizers Code Quality Improvement - remove tokenizers/ from /llms (#7163) 2024-12-10 23:50:15 -08:00
asyncify.py (core sdk fix) - fix fallbacks stuck in infinite loop (#7751) 2025-01-13 19:34:34 -08:00
core_helpers.py Litellm gemini grounding metadata stream (#12673) 2025-07-19 11:52:12 -07:00
credential_accessor.py fix(router.py): support reusable credentials via passthrough router (#9758) 2025-04-04 18:40:14 -07:00
custom_logger_registry.py [Prometheus] Move Prometheus to enterprise folder (#12659) 2025-07-18 11:54:47 -07:00
dd_tracing.py [Feat]: Performance add DD profiler to monitor python profile of LiteLLM CPU% (#11375) 2025-06-03 12:03:08 -07:00
default_encoding.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
dot_notation_indexing.py feat(handle_jwt.py): initial commit adding custom RBAC support on jwt… (#8037) 2025-01-28 16:27:06 -08:00
duration_parser.py Anthropic unified web search + tool cost tracking support (#10846) 2025-05-14 22:41:12 -07:00
exception_mapping_utils.py fix cohere InternalServerError error mapping 2025-07-16 16:13:34 -07:00
fallback_utils.py [Bug Fix] UI QA - Fix wildcard model test connection not working (#10347) 2025-04-26 17:42:06 -07:00
get_litellm_params.py feat(azure): Make Azure AD scope configurable (#11621) 2025-06-14 17:43:01 -07:00
get_llm_provider_logic.py Revert "Litellm dev 07 21 2025 p1 (#12848)" 2025-07-22 18:28:36 -07:00
get_model_cost_map.py Litellm UI qa 04 12 2025 p1 (#9955) 2025-04-12 19:30:48 -07:00
get_supported_openai_params.py [Feat] Add Eleven Labs - Speech To Text Support on LiteLLM (#12119) 2025-06-27 17:50:49 -07:00
health_check_helpers.py [Feat] - Track cost + add tags for health checks done by LiteLLM Proxy (#12880) 2025-07-22 18:45:57 -07:00
health_check_utils.py (Refactor) - Re use litellm.completion/litellm.embedding etc for health checks (#7455) 2024-12-28 18:38:54 -08:00
initialize_dynamic_callback_params.py Litellm dev 07 03 2025 p2 (#12301) 2025-07-03 22:40:21 -07:00
json_validation_rule.py [Feat] Add Bridge from generateContent <> /chat/completions (#12081) 2025-06-27 11:08:55 -07:00
litellm_logging.py [Feat] Backend - Add support for disabling callbacks in request body (#12762) 2025-07-19 10:10:30 -07:00
llm_request_utils.py [Feat] Enterprise - Allow dynamically disabling callbacks in request headers (#11985) 2025-06-23 14:32:05 -07:00
logging_callback_manager.py Allow forwarding clientside headers by model group (#12753) 2025-07-19 15:17:13 -07:00
logging_utils.py fix(streaming_handler.py): emit deep copy of completed chunk 2025-03-17 17:26:21 -07:00
mock_functions.py Support returning virtual key in custom auth + Handle provider-specific optional params for embedding calls (#11346) 2025-06-03 07:24:13 -07:00
model_param_helper.py [Bug Fix] caching does not account for thinking or reasoning_effort config (#10140) 2025-04-21 22:39:40 -07:00
README.md (QOL improvement) Provider budget routing - allow using 1s, 1d, 1mo, 2mo etc (#6885) 2024-11-23 16:59:46 -08:00
realtime_streaming.py build: merge in https://github.com/BerriAI/litellm/pull/10909 2025-05-17 07:36:56 -07:00
redact_messages.py UI - Azure Content Guardrails (#12341) 2025-07-05 10:19:29 -07:00
response_header_helpers.py fix(utils.py): guarantee openai-compatible headers always exist in response 2024-09-28 21:08:15 -07:00
rules.py Litellm dev 11 07 2024 (#6649) 2024-11-08 19:34:22 +05:30
safe_json_dumps.py Add recursion depth to convert_anyof_null_to_nullable, constants.py. Fix recursive_detector.py raise error state 2025-03-28 13:11:19 -07:00
safe_json_loads.py add support to parse metadata (#10832) 2025-05-14 12:03:49 -07:00
sensitive_data_masker.py test: fix litellm_mapped_tests 2025-05-14 18:29:01 -07:00
streaming_chunk_builder_utils.py Add 'thinking blocks' to stream chunk builder + remove experimental 'by_tag' metrics on prometheus (fix cardinality issue) (#12395) 2025-07-07 21:41:44 -07:00
streaming_handler.py Litellm gemini grounding metadata stream (#12673) 2025-07-19 11:52:12 -07:00
thread_pool_executor.py (Fixes) OpenAI Streaming Token Counting + Fixes usage track when litellm.turn_off_message_logging=True (#8156) 2025-01-31 15:06:37 -08:00
token_counter.py fix(router.py): use more descriptive error message (#12629) 2025-07-15 22:34:20 -07:00

Folder Contents

This folder contains general-purpose utilities that are used in multiple places in the codebase.

Core files:

  • streaming_handler.py: The core streaming logic + streaming related helper utils
  • core_helpers.py: code used in types/ - e.g. map_finish_reason.
  • exception_mapping_utils.py: utils for mapping exceptions to openai-compatible error types.
  • default_encoding.py: code for loading the default encoding (tiktoken)
  • get_llm_provider_logic.py: code for inferring the LLM provider from a given model name.
  • duration_parser.py: code for parsing durations - e.g. "1d", "1mo", "10s"