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]

[UI] Allow setting up CloudZero Usage through LiteLLM UI (#12923)

Ishaan Jaff3e529fae7f48
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 85792bdd09f..c7c5978536b 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -7533,6 +7533,53 @@
"cache_read_input_token_cost": 2.5e-08,
"supports_prompt_caching": true
},
+ "gemini/gemini-2.5-flash-lite": {
+ "max_tokens": 65535,
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65535,
+ "max_images_per_prompt": 3000,
+ "max_videos_per_prompt": 10,
+ "max_video_length": 1,
+ "max_audio_length_hours": 8.4,
+ "max_audio_per_prompt": 1,
+ "max_pdf_size_mb": 30,
+ "input_cost_per_audio_token": 5e-07,
+ "input_cost_per_token": 1e-07,
+ "output_cost_per_token": 4e-07,
+ "output_cost_per_reasoning_token": 4e-07,
+ "litellm_provider": "gemini",
+ "mode": "chat",
+ "rpm": 15,
+ "tpm": 250000,
+ "supports_reasoning": true,
+ "supports_system_messages": true,
+ "supports_function_calling": true,
+ "supports_vision": true,
+ "supports_response_schema": true,
+ "supports_audio_output": false,
+ "supports_tool_choice": true,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/completions",
+ "/v1/batch"
+ ],
+ "supported_modalities": [
+ "text",
+ "image",
+ "audio",
+ "video"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",
+ "supports_parallel_function_calling": true,
+ "supports_web_search": true,
+ "supports_url_context": true,
+ "supports_pdf_input": true,
+ "cache_read_input_token_cost": 2.5e-08,
+ "supports_prompt_caching": true
+ },
"gemini-2.5-flash-preview-05-20": {
"max_tokens": 65535,
"max_input_tokens": 1048576,
@@ -7667,6 +7714,51 @@
"cache_read_input_token_cost": 2.5e-08,
"supports_prompt_caching": true
},
+ "gemini-2.5-flash-lite": {
+ "max_tokens": 65535,
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65535,
+ "max_images_per_prompt": 3000,
+ "max_videos_per_prompt": 10,
+ "max_video_length": 1,
+ "max_audio_length_hours": 8.4,
+ "max_audio_per_prompt": 1,
+ "max_pdf_size_mb": 30,
+ "input_cost_per_audio_token": 5e-07,
+ "input_cost_per_token": 1e-07,
+ "output_cost_per_token": 4e-07,
+ "output_cost_per_reasoning_token": 4e-07,
+ "litellm_provider": "vertex_ai-language-models",
+ "mode": "chat",
+ "supports_reasoning": true,
+ "supports_system_messages": true,
+ "supports_function_calling": true,
+ "supports_vision": true,
+ "supports_response_schema": true,
+ "supports_audio_output": false,
+ "supports_tool_choice": true,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/completions",
+ "/v1/batch"
+ ],
+ "supported_modalities": [
+ "text",
+ "image",
+ "audio",
+ "video"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",
+ "supports_parallel_function_calling": true,
+ "supports_web_search": true,
+ "supports_url_context": true,
+ "supports_pdf_input": true,
+ "cache_read_input_token_cost": 2.5e-08,
+ "supports_prompt_caching": true
+ },
"gemini-2.0-flash": {
"max_tokens": 8192,
"max_input_tokens": 1048576,
diff --git a/litellm/proxy/spend_tracking/cloudzero_endpoints.py b/litellm/proxy/spend_tracking/cloudzero_endpoints.py
index ee6bd7d73a9..c9189cde1d3 100644
--- a/litellm/proxy/spend_tracking/cloudzero_endpoints.py
+++ b/litellm/proxy/spend_tracking/cloudzero_endpoints.py
@@ -3,17 +3,237 @@ import json
from fastapi import APIRouter, Depends, HTTPException
from litellm._logging import verbose_proxy_logger
+from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker
from litellm.proxy._types import CommonProxyErrors, LitellmUserRoles, UserAPIKeyAuth
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
+from litellm.proxy.common_utils.encrypt_decrypt_utils import (
+ decrypt_value_helper,
+ encrypt_value_helper,
+)
from litellm.types.proxy.cloudzero_endpoints import (
CloudZeroExportRequest,
CloudZeroExportResponse,
CloudZeroInitRequest,
CloudZeroInitResponse,
+ CloudZeroSettingsUpdate,
+ CloudZeroSettingsView,
)
router = APIRouter()
+
+# Initialize the sensitive data masker for API key masking
+_sensitive_masker = SensitiveDataMasker()
+
+
+async def _set_cloudzero_settings(api_key: str, connection_id: str, timezone: str):
+ """
+ Store CloudZero settings in the database with encrypted API key.
+
+ Args:
+ api_key: CloudZero API key to encrypt and store
+ connection_id: CloudZero connection ID
+ timezone: Timezone for date handling
+ """
+ from litellm.proxy.proxy_server import prisma_client
+
+ if prisma_client is None:
+ raise HTTPException(
+ status_code=500,
+ detail={"error": CommonProxyErrors.db_not_connected_error.value},
+ )
+
+ # Encrypt the API key before storing
+ encrypted_api_key = encrypt_value_helper(api_key)
+
+ cloudzero_settings = {
+ "api_key": encrypted_api_key,
+ "connection_id": connection_id,
+ "timezone": timezone,
+ }
+
+ await prisma_client.db.litellm_config.upsert(
+ where={"param_name": "cloudzero_settings"},
+ data={
+ "create": {
+ "param_name": "cloudzero_settings",
+ "param_value": json.dumps(cloudzero_settings),
+ },
+ "update": {"param_value": json.dumps(cloudzero_settings)},
+ },
+ )
+
+
+async def _get_cloudzero_settings():
+ """
+ Retrieve CloudZero settings from the database with decrypted API key.
+
+ Returns:
+ dict: CloudZero settings with decrypted API key
+ """
+ from litellm.proxy.proxy_server import prisma_client
+
+ if prisma_client is None:
+ raise HTTPException(
+ status_code=500,
+ detail={"error": CommonProxyErrors.db_not_connected_error.value},
+ )
+
+ cloudzero_config = await prisma_client.db.litellm_config.find_first(
+ where={"param_name": "cloudzero_settings"}
+ )
+
+ if not cloudzero_config or not cloudzero_config.param_value:
+ raise HTTPException(
+ status_code=400,
+ detail={"error": "CloudZero settings not configured. Please run /cloudzero/init first."}
+ )
+
+ settings = dict(cloudzero_config.param_value)
+
+ # Decrypt the API key
+ encrypted_api_key = settings.get("api_key")
+ if encrypted_api_key:
+ decrypted_api_key = decrypt_value_helper(encrypted_api_key, exception_type="error")
+ if decrypted_api_key is None:
+ raise HTTPException(
+ status_code=500,
+ detail={"error": "Failed to decrypt CloudZero API key. Check your salt key configuration."}
+ )
+ settings["api_key"] = decrypted_api_key
+
+ return settings
+
+
+ "/cloudzero/settings",
+ tags=["CloudZero"],
+ dependencies=[Depends(user_api_key_auth)],
+ response_model=CloudZeroSettingsView,
+)
+async def get_cloudzero_settings(
+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
+):
+ """
+ View current CloudZero settings.
+
+ Returns the current CloudZero configuration with the API key masked for security.
+ Only the first 4 and last 4 characters of the API key are shown.
+
+ Only admin users can view CloudZero settings.
+ """
+ # Validation
+ if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
+ raise HTTPException(
+ status_code=403,
+ detail={"error": CommonProxyErrors.not_allowed_access.value},
+ )
+
+ try:
+ # Get CloudZero settings using the accessor method
+ settings = await _get_cloudzero_settings()
+
+ # Use SensitiveDataMasker to mask the API key
+ masked_settings = _sensitive_masker.mask_dict(settings)
+
+ return CloudZeroSettingsView(
+ api_key_masked=masked_settings["api_key"],
+ connection_id=settings["connection_id"],
+ timezone=settings["timezone"],
+ status="configured"
+ )
+
+ except HTTPException as e:
+ if e.status_code == 400:
+ # Settings not configured
+ raise HTTPException(
+ status_code=404,
+ detail={"error": "CloudZero settings not configured"}
+ )
+ raise e
+ except Exception as e:
+ verbose_proxy_logger.error(f"Error retrieving CloudZero settings: {str(e)}")
+ raise HTTPException(
+ status_code=500,
+ detail={"error": f"Failed to retrieve CloudZero settings: {str(e)}"}
+ )
+
+
+ "/cloudzero/settings",
+ tags=["CloudZero"],
+ dependencies=[Depends(user_api_key_auth)],
+ response_model=CloudZeroInitResponse,
+)
+async def update_cloudzero_settings(
+ request: CloudZeroSettingsUpdate,
+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
+):
+ """
+ Update existing CloudZero settings.
+
+ Allows updating individual CloudZero configuration fields without requiring all fields.
+ Only provided fields will be updated; others will remain unchanged.
+
+ Parameters:
+ - api_key: (Optional) New CloudZero API key for authentication
+ - connection_id: (Optional) New CloudZero connection ID for data submission
+ - timezone: (Optional) New timezone for date handling
+
+ Only admin users can update CloudZero settings.
+ """
+ # Validation
+ if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
+ raise HTTPException(
+ status_code=403,
+ detail={"error": CommonProxyErrors.not_allowed_access.value},
+ )
+
+ # Check if at least one field is provided
+ if not any([request.api_key, request.connection_id, request.timezone]):
+ raise HTTPException(
+ status_code=400,
+ detail={"error": "At least one field must be provided for update"}
+ )
+
+ try:
+ # Get current settings
+ current_settings = await _get_cloudzero_settings()
+
+ # Update only provided fields
+ updated_api_key = request.api_key if request.api_key is not None else current_settings["api_key"]
+ updated_connection_id = request.connection_id if request.connection_id is not None else current_settings["connection_id"]
+ updated_timezone = request.timezone if request.timezone is not None else current_settings["timezone"]
+
+ # Store updated settings using the setter method with encryption
+ await _set_cloudzero_settings(
+ api_key=updated_api_key,
+ connection_id=updated_connection_id,
+ timezone=updated_timezone
+ )
+
+ verbose_proxy_logger.info("CloudZero settings updated successfully")
+
+ return CloudZeroInitResponse(
+ message="CloudZero settings updated successfully",
+ status="success"
+ )
+
+ except HTTPException as e:
+ if e.status_code == 400:
+ # Settings not configured yet
+ raise HTTPException(
+ status_code=404,
+ detail={"error": "CloudZero settings not found. Please initialize settings first using /cloudzero/init"}
+ )
+ raise e
+ except Exception as e:
+ verbose_proxy_logger.error(f"Error updating CloudZero settings: {str(e)}")
+ raise HTTPException(
+ status_code=500,
+ detail={"error": f"Failed to update CloudZero settings: {str(e)}"}
+ )
+
# Global variable to track if CloudZero background job has been initialized
_cloudzero_background_job_initialized = False
@@ -95,7 +315,6 @@ async def is_cloudzero_setup_in_db() -> bool:
verbose_proxy_logger.error(f"Error checking CloudZero status: {str(e)}")
return False
-
@router.post(
"/cloudzero/init",
tags=["CloudZero"],
@@ -119,15 +338,7 @@ async def init_cloudzero_settings(
Only admin users can configure CloudZero settings.
"""
- from litellm.proxy.proxy_server import prisma_client
-
# Validation
- if prisma_client is None:
- raise HTTPException(
- status_code=500,
- detail={"error": CommonProxyErrors.db_not_connected_error.value},
- )
-
if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
raise HTTPException(
status_code=403,
@@ -135,23 +346,11 @@ async def init_cloudzero_settings(
)
try:
- # Prepare CloudZero settings
- cloudzero_settings = {
- "api_key": request.api_key,
- "connection_id": request.connection_id,
- "timezone": request.timezone,
- }
-
- # Store in database
- await prisma_client.db.litellm_config.upsert(
- where={"param_name": "cloudzero_settings"},
- data={
- "create": {
- "param_name": "cloudzero_settings",
- "param_value": json.dumps(cloudzero_settings),
- },
- "update": {"param_value": json.dumps(cloudzero_settings)},
- },
+ # Store settings using the setter method with encryption
+ await _set_cloudzero_settings(
+ api_key=request.api_key,
+ connection_id=request.connection_id,
+ timezone=request.timezone
)
verbose_proxy_logger.info("CloudZero settings initialized successfully")
@@ -195,15 +394,7 @@ async def cloudzero_dry_run_export(
"""
from datetime import datetime
- from litellm.proxy.proxy_server import prisma_client
-
# Validation
- if prisma_client is None:
- raise HTTPException(
- status_code=500,
- detail={"error": CommonProxyErrors.db_not_connected_error.value},
- )
-
if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
raise HTTPException(
status_code=403,
@@ -254,17 +445,9 @@ async def cloudzero_export(
Only admin users can perform CloudZero exports.
"""
- from datetime import datetime
- from litellm.proxy.proxy_server import prisma_client
+ from datetime import datetime
- # Validation
- if prisma_client is None:
- raise HTTPException(
- status_code=500,
- detail={"error": CommonProxyErrors.db_not_connected_error.value},
- )
-
if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
raise HTTPException(
status_code=403,
@@ -272,18 +455,8 @@ async def cloudzero_export(
)
try:
- # Get CloudZero settings from database
- cloudzero_config = await prisma_client.db.litellm_config.find_first(
- where={"param_name": "cloudzero_settings"}
- )
-
- if not cloudzero_config or not cloudzero_config.param_value:
- raise HTTPException(
- status_code=400,
- detail={"error": "CloudZero settings not configured. Please run /cloudzero/init first."}
- )
-
- settings = dict(cloudzero_config.param_value)
+ # Get CloudZero settings using the accessor method with decryption
+ settings = await _get_cloudzero_settings()
# Import and initialize CloudZero logger with credentials
from litellm.integrations.cloudzero.cloudzero import CloudZeroLogger
diff --git a/litellm/types/proxy/cloudzero_endpoints.py b/litellm/types/proxy/cloudzero_endpoints.py
index 8ed535d60b3..f7f63233d4d 100644
--- a/litellm/types/proxy/cloudzero_endpoints.py
+++ b/litellm/types/proxy/cloudzero_endpoints.py
@@ -34,4 +34,21 @@ class CloudZeroExportResponse(BaseModel):
message: str
status: str
- records_exported: Optional[int] = None
\ No newline at end of file
+ records_exported: Optional[int] = None
+
+
+class CloudZeroSettingsView(BaseModel):
+ """Response model for viewing CloudZero settings with masked API key"""
+
+ api_key_masked: str = Field(..., description="Masked API key showing only first 4 and last 4 characters")
+ connection_id: str = Field(..., description="CloudZero connection ID for data submission")
+ timezone: str = Field(..., description="Timezone for date handling")
+ status: str = Field(..., description="Configuration status")
+
+
+class CloudZeroSettingsUpdate(BaseModel):
+ """Request model for updating CloudZero settings"""
+
+ api_key: Optional[str] = Field(None, description="New CloudZero API key for authentication")
+ connection_id: Optional[str] = Field(None, description="New CloudZero connection ID for data submission")
+ timezone: Optional[str] = Field(None, description="New timezone for date handling")
\ No newline at end of file
diff --git a/ui/litellm-dashboard/out/assets/logos/cloudzero.png b/ui/litellm-dashboard/out/assets/logos/cloudzero.png
new file mode 100644
index 00000000000..df209726b9d
Binary files /dev/null and b/ui/litellm-dashboard/out/assets/logos/cloudzero.png differ
diff --git a/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx b/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx
new file mode 100644
index 00000000000..a7b585e89e8
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx
@@ -0,0 +1,353 @@
+import React, { useState, useEffect } from "react";
+import {
+ Card,
+ Title,
+ Text,
+ Button,
+ Callout,
+ TextInput,
+} from "@tremor/react";
+import { Modal, Form, Input, message, Spin, Select } from "antd";
+
+interface CloudZeroExportModalProps {
+ isOpen: boolean;
+ onClose: () => void;
+ accessToken: string | null;
+}
+
+interface CloudZeroSettings {
+ api_key: string;
+ connection_id: string;
+}
+
+interface CloudZeroSettingsView {
+ api_key_masked: string;
+ connection_id: string;
+ status: string;
+}
+
+type ExportType = 'cloudzero' | 'csv';
+
+const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({
+ isOpen,
+ onClose,
+ accessToken,
+}) => {
+ const [form] = Form.useForm();
+ const [loading, setLoading] = useState(false);
+ const [existingSettings, setExistingSettings] = useState<CloudZeroSettingsView | null>(null);
+ const [settingsLoading, setSettingsLoading] = useState(false);
+ const [exportType, setExportType] = useState<ExportType>('cloudzero');
+ const [exportLoading, setExportLoading] = useState(false);
+
+ // Load existing settings when modal opens
+ useEffect(() => {
+ if (isOpen && accessToken) {
+ loadExistingSettings();
+ }
+ }, [isOpen, accessToken]);
+
+ const loadExistingSettings = async () => {
+ setSettingsLoading(true);
+ try {
+ const response = await fetch("/cloudzero/settings", {
+ method: "GET",
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ },
+ });
+
+ if (response.ok) {
+ const settings = await response.json();
+ setExistingSettings(settings);
+ // Pre-populate form with existing settings (except masked API key)
+ form.setFieldsValue({
+ connection_id: settings.connection_id,
+ });
+ } else if (response.status !== 404) {
+ // 404 means no settings configured yet, which is fine
+ const errorData = await response.json();
+ message.error(`Failed to load existing settings: ${errorData.error || 'Unknown error'}`);
+ }
+ } catch (error) {
+ console.error("Error loading CloudZero settings:", error);
+ message.error("Failed to load existing settings");
+ } finally {
+ setSettingsLoading(false);
+ }
+ };
+
+ const handleSaveCloudZeroSettings = async (values: CloudZeroSettings) => {
+ if (!accessToken) {
+ message.error("No access token available");
+ return;
+ }
+
+ setLoading(true);
+ try {
+ const endpoint = existingSettings ? "/cloudzero/settings" : "/cloudzero/init";
+ const method = existingSettings ? "PUT" : "POST";
+
+ // Add default timezone for backend compatibility
+ const payload = {
+ ...values,
+ timezone: "UTC"
+ };
+
+ const response = await fetch(endpoint, {
+ method,
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(payload),
+ });
+
+ const data = await response.json();
+
+ if (response.ok) {
+ message.success(data.message || "CloudZero settings saved successfully");
+ setExistingSettings({
+ api_key_masked: values.api_key.substring(0, 4) + "****" + values.api_key.slice(-4),
+ connection_id: values.connection_id,
+ status: "configured"
+ });
+ return true;
+ } else {
+ message.error(data.error || "Failed to save CloudZero settings");
+ return false;
+ }
+ } catch (error) {
+ console.error("Error saving CloudZero settings:", error);
+ message.error("Failed to save CloudZero settings");
+ return false;
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handleExportCloudZero = async () => {
+ if (!accessToken) {
+ message.error("No access token available");
+ return;
+ }
+
+ setExportLoading(true);
+ try {
+ const response = await fetch("/cloudzero/export", {
+ method: "POST",
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ limit: 100000,
+ operation: "replace_hourly"
+ }),
+ });
+
+ const data = await response.json();
+
+ if (response.ok) {
+ message.success(data.message || "Export to CloudZero completed successfully");
+ onClose();
+ } else {
+ message.error(data.error || "Failed to export to CloudZero");
+ }
+ } catch (error) {
+ console.error("Error exporting to CloudZero:", error);
+ message.error("Failed to export to CloudZero");
+ } finally {
+ setExportLoading(false);
+ }
+ };
+
+ const handleExportCSV = async () => {
+ setExportLoading(true);
+ try {
+ // TODO: Implement CSV export functionality
+ message.info("CSV export functionality coming soon!");
+ onClose();
+ } catch (error) {
+ console.error("Error exporting CSV:", error);
+ message.error("Failed to export CSV");
+ } finally {
+ setExportLoading(false);
+ }
+ };
+
+ const handleExport = async () => {
+ if (exportType === 'cloudzero') {
+ // Check if settings exist, if not save them first
+ if (!existingSettings) {
+ const values = await form.validateFields();
+ const success = await handleSaveCloudZeroSettings(values);
+ if (!success) return;
+ }
+ await handleExportCloudZero();
+ } else {
+ await handleExportCSV();
+ }
+ };
+
+ const handleModalClose = () => {
+ form.resetFields();
+ setExportType('cloudzero');
+ setExistingSettings(null);
+ onClose();
+ };
+
+ const exportOptions = [
+ {
+ value: 'cloudzero',
+ label: (
+ <div className="flex items-center gap-2">
+ <img
+ src="/cloudzero.png"
+ alt="CloudZero"
+ className="w-5 h-5"
+ onError={(e) => {
+ // Fallback to text if image fails to load
+ (e.target as HTMLImageElement).style.display = 'none';
+ }}
+ />
+ <span>Export to CloudZero</span>
+ </div>
+ ),
+ },
+ {
+ value: 'csv',
+ label: (
+ <div className="flex items-center gap-2">
+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
+ </svg>
+ <span>Export to CSV</span>
+ </div>
+ ),
+ },
+ ];
+
+ return (
+ <Modal
+ title="Export Data"
+ open={isOpen}
+ onCancel={handleModalClose}
+ footer={null}
+ width={600}
+ destroyOnClose
+ >
+ <div className="space-y-4">
+ {/* Export Type Selection */}
+ <div>
+ <Text className="font-medium mb-2 block">Export Destination</Text>
+ <Select
+ value={exportType}
+ onChange={setExportType}
+ options={exportOptions}
+ className="w-full"
+ size="large"
+ />
+ </div>
+
+ {/* CloudZero Configuration */}
+ {exportType === 'cloudzero' && (
+ <div>
+ {settingsLoading ? (
+ <div className="flex justify-center py-8">
+ <Spin size="large" />
+ </div>
+ ) : (
+ <>
+ {existingSettings && (
+ <Callout
+ title="Existing CloudZero Configuration"
+ icon={() => (
+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
+ </svg>
+ )}
+ color="green"
+ className="mb-4"
+ >
+ <Text>
+ API Key: {existingSettings.api_key_masked}<br/>
+ Connection ID: {existingSettings.connection_id}
+ </Text>
+ </Callout>
+ )}
+
+ {!existingSettings && (
+ <Form
+ form={form}
+ layout="vertical"
+ >
+ <Form.Item
+ label="CloudZero API Key"
+ name="api_key"
+ rules={[
+ { required: true, message: "Please enter your CloudZero API key" }
+ ]}
+ >
+ <TextInput
+ type="password"
+ placeholder="Enter your CloudZero API key"
+ />
+ </Form.Item>
+
+ <Form.Item
+ label="Connection ID"
+ name="connection_id"
+ rules={[
+ { required: true, message: "Please enter the CloudZero connection ID" }
+ ]}
+ >
+ <TextInput placeholder="Enter CloudZero connection ID" />
+ </Form.Item>
+ </Form>
+ )}
+ </>
+ )}
+ </div>
+ )}
+
+ {/* CSV Export Info */}
+ {exportType === 'csv' && (
+ <Callout
+ title="CSV Export"
+ icon={() => (
+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
+ </svg>
+ )}
+ color="blue"
+ >
+ <Text>
+ Export your usage data as a CSV file for analysis in spreadsheet applications.
+ </Text>
+ </Callout>
+ )}
+
+ {/* Action Buttons */}
+ <div className="flex justify-end space-x-2 pt-4">
+ <Button
+ variant="secondary"
+ onClick={handleModalClose}
+ >
+ Cancel
+ </Button>
+ <Button
+ onClick={handleExport}
+ loading={loading || exportLoading}
+ disabled={loading || exportLoading}
+ >
+ {exportType === 'cloudzero' ? 'Export to CloudZero' : 'Export CSV'}
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ );
+};
+
+export default CloudZeroExportModal;
\ No newline at end of file
diff --git a/ui/litellm-dashboard/src/components/new_usage.tsx b/ui/litellm-dashboard/src/components/new_usage.tsx
index 34b3523499c..9c1d388d097 100644
--- a/ui/litellm-dashboard/src/components/new_usage.tsx
+++ b/ui/litellm-dashboard/src/components/new_usage.tsx
@@ -29,6 +29,7 @@ import {
Subtitle,
DateRangePicker,
DateRangePickerValue,
+ Button,
} from "@tremor/react";
import UsageDatePicker from "./shared/usage_date_picker";
import { AreaChart } from "@tremor/react";
@@ -58,6 +59,7 @@ import { Team } from "./key_team_helpers/key_list";
import { EntityList } from "./entity_usage";
import { formatNumberWithCommas } from "@/utils/dataUtils";
import { valueFormatterSpend } from "./usage/utils/value_formatters";
+import CloudZeroExportModal from "./cloudzero_export_modal";
interface NewUsagePageProps {
accessToken: string | null;
@@ -87,6 +89,7 @@ const NewUsagePage: React.FC<NewUsagePageProps> = ({
const [allTags, setAllTags] = useState<EntityList[]>([]);
const [modelViewType, setModelViewType] = useState<'groups' | 'individual'>('groups');
+ const [isCloudZeroModalOpen, setIsCloudZeroModalOpen] = useState(false);
const getAllTags = async () => {
if (!accessToken) {
@@ -388,21 +391,45 @@ const NewUsagePage: React.FC<NewUsagePageProps> = ({
const mcpServerMetrics = processActivityData(userSpendData, "mcp_servers");
return (
- <div style={{ width: "100%" }} className="p-8">
- {all_admin_roles.includes(userRole || "") ? (
- <Text className="text-sm text-gray-500 mb-4">
- Note: If you see key/model-level inconsistencies between Global View
- and Team Usage, it&apos;s because the Global View was missing spend
- when user_id = null, prior to v1.71.2.{" "}
- <a
- href="https://github.com/BerriAI/litellm/issues/10876"
- className="text-blue-500 hover:text-blue-700 ml-1"
+ <div style={{ width: "100%" }} className="p-8 relative">
+ {/* Export Data Button - Positioned in top right corner */}
+ {all_admin_roles.includes(userRole || "") && (
+ <div className="absolute top-4 right-4 z-10">
+ <button
+ onClick={() => setIsCloudZeroModalOpen(true)}
+ className="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-full flex items-center gap-2 shadow-lg transition-colors duration-200 text-sm font-medium"
>
- Learn more here
- </a>
- .
- </Text>
- ) : null}
+ <svg
+ className="w-4 h-4"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ strokeWidth={2}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
+ />
+ </svg>
+ Export Data
+ <svg
+ className="w-3 h-3"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ strokeWidth={2}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M19 9l-7 7-7-7"
+ />
+ </svg>
+ </button>
+ </div>
+ )}
+
<TabGroup>
<TabList variant="solid" className="mt-1">
{all_admin_roles.includes(userRole || "") ? (
@@ -761,6 +788,13 @@ const NewUsagePage: React.FC<NewUsagePageProps> = ({
</TabPanel>
</TabPanels>
</TabGroup>
+
+ {/* CloudZero Export Modal */}
+ <CloudZeroExportModal
+ isOpen={isCloudZeroModalOpen}
+ onClose={() => setIsCloudZeroModalOpen(false)}
+ accessToken={accessToken}
+ />
</div>
);
};