litellm/litellm/litellm_core_utils
Krish Dholakia 644f66a7d3
Agent Guardrails - on streaming output (#21206)
* fix(ui/): add mcp input as an example for custom code guardrails

* feat(a2a/): ensure a2a guardrails works on response output

* feat(a2a/): support streaming guardrails

* fix(ui/): add mcp input as an example for custom code guardrails
2026-02-14 11:36:52 -08:00
..
audio_utils Use audio content for caching 2025-12-08 19:31:22 +05:30
llm_cost_calc feat(bedrock): add base cache costs for sonnet v1 (#20214) 2026-02-01 09:36:51 +08:00
llm_response_utils Fix gpt-image-1.5 cost calculation not including output image tokens (#19515) 2026-01-22 19:42:15 -08:00
prompt_templates fix(bedrock): handle concatenated JSON in tool call arguments (#20742) 2026-02-10 16:00:36 +05:30
specialty_caches
tokenizers
api_route_to_call_types.py Agent Guardrails - on streaming output (#21206) 2026-02-14 11:36:52 -08:00
app_crypto.py
asyncify.py
cached_imports.py
cli_token_utils.py
core_helpers.py Add compaction type block in the output 2026-02-06 11:31:35 +05:30
coroutine_checker.py
credential_accessor.py
custom_logger_registry.py feat: add support focus export 2026-01-08 16:48:06 +09:00
dd_tracing.py
default_encoding.py fix: resolve Read-only file system error in non-root images (#19449) 2026-01-20 19:00:52 -08:00
dot_notation_indexing.py Add Kubernetes ServiceAccount JWT authentication support (#18055) 2026-01-02 14:02:31 +05:30
duration_parser.py
env_utils.py fix(callbacks): allow MAX_CALLBACKS override via env var (#20781) 2026-02-09 12:11:32 -08:00
exception_mapping_utils.py fix openai tests 2026-02-12 17:53:47 -08:00
fallback_utils.py fix: filter internal params in fallback code and fix test issues (#17941) 2025-12-13 15:05:26 -08:00
get_litellm_params.py perf: Optimize get_litellm_params with sparse kwargs extraction (#19884) 2026-02-07 10:38:43 -08:00
get_llm_provider_logic.py Fix MCP streaming test skip logic and metadata None check (#20428) 2026-02-12 19:39:05 +05:30
get_model_cost_map.py [Stability] Investigate + fix issue where model cost map became poorly formatted (#20895) 2026-02-10 15:17:01 -08:00
get_provider_specific_headers.py
get_supported_openai_params.py [New provider] Sap gen ai hub (#16053) 2025-12-08 12:31:06 -08:00
health_check_helpers.py Add Vertex and Gemini Videos API with Cost Tracking + UI support (#16323) 2025-11-08 16:03:51 -08:00
health_check_utils.py
initialize_dynamic_callback_params.py Fix test_global_redaction_off_with_dynamic_params 2026-02-05 18:26:03 +05:30
json_validation_rule.py
litellm_logging.py Merge pull request #21092 from BerriAI/litellm_azure_batches_issues 2026-02-13 22:06:21 +05:30
llm_request_utils.py
logging_callback_manager.py fix(callbacks): allow MAX_CALLBACKS override via env var (#20781) 2026-02-09 12:11:32 -08:00
logging_utils.py
logging_worker.py [Release Day] - Fixed CI/CD issues & changed processes (#19902) 2026-01-28 17:57:24 -08:00
mock_functions.py
model_param_helper.py perf: cache _get_relevant_args_to_use_for_logging() at module level (#20077) 2026-02-02 10:54:49 -08:00
model_response_utils.py fix: resolve memory leak caused by Pydantic 2.11+ deprecation warnings (#16110) 2025-11-01 13:16:32 -07:00
README.md Guardrails API - add streaming support (#17400) 2025-12-02 22:52:09 -08:00
realtime_streaming.py
redact_messages.py fix: redaction headers ignored when sent via proxy (#20740) 2026-02-11 15:44:37 +05:30
response_header_helpers.py
rules.py
safe_json_dumps.py fix: shared health check serialization (#21119) 2026-02-13 09:15:43 -08:00
safe_json_loads.py
sensitive_data_masker.py Mask extra header secrets in model info (#18822) 2026-01-08 23:42:05 +05:30
streaming_chunk_builder_utils.py fix(streaming): preserve interleaved thinking/redacted blocks 2026-02-08 05:04:47 -06:00
streaming_handler.py fix: for test 2026-01-23 13:34:07 +09:00
thread_pool_executor.py
token_counter.py fix(mypy): resolve missing return statements and type casting issues (#20618) 2026-02-06 17:49:35 -08: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"
  • api_route_to_call_types.py: mapping of API routes to their corresponding CallTypes (e.g., /chat/completions -> [acompletion, completion])