GPU Cloud Billing: From Usage Metering to Billing¶
Cloud providers building GPU or Neo Cloud services face a universal challenge: how to turn resource consumption into revenue with accuracy, automation, and operational efficiency. In our previous blog, we demonstrated how to programmatically retrieve usage data from Rafay’s Usage Metering APIs and generate structured CSVs for downstream processing in an external billing platform.
In this follow-up blog, we take the next step toward a complete billing workflow—automatically transforming usage into billable cost using SKU-specific pricing. With GPU clouds scaling faster than ever and enterprise AI workloads becoming increasingly dynamic, providers must ensure their billing engine is consistent, transparent, and tightly integrated with their platform. The enhancements described in this blog are designed exactly for that.
Why Cost Automation Matters for GPU Cloud Providers¶
When a customer launches a GPU VM, deploys a Slurm workload, or provisions an AI/ML environment, they expect metering and billing to just work. Fortunately, Rafay’s Usage Metering API gives providers a clean, structured view of usage—broken down by organization (i.e. tenant), profile (i.e. SKU), instance, and duration.
However, raw usage alone is not enough for billing teams. To generate invoices or chargeback reports, someone must:
- Map SKUs to hourly pricing
- Compute usage × rate
- Apply reserved/on-demand logic
- Layer in additional fees (storage, egress, warm pools, etc.)
- Export the results into a billing system
Most organizations build a billing pipeline for this, but without automation, billing becomes brittle and error-prone. Manually joining usage data with a price book slows invoicing cycles and creates room for discrepancies.
For organizations that do not have a billing platform, we have enhanced our original utility to now calculate costs automatically, producing a CSV that is immediately ready for billing ingestion.
About the Utility¶
Download¶
The ncp_metrics.py script is a Python utility that collects billing and usage metrics for compute and service instances from the Rafay Console API. It generates CSV reports containing detailed billing information including usage hours, billing rates, and calculated billing amounts for each instance.
What the Utility Does¶
-
Fetches Instance Usage Data Retrieves compute and service instance usage data for a specified time range
-
Retrieves Billing Information Looks up billing rates for each profile associated with instances
-
Calculates Billing Amounts Computes total billing amounts based on usage hours and billing rates
-
Generates CSV Reports Creates timestamped CSV files with all metrics
-
Sorts Output Produces a sorted version of the CSV file organized by organization name
Prerequisites¶
Python 3.x and required Python packages. Install required dependencies using the following command:
pip install requests
requests- For making HTTP API callscsv- For CSV file operations (built-in)datetime- For date/time operations (built-in)
Environment Variables¶
This exercise assumes that you have access to an instance of the Rafay Platform (i.e. Controller). Ensure that you have Org Admin level access to the Default Org so that you can use the API Keys to programmatically retrieve the usage metering data.
The utility requires the following environment variables to be set:
| Variable | Description | Example |
|---|---|---|
DAYS |
Number of days to look back for usage data | 30 |
RAFAY_DEFAULT_API_KEY |
Default API key for Rafay Console | your-api-key |
PARTNER_API_KEY |
Partner API key for profile billing lookups | your-partner-api-key |
RAFAY_CONSOLE_URL |
Rafay Console URL (without https://) | console.rafay.dev |
CURRENCY |
Currency code for billing calculations | USD, EUR, etc. |
Usage¶
Step 1: Set Environment Variables¶
export DAYS=30
export RAFAY_DEFAULT_API_KEY="your-default-api-key"
export PARTNER_API_KEY="your-partner-api-key"
export RAFAY_CONSOLE_URL="your_rafay_url"
export CURRENCY="USD"
Step 2: Run the Utility¶
python ncp_metrics.py
Step 3: Review Output Files¶
The utility generates two CSV files:
ncp-metrics-{timestamp}.csv: Raw metrics datancp-metrics-sorted-{timestamp}.csv: Sorted by organization name
Example filenames:
ncp-metrics-12092025-154146.csvncp-metrics-sorted-12092025-154146.csv
Example Output¶
Notice the billing rate and billing amount columns.
| Organization | Profile Type | Profile | Instance | Usage (h) | Status | Billing Rate | Billing Amount (EUR) |
|---|---|---|---|---|---|---|---|
| Coke | Compute | medium-gpu-vm | coke-2-gpu-vm | 238.00h | Running | EUR 2/h | 476 |
| Coke | Compute | small-vcluster | coke-small-vcluster-instance | 238.00h | Running | EUR 2/h | 476 |
| Coke | Service | small-vllm | small-inference-endpoint-user | 238.00h | Running | EUR 3/h | 714 |
| Coke | Service | small-vllm | coke-demo-inference-ep | 238.00h | Running | EUR 3/h | 714 |
Closing Thoughts¶
GPU cloud providers are moving rapidly toward usage-based economics for both infrastructure (GPU VMs, MIG slices, Slurm clusters) and AI services (model hosting, fine-tuning, inference endpoints). To operate at scale, they require automated, transparent billing workflows.
By enhancing the usage metering utility to include SKU-based cost calculation, we’ve taken a major step toward enabling frictionless billing integration for cloud and enterprise providers. The pipeline is modular, extensible, and easy to adapt to your pricing model.
-
Free Org
Sign up for a free Org if you want to try this yourself with our Get Started guides.
-
Live Demo
Schedule time with us to watch a demo in action.
