litellm/tests/unit/test_private_usage_aliases.py
devin-ai-integration[bot] e2971e0af4
refactor(llms): expose public names for private provider helpers (#45037)
* refactor(litellm): migrate private usage in llms

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(litellm): preserve Bedrock batch signature marker

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(litellm): migrate llms private usage symbols

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(litellm): preserve UUID Watsonx project IDs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(litellm): retarget llms mocks to public names

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(litellm): limit llms changes to renames and forwarders

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(litellm): keep GCS mock client patching private Vertex auth methods

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(litellm): assert forwarder arguments and type forwarder signatures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: mateo <mateo@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-07 08:49:25 -07:00

2404 lines
73 KiB
Python

import inspect
from collections.abc import Awaitable, Callable
from importlib import import_module
from types import MethodType
from typing import Final, cast
import pytest
ALIAS_CASES: Final = (
(
"enterprise.enterprise_hooks.banned_keywords",
"",
"_ENTERPRISE_BannedKeywords",
"ENTERPRISE_BannedKeywords",
False,
),
(
"enterprise.enterprise_hooks.blocked_user_list",
"",
"_ENTERPRISE_BlockedUserList",
"ENTERPRISE_BlockedUserList",
False,
),
(
"enterprise.enterprise_hooks.google_text_moderation",
"",
"_ENTERPRISE_GoogleTextModeration",
"ENTERPRISE_GoogleTextModeration",
False,
),
(
"enterprise.enterprise_hooks.openai_moderation",
"",
"_ENTERPRISE_OpenAI_Moderation",
"ENTERPRISE_OpenAI_Moderation",
False,
),
(
"enterprise.litellm_enterprise.proxy.hooks.managed_files",
"",
"_PROXY_LiteLLMManagedFiles",
"PROXY_LiteLLMManagedFiles",
False,
),
(
"enterprise.litellm_enterprise.proxy.hooks.managed_vector_stores",
"",
"_PROXY_LiteLLMManagedVectorStores",
"PROXY_LiteLLMManagedVectorStores",
False,
),
("litellm", "", "_calculate_retry_after", "calculate_retry_after", False),
("litellm", "", "_turn_on_debug", "turn_on_debug", False),
("litellm", "", "_turn_on_json", "turn_on_json", False),
("litellm._lazy_imports", "", "_get_default_encoding", "get_default_encoding", False),
("litellm._lazy_imports", "", "_get_lazy_import_registry", "get_lazy_import_registry", False),
("litellm._lazy_imports", "", "_get_messages_reach_token_count", "get_messages_reach_token_count", False),
("litellm._lazy_imports", "", "_get_token_counter_new", "get_token_counter_new", False),
("litellm._logging", "", "_is_debugging_on", "is_debugging_on", False),
("litellm._logging", "", "_redact_string", "redact_string", False),
("litellm._logging", "", "_turn_on_debug", "turn_on_debug", False),
("litellm._logging", "", "_turn_on_json", "turn_on_json", False),
("litellm._redis", "", "_generate_gcp_iam_access_token", "generate_gcp_iam_access_token", False),
(
"litellm._redis_credential_provider",
"",
"_generate_gcp_iam_access_token",
"generate_gcp_iam_access_token",
False,
),
("litellm", "", "_should_retry", "should_retry", False),
("litellm.batches.batch_utils", "", "_count_entry_tokens", "count_entry_tokens", False),
("litellm.batches.batch_utils", "", "_estimate_batch_entry_tokens", "estimate_batch_entry_tokens", False),
("litellm.batches.batch_utils", "", "_extract_file_access_credentials", "extract_file_access_credentials", False),
("litellm.batches.batch_utils", "", "_get_file_content_as_dictionary", "get_file_content_as_dictionary", False),
("litellm.batches.batch_utils", "", "_handle_completed_batch", "handle_completed_batch", False),
("litellm.batches.batch_utils", "", "_iter_batch_input_lines", "iter_batch_input_lines", False),
("litellm.caching.caching", "Cache", "_get_cache_logic", "get_cache_logic", False),
(
"litellm.caching.caching",
"Cache",
"_get_preset_cache_key_from_kwargs",
"get_preset_cache_key_from_kwargs",
False,
),
("litellm.caching.caching", "Cache", "_supports_async", "supports_async", False),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_add_streaming_response_to_cache",
"add_streaming_response_to_cache",
False,
),
("litellm.caching.caching_handler", "LLMCachingHandler", "_async_get_cache", "async_get_cache", False),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_combine_cached_embedding_response_with_api_result",
"combine_cached_embedding_response_with_api_result",
False,
),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_should_store_result_in_cache",
"should_store_result_in_cache",
False,
),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_sync_add_streaming_response_to_cache",
"sync_add_streaming_response_to_cache",
False,
),
("litellm.caching.caching_handler", "LLMCachingHandler", "_sync_get_cache", "sync_get_cache", False),
(
"litellm.completion_extras.litellm_responses_transformation.transformation",
"LiteLLMResponsesTransformationHandler",
"_map_reasoning_effort",
"map_reasoning_effort",
False,
),
("litellm.cost_calculator", "", "_infer_call_type", "infer_call_type", False),
("litellm.cost_calculator", "", "_select_model_name_for_cost_calc", "select_model_name_for_cost_calc", False),
(
"litellm.integrations.SlackAlerting.utils",
"",
"_add_langfuse_trace_id_to_alert",
"add_langfuse_trace_id_to_alert",
False,
),
(
"litellm.integrations.arize.arize_phoenix_prompt_manager",
"ArizePhoenixTemplateManager",
"_load_prompt_from_arize",
"load_prompt_from_arize",
False,
),
(
"litellm.integrations.bitbucket.bitbucket_prompt_manager",
"BitBucketTemplateManager",
"_load_prompt_from_bitbucket",
"load_prompt_from_bitbucket",
False,
),
(
"litellm.integrations.dotprompt",
"",
"_get_prompt_data_from_dotprompt_content",
"get_prompt_data_from_dotprompt_content",
False,
),
(
"litellm.integrations.dotprompt.prompt_manager",
"PromptManager",
"_parse_frontmatter",
"parse_frontmatter",
False,
),
("litellm.integrations.dynamodb", "DyanmoDBLogger", "_async_log_event", "async_log_event", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_build_filename", "build_filename", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_count_unique", "count_unique", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_database", "database", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_destination", "destination", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_serializer", "serializer", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_sum_column", "sum_column", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_transformer", "transformer", True),
(
"litellm.integrations.gitlab.gitlab_prompt_manager",
"GitLabTemplateManager",
"_id_to_repo_path",
"id_to_repo_path",
False,
),
(
"litellm.integrations.gitlab.gitlab_prompt_manager",
"GitLabTemplateManager",
"_load_prompt_from_gitlab",
"load_prompt_from_gitlab",
False,
),
(
"litellm.integrations.opentelemetry",
"",
"_build_metric_attribute_filter",
"build_metric_attribute_filter",
False,
),
(
"litellm.integrations.opentelemetry",
"",
"_resolve_metric_attribute_filter",
"resolve_metric_attribute_filter",
False,
),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_custom_by_sanitized_key",
"custom_by_sanitized_key",
True,
),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_sanitized_enum",
"sanitized_enum",
True,
),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_tag_labels", "tag_labels", True),
(
"litellm.integrations.prometheus_helpers",
"",
"_get_cached_end_user_id_for_cost_tracking",
"get_cached_end_user_id_for_cost_tracking",
False,
),
(
"litellm.integrations.weave.weave_otel",
"",
"_get_weave_authorization_header",
"get_weave_authorization_header",
False,
),
(
"litellm.litellm_core_utils.core_helpers",
"",
"_get_parent_otel_span_from_kwargs",
"get_parent_otel_span_from_kwargs",
False,
),
("litellm.litellm_core_utils.dd_tracing", "", "_should_use_dd_profiler", "should_use_dd_profiler", False),
(
"litellm.litellm_core_utils.exception_mapping_utils",
"",
"_add_key_name_and_team_to_alert",
"add_key_name_and_team_to_alert",
False,
),
(
"litellm.litellm_core_utils.get_litellm_params",
"",
"_get_base_model_from_litellm_call_metadata",
"get_base_model_from_litellm_call_metadata",
False,
),
(
"litellm.litellm_core_utils.get_llm_provider_logic",
"",
"_is_non_openai_azure_model",
"is_non_openai_azure_model",
False,
),
(
"litellm.litellm_core_utils.get_model_cost_map",
"GetModelCostMap",
"_get_backup_model_count",
"get_backup_model_count",
False,
),
(
"litellm.litellm_core_utils.health_check_helpers",
"HealthCheckHelpers",
"_update_model_params_with_health_check_tracking_information",
"update_model_params_with_health_check_tracking_information",
False,
),
(
"litellm.litellm_core_utils.health_check_utils",
"",
"_create_health_check_response",
"create_health_check_response",
False,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_defer_async_logging", "defer_async_logging", True),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_enqueue_deferred_logging",
"enqueue_deferred_logging",
True,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_get_trace_id", "get_trace_id", False),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_is_sync_litellm_request",
"is_sync_litellm_request",
False,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_llm_caching_handler", "llm_caching_handler", True),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_on_detached_stream_failure",
"on_detached_stream_failure",
True,
),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_response_cost_calculator",
"response_cost_calculator",
False,
),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_update_completion_start_time",
"update_completion_start_time",
False,
),
(
"litellm.litellm_core_utils.litellm_logging",
"StandardLoggingPayloadSetup",
"_get_request_tags",
"get_request_tags",
False,
),
("litellm.litellm_core_utils.litellm_logging", "", "_get_masked_values", "get_masked_values", False),
(
"litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking",
"StandardBuiltInToolCostTracking",
"_get_file_search_tool_call",
"get_file_search_tool_call",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking",
"StandardBuiltInToolCostTracking",
"_get_web_search_options",
"get_web_search_options",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"CostCalculatorUtils",
"_call_type_has_image_response",
"call_type_has_image_response",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_generic_cost_per_character",
"generic_cost_per_character",
False,
),
("litellm.litellm_core_utils.llm_cost_calc.utils", "", "_get_cost_per_unit", "get_cost_per_unit", False),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_get_regional_uplift_multiplier",
"get_regional_uplift_multiplier",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_get_service_tier_cost_key",
"get_service_tier_cost_key",
False,
),
("litellm.litellm_core_utils.llm_cost_calc.utils", "", "_is_above_128k", "is_above_128k", False),
(
"litellm.litellm_core_utils.llm_request_utils",
"",
"_ensure_extra_body_is_safe",
"ensure_extra_body_is_safe",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_handle_invalid_parallel_tool_calls",
"handle_invalid_parallel_tool_calls",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_safe_convert_created_field",
"safe_convert_created_field",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_should_convert_tool_call_to_json_mode",
"should_convert_tool_call_to_json_mode",
False,
),
(
"litellm.litellm_core_utils.logging_callback_manager",
"LoggingCallbackManager",
"_add_custom_callback_generic_api_str",
"add_custom_callback_generic_api_str",
False,
),
(
"litellm.litellm_core_utils.logging_callback_manager",
"LoggingCallbackManager",
"_get_all_callbacks",
"get_all_callbacks",
False,
),
(
"litellm.litellm_core_utils.logging_utils",
"",
"_assemble_complete_response_from_streaming_chunks",
"assemble_complete_response_from_streaming_chunks",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_get_all_llm_api_params",
"get_all_llm_api_params",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_get_relevant_args_to_use_for_logging",
"get_relevant_args_to_use_for_logging",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_relevant_logging_args",
"relevant_logging_args",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_audio_or_image_in_message_content",
"audio_or_image_in_message_content",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_extract_reasoning_content",
"extract_reasoning_content",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_get_image_mime_type_from_url",
"get_image_mime_type_from_url",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_parse_content_for_reasoning",
"parse_content_for_reasoning",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"BedrockConverseMessagesProcessor",
"_process_file_message",
"process_file_message",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"BedrockImageProcessor",
"_validate_format",
"validate_format",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"",
"_encode_tool_call_id_with_signature",
"encode_tool_call_id_with_signature",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"",
"_get_thought_signature_from_tool",
"get_thought_signature_from_tool",
False,
),
("litellm.litellm_core_utils.prompt_templates.factory", "", "_parse_mime_type", "parse_mime_type", False),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_aget_chat_template_file",
"aget_chat_template_file",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_aget_tokenizer_config",
"aget_tokenizer_config",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_extract_token_value",
"extract_token_value",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_get_chat_template_file",
"get_chat_template_file",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_get_tokenizer_config",
"get_tokenizer_config",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_detect_beta_header",
"detect_beta_header",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_maybe_inject_guardrail_auto_response_disable",
"maybe_inject_guardrail_auto_response_disable",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_session_created_sent_to_client",
"session_created_sent_to_client",
True,
),
("litellm.litellm_core_utils.secret_redaction", "", "_python_redact_string", "python_redact_string", False),
(
"litellm.litellm_core_utils.secret_redaction",
"",
"_python_redact_structured_value",
"python_redact_structured_value",
False,
),
("litellm.litellm_core_utils.sensitive_data_masker", "SensitiveDataMasker", "_mask_value", "mask_value", False),
(
"litellm.litellm_core_utils.streaming_handler",
"CustomStreamWrapper",
"_strip_sse_data_from_chunk",
"strip_sse_data_from_chunk",
False,
),
(
"litellm.proxy.enterprise.litellm_enterprise.proxy.utils",
"",
"_should_block_robots",
"should_block_robots",
False,
),
("litellm.realtime_api.main", "", "_realtime_health_check", "realtime_health_check", False),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_tool_call_id_from_responses_item",
"tool_call_id_from_responses_item",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_chat_completion_annotations_to_response_output_annotations",
"transform_chat_completion_annotations_to_response_output_annotations",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_chat_completion_usage_to_responses_usage",
"transform_chat_completion_usage_to_responses_usage",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_tool_choice_for_responses_api_response",
"transform_tool_choice_for_responses_api_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_add_mcp_output_elements_to_response",
"add_mcp_output_elements_to_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_follow_up_input",
"create_follow_up_input",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_follow_up_messages_for_chat",
"create_follow_up_messages_for_chat",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_tool_execution_events",
"create_tool_execution_events",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_execute_tool_calls",
"execute_tool_calls",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_call_details",
"extract_tool_call_details",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_calls_from_chat_response",
"extract_tool_calls_from_chat_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_calls_from_response",
"extract_tool_calls_from_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_get_parent_request_tags",
"get_parent_request_tags",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_is_persistence_disabled",
"is_persistence_disabled",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_make_follow_up_call",
"make_follow_up_call",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_prepare_follow_up_call_params",
"prepare_follow_up_call_params",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_prepare_initial_call_params",
"prepare_initial_call_params",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_process_mcp_tools_to_openai_format",
"process_mcp_tools_to_openai_format",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_process_mcp_tools_without_openai_transform",
"process_mcp_tools_without_openai_transform",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_should_auto_execute_tools",
"should_auto_execute_tools",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_should_use_litellm_mcp_gateway",
"should_use_litellm_mcp_gateway",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_split_mcp_tools",
"split_mcp_tools",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_transform_mcp_tools_to_openai",
"transform_mcp_tools_to_openai",
False,
),
("litellm.responses.streaming_iterator", "", "_get_openai_response_types", "get_openai_response_types", False),
("litellm.responses.utils", "ResponseAPILoggingUtils", "_is_response_api_usage", "is_response_api_usage", False),
(
"litellm.responses.utils",
"ResponseAPILoggingUtils",
"_transform_response_api_usage_to_chat_usage",
"transform_response_api_usage_to_chat_usage",
False,
),
("litellm.responses.utils", "ResponsesAPIRequestUtils", "_build_container_id", "build_container_id", False),
("litellm.responses.utils", "ResponsesAPIRequestUtils", "_decode_container_id", "decode_container_id", False),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_decode_encrypted_item_id",
"decode_encrypted_item_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_decode_responses_api_response_id",
"decode_responses_api_response_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_encode_container_id_on_output_item",
"encode_container_id_on_output_item",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_encode_container_ids_in_annotations",
"encode_container_ids_in_annotations",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_restore_encrypted_content_item_ids_in_input",
"restore_encrypted_content_item_ids_in_input",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_unwrap_encrypted_content_with_model_id",
"unwrap_encrypted_content_with_model_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_update_responses_api_response_id_with_model_id",
"update_responses_api_response_id_with_model_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_wrap_encrypted_content_with_model_id",
"wrap_encrypted_content_with_model_id",
False,
),
("litellm.router", "Router", "_are_all_deployments_blocked", "are_all_deployments_blocked", False),
("litellm.router", "Router", "_deployment_usable_by_team", "deployment_usable_by_team", False),
("litellm.router", "Router", "_get_all_deployments", "get_all_deployments", False),
("litellm.router", "Router", "_get_model_from_alias", "get_model_from_alias", False),
(
"litellm.router",
"Router",
"_get_router_deployment_budget_limiter",
"get_router_deployment_budget_limiter",
False,
),
("litellm.router", "Router", "_is_deployment_blocked", "is_deployment_blocked", False),
(
"litellm.router",
"Router",
"_is_model_access_group_for_wildcard_route",
"is_model_access_group_for_wildcard_route",
False,
),
("litellm.router", "Router", "_replay_model_cost_registrations", "replay_model_cost_registrations", False),
("litellm.router", "Router", "_routing_groups", "routing_groups", True),
("litellm.router", "Router", "_update_redis_cache", "update_redis_cache", False),
(
"litellm.router_strategy.adaptive_router.adaptive_router",
"AdaptiveRouter",
"_state_loaded",
"state_loaded",
True,
),
(
"litellm.router_strategy.tag_based_routing",
"",
"_get_tags_from_request_kwargs",
"get_tags_from_request_kwargs",
False,
),
("litellm.router_utils.add_retry_fallback_headers", "HiddenParamsAsyncIteratorWrapper", "_inner", "inner", True),
("litellm.router_utils.add_retry_fallback_headers", "", "_HiddenParamsHost", "HiddenParamsHost", False),
(
"litellm.router_utils.batch_utils",
"",
"_get_router_metadata_variable_name",
"get_router_metadata_variable_name",
False,
),
("litellm.router_utils.common_utils", "", "_is_proxy_admin_request", "is_proxy_admin_request", False),
(
"litellm.router_utils.cooldown_callbacks",
"",
"_get_prometheus_logger_from_callbacks",
"get_prometheus_logger_from_callbacks",
False,
),
(
"litellm.router_utils.cooldown_handlers",
"",
"_async_get_cooldown_deployments",
"async_get_cooldown_deployments",
False,
),
(
"litellm.router_utils.cooldown_handlers",
"",
"_async_get_cooldown_deployments_with_debug_info",
"async_get_cooldown_deployments_with_debug_info",
False,
),
("litellm.router_utils.cooldown_handlers", "", "_get_cooldown_deployments", "get_cooldown_deployments", False),
("litellm.router_utils.cooldown_handlers", "", "_set_cooldown_deployments", "set_cooldown_deployments", False),
(
"litellm.router_utils.fallback_event_handlers",
"",
"_check_non_standard_fallback_format",
"check_non_standard_fallback_format",
False,
),
(
"litellm.router_utils.pattern_match_deployments",
"PatternMatchRouter",
"_pattern_to_regex",
"pattern_to_regex",
False,
),
("litellm.types.agents", "", "_normalize_a2a_jsonrpc_response", "normalize_a2a_jsonrpc_response", False),
("litellm.types.completion", "", "_CompletionDispatchContext", "CompletionDispatchContext", False),
(
"litellm.types.integrations.prometheus",
"",
"_sanitize_prometheus_label_name",
"sanitize_prometheus_label_name",
False,
),
(
"litellm.types.integrations.prometheus",
"",
"_sanitize_prometheus_label_value",
"sanitize_prometheus_label_value",
False,
),
("litellm.types.utils", "", "_generate_id", "generate_id", False),
("litellm.utils", "ProviderConfigManager", "_get_bedrock_mantle_config", "get_bedrock_mantle_config", False),
(
"litellm.utils",
"",
"_add_custom_logger_callback_to_specific_event",
"add_custom_logger_callback_to_specific_event",
False,
),
("litellm.utils", "", "_add_path_to_api_base", "add_path_to_api_base", False),
("litellm.utils", "", "_apply_openai_param_overrides", "apply_openai_param_overrides", False),
("litellm.utils", "", "_cached_get_model_info_helper", "cached_get_model_info_helper", False),
("litellm.utils", "", "_calculate_retry_after", "calculate_retry_after", False),
("litellm.utils", "", "_count_characters", "count_characters", False),
("litellm.utils", "", "_get_base_model_from_metadata", "get_base_model_from_metadata", False),
("litellm.utils", "", "_get_bundled_model_cost_map", "get_bundled_model_cost_map", False),
("litellm.utils", "", "_get_deployment_order", "get_deployment_order", False),
("litellm.utils", "", "_get_model_cost_key", "get_model_cost_key", False),
("litellm.utils", "", "_get_model_info_helper", "get_model_info_helper", False),
("litellm.utils", "", "_get_potential_model_names", "get_potential_model_names", False),
("litellm.utils", "", "_remove_additional_properties", "remove_additional_properties", False),
("litellm.utils", "", "_remove_json_schema_refs", "remove_json_schema_refs", False),
("litellm.utils", "", "_remove_strict_from_schema", "remove_strict_from_schema", False),
("litellm.utils", "", "_select_tokenizer", "select_tokenizer", False),
("litellm.utils", "", "_should_retry", "should_retry", False),
("litellm.utils", "", "_supports_factory", "supports_factory", False),
("litellm.utils", "", "_update_dictionary", "update_dictionary", False),
(
"litellm.vector_stores.vector_store_registry",
"VectorStoreIndexRegistry",
"_get_vector_store_indexes_from_db",
"get_vector_store_indexes_from_db",
False,
),
(
"litellm.vector_stores.vector_store_registry",
"VectorStoreRegistry",
"_get_vector_stores_from_db",
"get_vector_stores_from_db",
False,
),
)
PROPERTY_CASES: Final = (
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_database", "database"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_destination", "destination"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_serializer", "serializer"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_transformer", "transformer"),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_custom_by_sanitized_key",
"custom_by_sanitized_key",
),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_sanitized_enum", "sanitized_enum"),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_tag_labels", "tag_labels"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_defer_async_logging", "defer_async_logging"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_enqueue_deferred_logging", "enqueue_deferred_logging"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_llm_caching_handler", "llm_caching_handler"),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_on_detached_stream_failure",
"on_detached_stream_failure",
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_session_created_sent_to_client",
"session_created_sent_to_client",
),
("litellm.router", "Router", "_routing_groups", "routing_groups"),
("litellm.router_strategy.adaptive_router.adaptive_router", "AdaptiveRouter", "_state_loaded", "state_loaded"),
("litellm.router_utils.add_retry_fallback_headers", "HiddenParamsAsyncIteratorWrapper", "_inner", "inner"),
)
CLASS_PROPERTY_CASES: Final = ()
LLMS_ALIAS_CASES: Final = (
(
"litellm.llms.anthropic.pass_through.adapters.transformation",
"LiteLLMAnthropicMessagesAdapter",
"_translate_openai_usage_to_anthropic_usage",
"translate_openai_usage_to_anthropic_usage",
False,
),
(
"litellm.llms.anthropic.pass_through.adapters.transformation",
"LiteLLMAnthropicMessagesAdapter",
"_translate_openai_usage_to_anthropic_usage_delta",
"translate_openai_usage_to_anthropic_usage_delta",
False,
),
(
"litellm.llms.anthropic.pass_through.adapters.transformation",
"LiteLLMAnthropicMessagesAdapter",
"_translate_streaming_openai_chunk_to_anthropic_content_block",
"translate_streaming_openai_chunk_to_anthropic_content_block",
False,
),
(
"litellm.llms.anthropic.pass_through.context_management.dispatcher",
"",
"_normalize_spec",
"normalize_spec",
False,
),
(
"litellm.llms.anthropic.pass_through.messages.streaming_iterator",
"",
"_is_message_stop_chunk",
"is_message_stop_chunk",
False,
),
(
"litellm.llms.anthropic.pass_through.messages.streaming_iterator",
"",
"_is_provider_error_chunk",
"is_provider_error_chunk",
False,
),
(
"litellm.llms.anthropic.pass_through.messages.transformation",
"",
"_messages_carry_output_config",
"messages_carry_output_config",
False,
),
("litellm.llms.azure.azure", "", "_check_dynamic_azure_params", "check_dynamic_azure_params", False),
(
"litellm.llms.base_llm.base_utils",
"",
"_convert_tool_response_to_message",
"convert_tool_response_to_message",
False,
),
(
"litellm.llms.bedrock.batches.handler",
"BedrockBatchesHandler",
"_handle_async_invoke_status",
"handle_async_invoke_status",
False,
),
(
"litellm.llms.bedrock.batches.handler",
"BedrockBatchesHandler",
"_handle_model_invocation_job_status",
"handle_model_invocation_job_status",
False,
),
("litellm.llms.bedrock.common_utils", "", "_get_all_bedrock_regions", "get_all_bedrock_regions", False),
(
"litellm.llms.custom_httpx.aiohttp_transport",
"LiteLLMAiohttpTransport",
"_get_valid_client_session",
"get_valid_client_session",
False,
),
(
"litellm.llms.custom_httpx.http_handler",
"",
"_build_aiohttp_keepalive_socket_factory",
"build_aiohttp_keepalive_socket_factory",
False,
),
("litellm.llms.custom_httpx.http_handler", "", "_get_httpx_client", "get_httpx_client", False),
(
"litellm.llms.custom_httpx.http_handler",
"AsyncHTTPHandler",
"_create_aiohttp_transport",
"create_aiohttp_transport",
False,
),
(
"litellm.llms.custom_httpx.http_handler",
"AsyncHTTPHandler",
"_create_async_transport",
"create_async_transport",
False,
),
(
"litellm.llms.custom_httpx.http_handler",
"AsyncHTTPHandler",
"_create_httpx_proxy_mounts",
"create_httpx_proxy_mounts",
False,
),
(
"litellm.llms.custom_httpx.http_handler",
"AsyncHTTPHandler",
"_should_use_aiohttp_transport",
"should_use_aiohttp_transport",
False,
),
(
"litellm.llms.huggingface.common_utils",
"",
"_fetch_inference_provider_mapping",
"fetch_inference_provider_mapping",
False,
),
("litellm.llms.oci.chat.cohere", "", "_extract_text_content", "extract_text_content", False),
("litellm.llms.oci.chat.generic", "", "_normalize_oci_finish_reason", "normalize_oci_finish_reason", False),
("litellm.llms.oci.chat.generic", "", "_synthesize_oci_tool_call_id", "synthesize_oci_tool_call_id", False),
("litellm.llms.ollama.common_utils", "", "_convert_image", "convert_image", False),
("litellm.llms.openai.chat.gpt_5_transformation", "", "_get_effort_level", "get_effort_level", False),
("litellm.llms.openai.completion.utils", "", "_transform_prompt", "transform_prompt", False),
(
"litellm.llms.openai.cost_calculation",
"",
"_video_output_cost_per_second",
"video_output_cost_per_second",
False,
),
(
"litellm.llms.openai.fine_tuning.handler",
"",
"_litellm_fine_tuning_job_from_response",
"litellm_fine_tuning_job_from_response",
False,
),
(
"litellm.llms.vertex_ai.batches.transformation",
"VertexAIBatchTransformation",
"_get_batch_id_from_vertex_ai_batch_response",
"get_batch_id_from_vertex_ai_batch_response",
False,
),
("litellm.llms.vertex_ai.common_utils", "", "_build_json_schema", "build_json_schema", False),
("litellm.llms.vertex_ai.common_utils", "", "_build_vertex_schema", "build_vertex_schema", False),
("litellm.llms.vertex_ai.common_utils", "", "_check_text_in_content", "check_text_in_content", False),
(
"litellm.llms.vertex_ai.common_utils",
"",
"_convert_vertex_datetime_to_openai_datetime",
"convert_vertex_datetime_to_openai_datetime",
False,
),
("litellm.llms.vertex_ai.common_utils", "", "_get_gemini_url", "get_gemini_url", False),
("litellm.llms.vertex_ai.common_utils", "", "_get_vertex_url", "get_vertex_url", False),
("litellm.llms.vertex_ai.gemini.transformation", "", "_camel_to_snake", "camel_to_snake", False),
(
"litellm.llms.vertex_ai.gemini.transformation",
"",
"_gemini_convert_messages_with_history",
"gemini_convert_messages_with_history",
False,
),
("litellm.llms.vertex_ai.gemini.transformation", "", "_snake_to_camel", "snake_to_camel", False),
(
"litellm.llms.vertex_ai.gemini.transformation",
"",
"_transform_request_body",
"transform_request_body",
False,
),
(
"litellm.llms.vertex_ai.gemini.transformation",
"",
"_transform_system_message",
"transform_system_message",
False,
),
(
"litellm.llms.vertex_ai.gemini_embeddings.batch_embed_content_transformation",
"",
"_is_file_reference",
"is_file_reference",
False,
),
(
"litellm.llms.vertex_ai.vertex_llm_base",
"",
"_graft_default_vertex_path",
"graft_default_vertex_path",
False,
),
("litellm.llms.watsonx.common_utils", "", "_generate_watsonx_token", "generate_watsonx_token", False),
("litellm.llms.watsonx.common_utils", "", "_get_api_params", "get_api_params", False),
)
LLMS_FORWARDER_CASES: Final = (
(
"litellm.llms.bedrock.chat.invoke_handler",
"AWSEventStreamDecoder",
"_chunk_parser",
"chunk_parser",
"instance",
False,
),
(
"litellm.llms.aiml.chat.transformation",
"AIMLChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_convert_tool_response_to_message",
"convert_tool_response_to_message",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_map_reasoning_effort",
"map_reasoning_effort",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_map_stop_sequences",
"map_stop_sequences",
"instance",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_map_tool_helper",
"map_tool_helper",
"instance",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_map_tools",
"map_tools",
"instance",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_maybe_drop_speed_param",
"maybe_drop_speed_param",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_model_supports_effort_param",
"model_supports_effort_param",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_raise_invalid_reasoning_effort",
"raise_invalid_reasoning_effort",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.chat.transformation",
"AnthropicConfig",
"_validate_effort_for_model",
"validate_effort_for_model",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.common_utils",
"AnthropicModelInfo",
"_apply_sampling_param",
"apply_sampling_param",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.common_utils",
"AnthropicModelInfo",
"_is_adaptive_thinking_model",
"is_adaptive_thinking_model",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.common_utils",
"AnthropicModelInfo",
"_supports_model_capability",
"supports_model_capability",
"staticmethod",
False,
),
(
"litellm.llms.anthropic.completion.transformation",
"AnthropicTextConfig",
"_is_anthropic_text_model",
"is_anthropic_text_model",
"staticmethod",
False,
),
(
"litellm.llms.azure.common_utils",
"BaseAzureLLM",
"_base_validate_azure_environment",
"base_validate_azure_environment",
"staticmethod",
False,
),
(
"litellm.llms.azure.common_utils",
"BaseAzureLLM",
"_get_base_azure_url",
"get_base_azure_url",
"staticmethod",
False,
),
(
"litellm.llms.azure.common_utils",
"BaseAzureLLM",
"_try_get_default_azure_credential_provider",
"try_get_default_azure_credential_provider",
"staticmethod",
False,
),
(
"litellm.llms.azure.realtime.handler",
"AzureOpenAIRealtime",
"_construct_url",
"construct_url",
"instance",
False,
),
(
"litellm.llms.azure_ai.agents.transformation",
"AzureAIAgentsConfig",
"_get_agent_id",
"get_agent_id",
"instance",
False,
),
(
"litellm.llms.azure_ai.chat.transformation",
"AzureAIStudioConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.azure_ai.embed.cohere_transformation",
"AzureAICohereConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.azure_ai.embed.cohere_transformation",
"AzureAICohereConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.base_llm.base_model_iterator",
"BaseModelResponseIterator",
"_string_to_dict_parser",
"string_to_dict_parser",
"staticmethod",
False,
),
(
"litellm.llms.base_llm.chat.transformation",
"BaseConfig",
"_add_tools_to_optional_params",
"add_tools_to_optional_params",
"instance",
False,
),
(
"litellm.llms.base_llm.passthrough.transformation",
"BasePassthroughConfig",
"_convert_raw_bytes_to_str_lines",
"convert_raw_bytes_to_str_lines",
"instance",
False,
),
(
"litellm.llms.bedrock.base_aws_llm",
"BaseAWSLLM",
"_get_aws_region_name",
"get_aws_region_name",
"instance",
False,
),
(
"litellm.llms.bedrock.base_aws_llm",
"BaseAWSLLM",
"_validate_aws_region_name",
"validate_aws_region_name",
"staticmethod",
False,
),
(
"litellm.llms.bedrock.batches.transformation",
"BedrockBatchesConfig",
"_parse_timestamps_and_status",
"parse_timestamps_and_status",
"instance",
False,
),
(
"litellm.llms.bedrock.chat.agentcore.transformation",
"AmazonAgentCoreConfig",
"_get_runtime_session_id",
"get_runtime_session_id",
"instance",
False,
),
(
"litellm.llms.bedrock.chat.agentcore.transformation",
"AmazonAgentCoreConfig",
"_get_runtime_user_id",
"get_runtime_user_id",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_nova_transformation",
"AmazonNovaEmbeddingConfig",
"_transform_async_invoke_response",
"transform_async_invoke_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_nova_transformation",
"AmazonNovaEmbeddingConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_nova_transformation",
"AmazonNovaEmbeddingConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_g1_transformation",
"AmazonTitanG1Config",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_g1_transformation",
"AmazonTitanG1Config",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_multimodal_transformation",
"AmazonTitanMultimodalEmbeddingG1Config",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_multimodal_transformation",
"AmazonTitanMultimodalEmbeddingG1Config",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_v2_transformation",
"AmazonTitanV2Config",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.amazon_titan_v2_transformation",
"AmazonTitanV2Config",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.cohere_transformation",
"BedrockCohereEmbeddingConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.embedding",
"BedrockEmbedding",
"_get_async_invoke_status",
"get_async_invoke_status",
"instance",
True,
),
(
"litellm.llms.bedrock.embed.twelvelabs_marengo_transformation",
"TwelveLabsMarengoEmbeddingConfig",
"_transform_async_invoke_response",
"transform_async_invoke_response",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.twelvelabs_marengo_transformation",
"TwelveLabsMarengoEmbeddingConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.embed.twelvelabs_marengo_transformation",
"TwelveLabsMarengoEmbeddingConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock.files.transformation",
"BedrockFilesConfig",
"_transform_openai_jsonl_content_to_bedrock_jsonl_content",
"transform_openai_jsonl_content_to_bedrock_jsonl_content",
"instance",
False,
),
(
"litellm.llms.bedrock.image_edit.amazon_nova_canvas_image_edit_transformation",
"BedrockAmazonNovaCanvasImageEditConfig",
"_is_nova_canvas_image_edit_model",
"is_nova_canvas_image_edit_model",
"classmethod",
False,
),
(
"litellm.llms.bedrock.image_edit.stability_transformation",
"BedrockStabilityImageEditConfig",
"_is_stability_edit_model",
"is_stability_edit_model",
"classmethod",
False,
),
(
"litellm.llms.bedrock.image_generation.amazon_nova_canvas_transformation",
"AmazonNovaCanvasConfig",
"_is_nova_model",
"is_nova_model",
"classmethod",
False,
),
(
"litellm.llms.bedrock.image_generation.amazon_stability3_transformation",
"AmazonStability3Config",
"_is_stability_3_model",
"is_stability_3_model",
"classmethod",
False,
),
(
"litellm.llms.bedrock.image_generation.amazon_titan_transformation",
"AmazonTitanImageGenerationConfig",
"_is_titan_model",
"is_titan_model",
"classmethod",
False,
),
(
"litellm.llms.bedrock.rerank.transformation",
"BedrockRerankConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.bedrock.rerank.transformation",
"BedrockRerankConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.bedrock_mantle.chat.transformation",
"BedrockMantleChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.chatgpt.chat.transformation",
"ChatGPTConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.clarifai.chat.transformation",
"ClarifaiConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.codestral.completion.transformation",
"CodestralTextCompletionConfig",
"_chunk_parser",
"chunk_parser",
"instance",
False,
),
(
"litellm.llms.cohere.embed.v1_transformation",
"CohereEmbeddingConfig",
"_populate_embedding_response",
"populate_embedding_response",
"instance",
False,
),
(
"litellm.llms.cohere.embed.v1_transformation",
"CohereEmbeddingConfig",
"_transform_request",
"transform_request",
"instance",
False,
),
(
"litellm.llms.cohere.embed.v1_transformation",
"CohereEmbeddingConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.custom_httpx.llm_http_handler",
"BaseLLMHTTPHandler",
"_handle_error",
"handle_error",
"instance",
False,
),
(
"litellm.llms.dashscope.chat.transformation",
"DashScopeChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.datarobot.chat.transformation",
"DataRobotConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.deepinfra.chat.transformation",
"DeepInfraConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.docker_model_runner.chat.transformation",
"DockerModelRunnerChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.featherless_ai.chat.transformation",
"FeatherlessAIConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.fireworks_ai.chat.transformation",
"FireworksAIConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.gemini.chat.transformation",
"GoogleAIStudioGeminiConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.github_copilot.chat.transformation",
"GithubCopilotConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.gradient_ai.chat.transformation",
"GradientAIConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.groq.chat.transformation",
"GroqChatConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.groq.chat.transformation",
"GroqChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.heroku.chat.transformation",
"HerokuChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.hosted_vllm.chat.transformation",
"HostedVLLMChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.hyperbolic.chat.transformation",
"HyperbolicChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.inception.chat.transformation",
"InceptionChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.jina_ai.embedding.transformation",
"JinaAIEmbeddingConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.lambda_ai.chat.transformation",
"LambdaAIChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.langflow.chat.transformation",
"LangFlowConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.langgraph.chat.transformation",
"LangGraphConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.lemonade.chat.transformation",
"LemonadeChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.litellm_proxy.chat.transformation",
"LiteLLMProxyChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.llamafile.chat.transformation",
"LlamafileChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.lm_studio.chat.transformation",
"LMStudioChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.mistral.chat.transformation",
"MistralConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.mistral.chat.transformation",
"MistralConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.modelscope.chat.transformation",
"ModelScopeChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.moonshot.chat.transformation",
"MoonshotChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.morph.chat.transformation",
"MorphChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.nscale.chat.transformation",
"NscaleConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.openai.chat.gpt_5_transformation",
"OpenAIGPT5Config",
"_supports_reasoning_effort_level",
"supports_reasoning_effort_level",
"classmethod",
False,
),
(
"litellm.llms.openai.chat.gpt_transformation",
"OpenAIGPTConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.openai.common_utils",
"BaseOpenAILLM",
"_get_async_http_client",
"get_async_http_client",
"staticmethod",
False,
),
(
"litellm.llms.openai.openai",
"OpenAIChatCompletion",
"_get_openai_client",
"get_openai_client",
"instance",
False,
),
(
"litellm.llms.openai.openai",
"OpenAIConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.openai.realtime.handler",
"OpenAIRealtime",
"_construct_url",
"construct_url",
"instance",
False,
),
(
"litellm.llms.openai_like.chat.transformation",
"OpenAILikeChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.openai_like.dynamic_config",
"JSONProviderConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.perplexity.chat.transformation",
"PerplexityChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.ragflow.chat.transformation",
"RAGFlowConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.snowflake.utils",
"SnowflakeBaseConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.soniox.audio_transcription.transformation",
"SonioxAudioTranscriptionConfig",
"_build_response_from_payload",
"build_response_from_payload",
"instance",
False,
),
(
"litellm.llms.together_ai.rerank.transformation",
"TogetherAIRerankConfig",
"_transform_response",
"transform_response",
"instance",
False,
),
(
"litellm.llms.v0.chat.transformation",
"V0ChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.vercel_ai_gateway.chat.transformation",
"VercelAIGatewayConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_calculate_usage",
"calculate_usage",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_calculate_web_search_requests",
"calculate_web_search_requests",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_check_finish_reason",
"check_finish_reason",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_check_prompt_level_content_filter",
"check_prompt_level_content_filter",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_drop_search_tools_mixed_with_functions",
"drop_search_tools_mixed_with_functions",
"classmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_forward_gemini_function_call_id",
"forward_gemini_function_call_id",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_is_gemini_3_or_newer",
"is_gemini_3_or_newer",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_is_model_gemini_spec_model",
"is_model_gemini_spec_model",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_map_audio_params",
"map_audio_params",
"instance",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_map_function",
"map_function",
"instance",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_map_web_search_options",
"map_web_search_options",
"instance",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_process_candidates",
"process_candidates",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_search_tool_keys",
"search_tool_keys",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_set_grounding_usage_counters",
"set_grounding_usage_counters",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_set_stream_metadata_on_response",
"set_stream_metadata_on_response",
"staticmethod",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_transform_google_generate_content_to_openai_model_response",
"transform_google_generate_content_to_openai_model_response",
"instance",
False,
),
(
"litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini",
"VertexGeminiConfig",
"_transform_messages",
"transform_messages",
"instance",
False,
),
(
"litellm.llms.vertex_ai.vertex_llm_base",
"VertexBase",
"_ensure_access_token",
"ensure_access_token",
"instance",
False,
),
(
"litellm.llms.vertex_ai.vertex_llm_base",
"VertexBase",
"_ensure_access_token_async",
"ensure_access_token_async",
"instance",
True,
),
(
"litellm.llms.vertex_ai.vertex_llm_base",
"VertexBase",
"_get_token_and_url",
"get_token_and_url",
"instance",
False,
),
(
"litellm.llms.watsonx.common_utils",
"IBMWatsonXMixin",
"_prepare_payload",
"prepare_payload",
"instance",
False,
),
(
"litellm.llms.xai.chat.transformation",
"XAIChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
(
"litellm.llms.xai.chat.transformation",
"XAIChatConfig",
"_normalize_openai_compatible_usage_totals",
"normalize_openai_compatible_usage_totals",
"staticmethod",
False,
),
(
"litellm.llms.xai.chat.transformation",
"XAIChatConfig",
"_supports_stop_reason",
"supports_stop_reason",
"instance",
False,
),
(
"litellm.llms.zai.chat.transformation",
"ZAIChatConfig",
"_get_openai_compatible_provider_info",
"get_openai_compatible_provider_info",
"instance",
False,
),
)
def _get_owner(module_path: str, owner_name: str) -> object:
module: Final = import_module(module_path or "litellm")
if module_path == "litellm.llms.openai_like.dynamic_config" and owner_name == "JSONProviderConfig":
provider_registry: Final = getattr(
import_module("litellm.llms.openai_like.json_loader"),
"JSONProviderRegistry",
)
provider: Final = provider_registry.get("publicai")
return getattr(module, "create_config_class")(provider)
return module if not owner_name else getattr(module, owner_name)
def _get_instance(owner: object, public_name: str) -> object:
if not isinstance(owner, type):
raise TypeError(f"expected a class owner, got {type(owner).__name__}")
instance: Final = object.__new__(owner)
setattr(instance, public_name, object())
return instance
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name", "use_instance"),
(*ALIAS_CASES, *LLMS_ALIAS_CASES),
)
def test_public_aliases(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
use_instance: bool,
) -> None:
resolved_owner: Final = _get_owner(module_path, owner_name)
alias_owner: Final = _get_instance(resolved_owner, new_name) if use_instance else resolved_owner
old_value, new_value = getattr(alias_owner, old_name), getattr(alias_owner, new_name)
if isinstance(old_value, MethodType) and isinstance(new_value, MethodType):
assert old_value.__func__ is new_value.__func__
else:
assert old_value is new_value
def _make_private_override(
descriptor: str,
is_async: bool,
result: object,
) -> object:
def recorded_args(args: tuple[object, ...]) -> tuple[object, ...]:
return args[1:] if descriptor in ("instance", "classmethod") else args
def sync_override(
*args: object, **kwargs: object
) -> tuple[object, tuple[object, ...], dict[str, object]]:
return result, recorded_args(args), kwargs
async def async_override(
*args: object, **kwargs: object
) -> tuple[object, tuple[object, ...], dict[str, object]]:
return result, recorded_args(args), kwargs
implementation: Final = async_override if is_async else sync_override
if descriptor == "classmethod":
return classmethod(implementation)
if descriptor == "staticmethod":
return staticmethod(implementation)
return implementation
def _abstract_method_placeholder(*args: object, **kwargs: object) -> None:
return None
def _forwarder_arguments(
method: Callable[..., object],
) -> tuple[tuple[object, ...], dict[str, object]]:
parameters: Final = tuple(inspect.signature(method).parameters.values())
positional: Final = tuple(
object()
for parameter in parameters
if parameter.kind
in (
inspect.Parameter.POSITIONAL_ONLY,
inspect.Parameter.POSITIONAL_OR_KEYWORD,
inspect.Parameter.VAR_POSITIONAL,
)
)
keyword_only: Final = {
parameter.name: object() for parameter in parameters if parameter.kind is inspect.Parameter.KEYWORD_ONLY
}
variadic_keyword: Final = {
f"forwarder_extra_{index}": object()
for index, parameter in enumerate(parameters)
if parameter.kind is inspect.Parameter.VAR_KEYWORD
}
return positional, {**keyword_only, **variadic_keyword}
@pytest.mark.asyncio
@pytest.mark.parametrize(
(
"module_path",
"owner_name",
"private_name",
"public_name",
"descriptor",
"is_async",
),
LLMS_FORWARDER_CASES,
)
async def test_public_forwarders_dispatch_to_private_subclass_override(
module_path: str,
owner_name: str,
private_name: str,
public_name: str,
descriptor: str,
is_async: bool,
) -> None:
owner: Final = _get_owner(module_path, owner_name)
if not isinstance(owner, type):
raise TypeError(f"expected a class owner, got {type(owner).__name__}")
expected: Final = object()
abstract_method_overrides: Final = {
name: _abstract_method_placeholder for name in getattr(owner, "__abstractmethods__", ())
}
subclass: Final = type(
f"{owner_name}PrivateOverride",
(owner,),
{**abstract_method_overrides, private_name: _make_private_override(descriptor, is_async, expected)},
)
instance: Final = object.__new__(subclass)
public_method: Final = cast(Callable[..., object], getattr(instance, public_name))
args, kwargs = _forwarder_arguments(public_method)
invocation: Final = public_method(*args, **kwargs)
if is_async:
assert inspect.isawaitable(invocation)
awaited: Final = await cast(Awaitable[object], invocation)
assert awaited == (expected, args, kwargs)
return
assert invocation == (expected, args, kwargs)
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name"),
PROPERTY_CASES,
)
def test_protected_data_properties_round_trip(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
) -> None:
owner: Final = _get_owner(module_path, owner_name)
if not isinstance(owner, type):
raise TypeError(f"expected a class owner, got {type(owner).__name__}")
instance: Final = object.__new__(owner)
first_value: Final = object()
second_value: Final = object()
setattr(instance, new_name, first_value)
assert getattr(instance, old_name) is first_value
setattr(instance, old_name, second_value)
assert getattr(instance, new_name) is second_value
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name"),
CLASS_PROPERTY_CASES,
)
def test_class_level_property_alias_round_trip(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
) -> None:
owner: Final = _get_owner(module_path, owner_name)
first_value: Final = object()
second_value: Final = object()
original_class_value: Final = getattr(owner, new_name)
try:
setattr(owner, old_name, first_value)
assert getattr(owner, new_name) is first_value
setattr(owner, new_name, second_value)
assert getattr(owner, old_name) is second_value
finally:
setattr(owner, new_name, original_class_value)