{"record":{"id":"f1f4ff8b9bfa0e59","repo":"BerriAI/litellm","slug":"spend-report-endpoint-you-must-be-a-litellm-enter","errorCode":null,"errorMessage":"/spend/report endpoint You must be a LiteLLM Enterprise user to use this feature. If you have a license please set `LITELLM_LICENSE` in your env. Get a 7 day trial key here: https://www.litellm.ai/enterprise#trial. \nPricing: https://www.litellm.ai/#pricing","messagePattern":"/spend/report endpoint You must be a LiteLLM Enterprise user to use this feature\\. If you have a license please set `LITELLM_LICENSE` in your env\\. Get a 7 day trial key here: https://www\\.litellm\\.ai/enterprise#trial\\. \nPricing: https://www\\.litellm\\.ai/#pricing","errorType":"exception","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"litellm/proxy/spend_tracking/spend_management_endpoints.py","lineNumber":1244,"sourceCode":"        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail={\"error\": \"Please provide start_date and end_date\"},\n        )\n\n    start_date_obj: Final = datetime.strptime(start_date, \"%Y-%m-%d\").replace(tzinfo=timezone.utc)\n    end_date_obj: Final = datetime.strptime(end_date, \"%Y-%m-%d\").replace(tzinfo=timezone.utc)\n\n    from litellm.proxy.proxy_server import premium_user, prisma_client\n\n    try:\n        if prisma_client is None:\n            raise Exception(\n                \"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys\"\n            )\n\n        if premium_user is not True:\n            verbose_proxy_logger.debug(\"accessing /spend/report but not a premium user\")\n            raise ValueError(\"/spend/report endpoint \" + CommonProxyErrors.not_premium_user.value)\n        db_response: Sequence[Mapping[str, object]] | None\n        if api_key is not None:\n            verbose_proxy_logger.debug(\"Getting /spend for api_key: [set=%s]\", api_key is not None)\n            if api_key.startswith(\"sk-\"):\n                api_key = hash_token(token=api_key)\n            sql_query = \"\"\"\n                WITH SpendByModelApiKey AS (\n                    SELECT\n                        sl.api_key,\n                        sl.model,\n                        SUM(sl.spend) AS model_cost,\n                        SUM(sl.prompt_tokens) AS model_input_tokens,\n                        SUM(sl.completion_tokens) AS model_output_tokens\n                    FROM\n                        \"LiteLLM_SpendLogs\" sl\n                    WHERE\n                        sl.\"startTime\" >= ($1::timestamptz AT TIME ZONE 'UTC')\n                        AND sl.\"startTime\" <  (($2::timestamptz + INTERVAL '1 day') AT TIME ZONE 'UTC')","sourceCodeStart":1226,"sourceCodeEnd":1262,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/spend_tracking/spend_management_endpoints.py#L1226-L1262","documentation":"Error \"/spend/report endpoint You must be a LiteLLM Enterprise user to use this feature. If you have a license please set `LITELLM_LICENSE` in your env. Get a 7 day trial key here: https://www.litellm.ai/enterprise#trial. \nPricing: https://www.litellm.ai/#pricing\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:1244 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set LITELLM_LICENSE to a valid Enterprise license key, or request a 7-day trial key from litellm.ai."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}