fix(proxy): keep the usage api_key cap local to common_daily_activity to avoid a module-level import cycle

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yassin 2026-09-14 23:15:57 +00:00
parent d6eac1f974
commit 733d6f1248
3 changed files with 4 additions and 6 deletions

View file

@ -65,10 +65,6 @@ DEFAULT_MAX_RETRIES: Final = int(os.getenv("DEFAULT_MAX_RETRIES", 2))
# Max records accepted in one POST /v1/callbacks/logs batch. Bounds the blast
# radius: each record fans out to spend logs + every callback integration.
MAX_CALLBACK_LOG_RECORDS: Final = 1000
# Top keys by spend that get per-key rows in the aggregated usage response.
# Six of its GROUPING SETS are keyed on api_key, so an uncapped result grows
# with every distinct key and the prisma query engine OOMs buffering it.
MAX_API_KEYS_IN_USAGE_BREAKDOWN: Final = 100
DEFAULT_MAX_RECURSE_DEPTH: Final = int(os.getenv("DEFAULT_MAX_RECURSE_DEPTH", 100))
DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKER = int(os.getenv("DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKER", 10))
DEFAULT_FAILURE_THRESHOLD_PERCENT: Final = float(

View file

@ -9,7 +9,7 @@ from fastapi import HTTPException, status
from typing_extensions import ReadOnly, TypedDict
from litellm._logging import verbose_proxy_logger
from litellm.constants import MAX_API_KEYS_IN_USAGE_BREAKDOWN, PTU_SENTINEL_API_KEY
from litellm.constants import PTU_SENTINEL_API_KEY
from litellm.proxy._types import CommonProxyErrors
from litellm.proxy.spend_tracking.key_metadata_recovery import (
attach_user_emails,
@ -52,6 +52,8 @@ _PRISMA_TO_PG_TABLE: Final[Mapping[str, str]] = {
"litellm_dailytagspend": "LiteLLM_DailyTagSpend",
}
MAX_API_KEYS_IN_USAGE_BREAKDOWN: Final = 100
class DailySpendRecord(Protocol):
@property

View file

@ -9,8 +9,8 @@ import pytest
from psycopg.rows import dict_row
from pytest_postgresql import factories
from litellm.constants import MAX_API_KEYS_IN_USAGE_BREAKDOWN
from litellm.proxy.management_endpoints.common_daily_activity import (
MAX_API_KEYS_IN_USAGE_BREAKDOWN,
_adjust_dates_for_timezone,
_build_aggregated_sql_query,
_build_entity_rollup_sql_query,