Skip to content

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]

feat(proxy): add LiteLLM_BudgetWindowSpend table for per-window budget spend

ryan-crabbe-berrid28621685a6b
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260804162853_add_budget_window_spend_table/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260804162853_add_budget_window_spend_table/migration.sql
new file mode 100644
index 00000000000..45cc927a328
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260804162853_add_budget_window_spend_table/migration.sql
@@ -0,0 +1,13 @@
+-- CreateTable
+CREATE TABLE IF NOT EXISTS "LiteLLM_BudgetWindowSpend" (
+ "entity_type" TEXT NOT NULL,
+ "entity_id" TEXT NOT NULL,
+ "window_duration" TEXT NOT NULL,
+ "window_start" TIMESTAMP(3) NOT NULL,
+ "spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0,
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updated_at" TIMESTAMP(3) NOT NULL,
+
+ CONSTRAINT "LiteLLM_BudgetWindowSpend_pkey" PRIMARY KEY ("entity_type","entity_id","window_duration")
+);
+
diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
index 2bb850139a2..7818e3acd56 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
@@ -649,6 +649,18 @@ model LiteLLM_SpendLogs {
@@index([session_id])
}
+model LiteLLM_BudgetWindowSpend {
+ entity_type String
+ entity_id String
+ window_duration String
+ window_start DateTime
+ spend Float @default(0.0)
+ created_at DateTime @default(now())
+ updated_at DateTime @updatedAt
+
+ @@id([entity_type, entity_id, window_duration])
+}
+
// View spend, model, api_key per request
model LiteLLM_ErrorLogs {
request_id String @id @default(uuid())
diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prisma
index 2bb850139a2..7818e3acd56 100644
--- a/litellm/proxy/schema.prisma
+++ b/litellm/proxy/schema.prisma
@@ -649,6 +649,18 @@ model LiteLLM_SpendLogs {
@@index([session_id])
}
+model LiteLLM_BudgetWindowSpend {
+ entity_type String
+ entity_id String
+ window_duration String
+ window_start DateTime
+ spend Float @default(0.0)
+ created_at DateTime @default(now())
+ updated_at DateTime @updatedAt
+
+ @@id([entity_type, entity_id, window_duration])
+}
+
// View spend, model, api_key per request
model LiteLLM_ErrorLogs {
request_id String @id @default(uuid())
diff --git a/schema.prisma b/schema.prisma
index 2bb850139a2..7818e3acd56 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -649,6 +649,18 @@ model LiteLLM_SpendLogs {
@@index([session_id])
}
+model LiteLLM_BudgetWindowSpend {
+ entity_type String
+ entity_id String
+ window_duration String
+ window_start DateTime
+ spend Float @default(0.0)
+ created_at DateTime @default(now())
+ updated_at DateTime @updatedAt
+
+ @@id([entity_type, entity_id, window_duration])
+}
+
// View spend, model, api_key per request
model LiteLLM_ErrorLogs {
request_id String @id @default(uuid())
diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts
index 6c5319f0361..c1a85a297c9 100644
--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts
+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts
@@ -26073,7 +26073,7 @@ export interface components {
* @description Default role assigned to new users created
* @default internal_user_viewer
*/
- user_role: ("proxy_admin" | "proxy_admin_viewer" | "internal_user" | "internal_user_viewer") | null;
+ user_role: ("internal_user" | "internal_user_viewer" | "proxy_admin" | "proxy_admin_viewer") | null;
};
/**
* DefaultTeamSSOParams