The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): look the entity spend table up lazily so only the selected batcher table is touched
mateo-berri51eaad657baf
diff --git a/litellm/proxy/db/db_spend_update_writer.py b/litellm/proxy/db/db_spend_update_writer.pyindex 5381071172f..d9c8b271646 100644--- a/litellm/proxy/db/db_spend_update_writer.py+++ b/litellm/proxy/db/db_spend_update_writer.py@@ -141,16 +141,18 @@ _EntitySpendTable: TypeAlias = Literal[]+_ENTITY_SPEND_TABLES: Final[Mapping[_EntitySpendTable, Callable[[_SpendBatch], BatchTable]]] = MappingProxyType(+ {+ "litellm_tagtable": lambda batcher: batcher.litellm_tagtable,+ "litellm_agentstable": lambda batcher: batcher.litellm_agentstable,+ "litellm_modelaccessgroupbudgettable": lambda batcher: batcher.litellm_modelaccessgroupbudgettable,+ "litellm_projecttable": lambda batcher: batcher.litellm_projecttable,+ }+)++def _entity_spend_table(batcher: _SpendBatch, table_accessor: _EntitySpendTable) -> BatchTable:- tables: Final[Mapping[_EntitySpendTable, BatchTable]] = MappingProxyType(- {- "litellm_tagtable": batcher.litellm_tagtable,- "litellm_agentstable": batcher.litellm_agentstable,- "litellm_modelaccessgroupbudgettable": batcher.litellm_modelaccessgroupbudgettable,- "litellm_projecttable": batcher.litellm_projecttable,- }- )- return tables[table_accessor]+ return _ENTITY_SPEND_TABLES[table_accessor](batcher)class _SpendBatchManager(Protocol):