Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
f1dea17
fix(spend_logs): store litellm_call_id and match it in request_id loo…
mateo-berri Sep 1, 2026
b35a132
fix(spend-logs): require every ambiguous request_id match to be owned
mateo-berri Sep 1, 2026
c0adca7
fix(spend-logs): authorize request_id lookups over distinct owners, b…
mateo-berri Sep 1, 2026
5382f9b
fix: re-verify ownership on fetched spend log rows for id lookups
mateo-berri Sep 1, 2026
61cef45
fix: re-verify ownership on custom-logger payload branch for id lookups
mateo-berri Sep 1, 2026
8ccbd82
fix: authorize custom-logger spend payload against its own owner
mateo-berri Sep 1, 2026
d6f85ed
Merge branch 'litellm_internal_staging' of https://github.com/BerriAI…
mateo-berri Sep 2, 2026
808fac0
fix(spend-logs): scope non-admin id lookups to viewable rows so id co…
mateo-berri Sep 2, 2026
cbeef3b
fix(proxy): bound client x-litellm-call-id, open log deep links by ca…
mateo-berri Sep 2, 2026
0f628f7
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 2, 2026
a196a50
fix(spend_logs): resolve the caller's own row before cold storage and…
mateo-berri Sep 3, 2026
6d29773
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 3, 2026
0c2be34
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 3, 2026
b69351e
fix(spend_logs): owner-scope every non-admin UI request_id lookup
mateo-berri Sep 3, 2026
55853c1
Merge branch 'litellm_internal_staging' of https://github.com/BerriAI…
mateo-berri Sep 3, 2026
8608a03
Merge origin/litellm_internal_staging into litellm_spend_log_request_…
mateo-berri Sep 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "LiteLLM_SpendLogs" ADD COLUMN IF NOT EXISTS "litellm_call_id" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- CreateIndex (CONCURRENTLY)
--
-- Disclaimer:
-- - CREATE INDEX CONCURRENTLY cannot run inside a transaction. This migration must stay a
-- single statement so Prisma Migrate on PostgreSQL can apply it outside a transaction.
-- - Builds are slower and use more I/O than a blocking CREATE INDEX; if the build is
-- interrupted, Postgres may leave an INVALID index that must be dropped and recreated.
-- - Do not edit this file after it has been applied to any database: Prisma checksums
-- migrations; add a new migration instead.
-- - Requires PostgreSQL that supports CONCURRENTLY with IF NOT EXISTS (use a new migration
-- without IF NOT EXISTS if you must support older versions).
CREATE INDEX CONCURRENTLY IF NOT EXISTS "LiteLLM_SpendLogs_litellm_call_id_idx" ON "LiteLLM_SpendLogs"("litellm_call_id");
2 changes: 2 additions & 0 deletions litellm-proxy-extras/litellm_proxy_extras/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,14 @@ model LiteLLM_SpendLogs {
mcp_namespaced_tool_name String?
agent_id String?
proxy_server_request Json? @default("{}")
litellm_call_id String?
created_at DateTime @default(now()) @map("created_at")
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
@@index([startTime])
@@index([startTime, request_id])
@@index([end_user])
@@index([session_id])
@@index([litellm_call_id])
}

model LiteLLM_BudgetWindowSpend {
Expand Down
1 change: 1 addition & 0 deletions litellm/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
os.getenv("DEFAULT_MCP_SEMANTIC_FILTER_SIMILARITY_THRESHOLD", 0.3)
)
MAX_MCP_SEMANTIC_FILTER_TOOLS_HEADER_LENGTH: Final = int(os.getenv("MAX_MCP_SEMANTIC_FILTER_TOOLS_HEADER_LENGTH", 150))
MAX_LITELLM_CALL_ID_LENGTH: Final = 256

DEFAULT_AUTO_ROUTER_MAX_INPUT_CHARS: Final = 2000

Expand Down
1 change: 1 addition & 0 deletions litellm/proxy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,7 @@ class SpendLogsPayload(TypedDict):
session_id: str | None
request_duration_ms: int | None
status: Literal["success", "failure"]
litellm_call_id: ReadOnly[str | None]


class SpanAttributes(str, enum.Enum):
Expand Down
9 changes: 8 additions & 1 deletion litellm/proxy/common_request_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DEFAULT_MAX_RECURSE_DEPTH,
LITELLM_DETAILED_TIMING,
LITELLM_HTTP_STATUS_CLIENT_DISCONNECTED,
MAX_LITELLM_CALL_ID_LENGTH,
MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG,
NON_INFERENCE_CALL_TYPES,
RETURN_RAW_MODEL_NAME_METADATA_KEY,
Expand Down Expand Up @@ -209,6 +210,12 @@ def _withheld_provider_output(response: object) -> bool:
return getattr(response, "has_buffered_provider_output", False) is True


def resolve_litellm_call_id(client_call_id: str | None) -> str:
if client_call_id is not None and 0 < len(client_call_id) <= MAX_LITELLM_CALL_ID_LENGTH:
return client_call_id
return str(uuid.uuid4())


def _should_return_raw_model_name(request_data: dict[str, object]) -> bool:
return any(
isinstance(metadata, dict) and metadata.get(RETURN_RAW_MODEL_NAME_METADATA_KEY) is True
Expand Down Expand Up @@ -1922,7 +1929,7 @@ async def common_processing_pre_call_logic(
if alias_target is not None:
self.data["model"] = alias_target

self.data["litellm_call_id"] = request.headers.get("x-litellm-call-id", str(uuid.uuid4()))
self.data["litellm_call_id"] = resolve_litellm_call_id(request.headers.get("x-litellm-call-id"))
DDSpanTagger.tag_call_id(self.data.get("litellm_call_id"))
DDSpanTagger.tag_request(
user_api_key_dict=user_api_key_dict,
Expand Down
2 changes: 2 additions & 0 deletions litellm/proxy/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,14 @@ model LiteLLM_SpendLogs {
mcp_namespaced_tool_name String?
agent_id String?
proxy_server_request Json? @default("{}")
litellm_call_id String?
created_at DateTime @default(now()) @map("created_at")
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
@@index([startTime])
@@index([startTime, request_id])
@@index([end_user])
@@index([session_id])
@@index([litellm_call_id])
}

model LiteLLM_BudgetWindowSpend {
Expand Down
Loading
Loading