diff --git a/litellm/constants.py b/litellm/constants.py index 8409a161800..c44d2a13c7f 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -205,6 +205,7 @@ LITELLM_UI_ALLOW_HEADERS: Final = [ "x-litellm-guardrail-scan-id", "x-litellm-guardrail-scan-metadata", "x-litellm-cache-key", + "x-litellm-response-cost", ] # Gemini model-specific minimal thinking budget constants diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py index 41c4956dba6..e973e154c61 100644 --- a/tests/test_litellm/proxy/test_proxy_server.py +++ b/tests/test_litellm/proxy/test_proxy_server.py @@ -102,6 +102,13 @@ def test_cors_exposes_cache_key_header_to_browser_js(): assert "x-litellm-cache-key" in cors_middleware.kwargs["expose_headers"] +def test_cors_exposes_response_cost_header_to_browser_js(): + from fastapi.middleware.cors import CORSMiddleware + + cors_middleware = next(m for m in app.user_middleware if m.cls is CORSMiddleware) + assert "x-litellm-response-cost" in cors_middleware.kwargs["expose_headers"] + + def test_login_v2_returns_redirect_url_and_sets_cookie(monkeypatch): mock_login_result = {"user_id": "test-user"} mock_prisma_client = MagicMock() diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTestCard.tsx b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTestCard.tsx index 06b58a51da5..e406224408a 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTestCard.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTestCard.tsx @@ -91,7 +91,7 @@ const PromptCachingTestCard: React.FC = ({ Test prompt caching

- Sends two identical requests with a ~5k token system prompt and no cache_control of its own. If LiteLLM + Sends two identical requests with a ~9k token system prompt and no cache_control of its own. If LiteLLM injects the breakpoints, the first call writes the cache and the second reads it.