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-berri2c2f4bbfed76
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 48d41edffbd..60223265211 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
@@ -664,6 +664,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 48d41edffbd..60223265211 100644
--- a/litellm/proxy/schema.prisma
+++ b/litellm/proxy/schema.prisma
@@ -664,6 +664,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 48d41edffbd..60223265211 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -664,6 +664,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 c762183dec4..37e97f98e63 100644
--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts
+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts
@@ -26193,7 +26193,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