Implementation:BerriAI Litellm Lazy Imports Registry
| Attribute | Value |
|---|---|
| Sources | litellm/_lazy_imports_registry.py |
| Domains | Performance, Module Loading, Import System, Configuration |
| last_updated | 2026-02-15 16:00 GMT |
Overview
The Lazy Imports Registry is a pure-data module that declares every attribute eligible for lazy loading and maps each attribute name to the module path and symbol name from which it should be resolved.
Description
This module contains no executable logic; it is a configuration manifest consumed by litellm._lazy_imports. It provides two kinds of data structures per category:
- Name tuples -- tuples of attribute name strings (e.g.,
UTILS_NAMES,CACHING_NAMES,LLM_CONFIG_NAMES) that enumerate every lazy-loadable attribute in that category. - Import maps -- dictionaries (e.g.,
_UTILS_IMPORT_MAP,_LLM_CONFIGS_IMPORT_MAP) that map each attribute name to a(module_path, attr_name)tuple indicating where to find the actual implementation.
The module covers 14 categories of lazy-loadable attributes:
- COST_CALCULATOR_NAMES (3 items) -- cost calculation functions
- LITELLM_LOGGING_NAMES (2 items) -- logging classes
- UTILS_NAMES (36 items) -- core utility functions and response types
- TOKEN_COUNTER_NAMES (1 item) -- token counting
- LLM_CLIENT_CACHE_NAMES (2 items) -- client caching
- BEDROCK_TYPES_NAMES (1 item) -- AWS Bedrock types
- TYPES_UTILS_NAMES (9 items) -- common Pydantic types
- CACHING_NAMES (4 items) -- cache backends
- HTTP_HANDLER_NAMES (2 items) -- HTTP client singletons
- DOTPROMPT_NAMES (3 items) -- prompt management
- LLM_CONFIG_NAMES (190+ items) -- provider configuration classes
- TYPES_NAMES (8 items) -- type classes (guardrails, SSO, etc.)
- LLM_PROVIDER_LOGIC_NAMES (2 items) -- provider resolution
- UTILS_MODULE_NAMES (60+ items) -- attributes on
litellm.utils
The LLM_CONFIG_NAMES and _LLM_CONFIGS_IMPORT_MAP are the largest structures, covering every provider-specific configuration class (Anthropic, OpenAI, Bedrock, Vertex AI, Azure, and 100+ others) including backward-compatibility aliases.
Usage
This module is imported by litellm._lazy_imports at its module level. Developers adding a new provider configuration or lazily-loaded symbol must add entries to both the appropriate name tuple and the corresponding import map in this file.
Code Reference
Source Location
/litellm/_lazy_imports_registry.py (1405 lines)
Key Data Structures
| Name | Type | Description |
|---|---|---|
UTILS_NAMES |
tuple[str, ...] |
Names of utils functions/classes eligible for lazy loading |
LLM_CONFIG_NAMES |
tuple[str, ...] |
Names of all provider config classes (~190 entries) |
UTILS_MODULE_NAMES |
tuple[str, ...] |
Names of attributes on the litellm.utils module
|
_UTILS_IMPORT_MAP |
dict[str, tuple[str, str]] |
Maps utils attribute names to (module_path, attr_name)
|
_LLM_CONFIGS_IMPORT_MAP |
dict[str, tuple[str, str]] |
Maps provider config names to their module locations |
_UTILS_MODULE_IMPORT_MAP |
dict[str, tuple[str, str]] |
Maps utils module attribute names to their module locations |
_CACHING_IMPORT_MAP |
dict[str, tuple[str, str]] |
Maps cache class names to litellm.caching.caching
|
Import
# Internal use only -- imported by _lazy_imports.py
from litellm._lazy_imports_registry import (
UTILS_NAMES,
_UTILS_IMPORT_MAP,
LLM_CONFIG_NAMES,
_LLM_CONFIGS_IMPORT_MAP,
)
I/O Contract
This module exports only data (tuples and dictionaries). It has no callable functions.
Outputs
| Export | Type | Description |
|---|---|---|
| Name tuples | tuple[str, ...] |
Enumerations of lazy-loadable attribute names per category |
| Import maps | dict[str, tuple[str, str]] |
Lookup tables mapping attribute name to (module_path, attribute_name)
|
Usage Examples
# Checking what a config name resolves to
from litellm._lazy_imports_registry import _LLM_CONFIGS_IMPORT_MAP
module_path, attr_name = _LLM_CONFIGS_IMPORT_MAP["AnthropicConfig"]
# module_path = ".llms.anthropic.chat.transformation"
# attr_name = "AnthropicConfig"
# Backward-compatibility aliases point to different targets
module_path, attr_name = _LLM_CONFIGS_IMPORT_MAP["VertexAIConfig"]
# module_path = ".llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini"
# attr_name = "VertexGeminiConfig" (alias)
Related Pages
- BerriAI_Litellm_Lazy_Imports - the runtime engine that consumes this registry
- BerriAI_Litellm_Constants - constant values referenced by lazy-loaded modules