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
(feat) Track `custom_llm_provider` in LiteLLMSpendLogs (#7081)
Ishaan Jaffd4c52e292100
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex 6bb48bf8e60..ac235ca0d6a 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -1812,6 +1812,7 @@ class SpendLogsPayload(TypedDict):team_id: Optional[str]end_user: Optional[str]requester_ip_address: Optional[str]+ custom_llm_provider: Optional[str]class SpanAttributes(str, enum.Enum):diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prismaindex 64045999c95..183ac1b62a0 100644--- a/litellm/proxy/schema.prisma+++ b/litellm/proxy/schema.prisma@@ -191,6 +191,7 @@ model LiteLLM_SpendLogs {model String @default("")model_id String? @default("") // the model id stored in proxy model dbmodel_group String? @default("") // public model_name / model_group+ custom_llm_provider String? @default("") // litellm used custom_llm_providerapi_base String? @default("")user String? @default("")metadata Json? @default("{}")diff --git a/litellm/proxy/spend_tracking/spend_tracking_utils.py b/litellm/proxy/spend_tracking/spend_tracking_utils.pyindex 7cdb8fecc95..ca1e1d33e8b 100644--- a/litellm/proxy/spend_tracking/spend_tracking_utils.py+++ b/litellm/proxy/spend_tracking/spend_tracking_utils.py@@ -153,6 +153,7 @@ def get_logging_payload(model_group=_model_group,model_id=_model_id,requester_ip_address=clean_metadata.get("requester_ip_address", None),+ custom_llm_provider=kwargs.get("custom_llm_provider", ""),)verbose_proxy_logger.debug(diff --git a/schema.prisma b/schema.prismaindex 64045999c95..183ac1b62a0 100644--- a/schema.prisma+++ b/schema.prisma@@ -191,6 +191,7 @@ model LiteLLM_SpendLogs {model String @default("")model_id String? @default("") // the model id stored in proxy model dbmodel_group String? @default("") // public model_name / model_group+ custom_llm_provider String? @default("") // litellm used custom_llm_providerapi_base String? @default("")user String? @default("")metadata Json? @default("{}")diff --git a/tests/local_testing/test_spend_logs.py b/tests/logging_callback_tests/test_spend_logs.pysimilarity index 99%rename from tests/local_testing/test_spend_logs.pyrename to tests/logging_callback_tests/test_spend_logs.pyindex ff05173a5f0..62f3d6d7150 100644--- a/tests/local_testing/test_spend_logs.py+++ b/tests/logging_callback_tests/test_spend_logs.py@@ -45,6 +45,7 @@ def test_spend_logs_payload(model_id: Optional[str]):{"role": "system", "content": "you are a helpful assistant.\n"},{"role": "user", "content": "bom dia"},],+ "custom_llm_provider": "azure","optional_params": {"stream": False,"max_tokens": 10,@@ -211,6 +212,8 @@ def test_spend_logs_payload(model_id: Optional[str]):payload["request_tags"] == '["model-anthropic-claude-v2.1", "app-ishaan-prod"]')+ assert payload["custom_llm_provider"] == "azure"+def test_spend_logs_payload_whisper():"""