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
[DB] Add index for session_id on LiteLLM_SpendLogs (#10727)
Ishaan Jaff3d8c3d7b961e
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20250510142544_add_session_id_index_spend_logs/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20250510142544_add_session_id_index_spend_logs/migration.sqlnew file mode 100644index 00000000000..eda055d6e56--- /dev/null+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20250510142544_add_session_id_index_spend_logs/migration.sql@@ -0,0 +1,3 @@+-- CreateIndex+CREATE INDEX "LiteLLM_SpendLogs_session_id_idx" ON "LiteLLM_SpendLogs"("session_id");+diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prismaindex 3c20b9a3cda..c2a8bd11d0b 100644--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma@@ -264,6 +264,7 @@ model LiteLLM_SpendLogs {proxy_server_request Json? @default("{}")@@index([startTime])@@index([end_user])+ @@index([session_id])}// View spend, model, api_key per request@@ -361,14 +362,14 @@ model LiteLLM_DailyUserSpend {model Stringmodel_group String?custom_llm_provider String?- prompt_tokens Int @default(0)- completion_tokens Int @default(0)- cache_read_input_tokens Int @default(0)- cache_creation_input_tokens Int @default(0)+ prompt_tokens BigInt @default(0)+ completion_tokens BigInt @default(0)+ cache_read_input_tokens BigInt @default(0)+ cache_creation_input_tokens BigInt @default(0)spend Float @default(0.0)- api_requests Int @default(0)- successful_requests Int @default(0)- failed_requests Int @default(0)+ api_requests BigInt @default(0)+ successful_requests BigInt @default(0)+ failed_requests BigInt @default(0)created_at DateTime @default(now())updated_at DateTime @updatedAt@@ -388,14 +389,14 @@ model LiteLLM_DailyTeamSpend {model Stringmodel_group String?custom_llm_provider String?- prompt_tokens Int @default(0)- completion_tokens Int @default(0)- cache_read_input_tokens Int @default(0)- cache_creation_input_tokens Int @default(0)+ prompt_tokens BigInt @default(0)+ completion_tokens BigInt @default(0)+ cache_read_input_tokens BigInt @default(0)+ cache_creation_input_tokens BigInt @default(0)spend Float @default(0.0)- api_requests Int @default(0)- successful_requests Int @default(0)- failed_requests Int @default(0)+ api_requests BigInt @default(0)+ successful_requests BigInt @default(0)+ failed_requests BigInt @default(0)created_at DateTime @default(now())updated_at DateTime @updatedAt@@ -415,14 +416,14 @@ model LiteLLM_DailyTagSpend {model Stringmodel_group String?custom_llm_provider String?- prompt_tokens Int @default(0)- completion_tokens Int @default(0)- cache_read_input_tokens Int @default(0)- cache_creation_input_tokens Int @default(0)+ prompt_tokens BigInt @default(0)+ completion_tokens BigInt @default(0)+ cache_read_input_tokens BigInt @default(0)+ cache_creation_input_tokens BigInt @default(0)spend Float @default(0.0)- api_requests Int @default(0)- successful_requests Int @default(0)- failed_requests Int @default(0)+ api_requests BigInt @default(0)+ successful_requests BigInt @default(0)+ failed_requests BigInt @default(0)created_at DateTime @default(now())updated_at DateTime @updatedAtdiff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prismaindex b3016cc38bd..c2a8bd11d0b 100644--- a/litellm/proxy/schema.prisma+++ b/litellm/proxy/schema.prisma@@ -264,6 +264,7 @@ model LiteLLM_SpendLogs {proxy_server_request Json? @default("{}")@@index([startTime])@@index([end_user])+ @@index([session_id])}// View spend, model, api_key per requestdiff --git a/schema.prisma b/schema.prismaindex b3016cc38bd..c2a8bd11d0b 100644--- a/schema.prisma+++ b/schema.prisma@@ -264,6 +264,7 @@ model LiteLLM_SpendLogs {proxy_server_request Json? @default("{}")@@index([startTime])@@index([end_user])+ @@index([session_id])}// View spend, model, api_key per request