CloudZero Integration
LiteLLM provides an integration with CloudZero's AnyCost API, allowing you to export your LLM usage data to CloudZero for cost tracking analysis.
Overview
| Property | Details |
|---|---|
| Description | Export LiteLLM usage data to CloudZero AnyCost API for cost tracking and analysis |
| callback name | cloudzero |
| Supported Operations | • Automatic hourly data export • Manual data export • Dry run testing • Cost and token usage tracking |
| Data Format | CloudZero Billing Format (CBF) with proper resource tagging |
| Export Frequency | Hourly (configurable via CLOUDZERO_EXPORT_INTERVAL_MINUTES) |
Environment Variables
| Variable | Required | Description | Example |
|---|---|---|---|
CLOUDZERO_API_KEY | Yes | Your CloudZero API key | cz_api_xxxxxxxxxx |
CLOUDZERO_CONNECTION_ID | Yes | CloudZero connection ID for data submission | conn_xxxxxxxxxx |
CLOUDZERO_TIMEZONE | No | Timezone for date handling (default: UTC) | America/New_York |
CLOUDZERO_EXPORT_INTERVAL_MINUTES | No | Export frequency in minutes (default: 60) | 60 |
Setup
End to End Video Walkthrough
This video walks through the entire process of setting up LiteLLM with CloudZero integration and viewing LiteLLM exported usage data in CloudZero.
Step 1: Configure Environment Variables
Set your CloudZero credentials in your environment:
export CLOUDZERO_API_KEY="cz_api_xxxxxxxxxx"
export CLOUDZERO_CONNECTION_ID="conn_xxxxxxxxxx"
export CLOUDZERO_TIMEZONE="UTC" # Optional, defaults to UTC
Step 2: Enable CloudZero Integration
Add the CloudZero callback to your LiteLLM configuration YAML file:
model_list:
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: sk-xxxxxxx
litellm_settings:
callbacks: ["cloudzero"] # Enable CloudZero integration
Step 3: Start LiteLLM Proxy
Start your LiteLLM proxy with the configuration:
litellm --config /path/to/config.yaml
Setup on UI
1. Click "Settings"

2. Click "Logging & Alerts"

3. Click "CloudZero Cost Tracking"

4. Click "Add CloudZero Integration"

5. Enter your CloudZero API Key.

6. Enter your CloudZero Connection ID.

7. Click "Create"

8. Test your payload with "Run Dry Run Simulation"

10. Click "Export Data Now" to export to CLoudZero

Testing Your Setup
Dry Run Export
Call the dry run endpoint to test your CloudZero configuration without sending data to CloudZero. This endpoint will not send any data to CloudZero, but will return the data that would be exported.
curl -X POST "http://localhost:4000/cloudzero/dry-run" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
"limit": 10
}' | jq
Expected Response:
{
"message": "CloudZero dry run export completed successfully.",
"status": "success",
"dry_run_data": {
"usage_data": [...],
"cbf_data": [...],
"summary": {
"total_cost": 0.05,
"total_tokens": 1250,
"total_records": 10
}
}
}
Manual Export
Call the export endpoint to send data immediately to CloudZero. We suggest setting a small limit to test the export. This will only export the last 10 records to CloudZero. Note: Cloudzero can take up to 15 minutes to process the exported data.
curl -X POST "http://localhost:4000/cloudzero/export" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
"limit": 10
}' | jq
Expected Response:
{
"message": "CloudZero export completed successfully",
"status": "success"
}