Get cost estimates for your Google Cloud workloads

Stay organized with collections Save and categorize content based on your preferences.

This page shows you how to get started with the Cost Estimation API, and includes examples of API requests for common cost scenarios.

You can use the Cost Estimation API to get an idea of the costs for hypothetical workloads. For example, if you want to budget for a new application, the API helps you estimate how much the infrastructure for the application might cost over time. You can also get an estimate that includes credits from a committed use discount (CUD).

If you have a negotiated pricing contract, you can estimate your costs with your negotiated prices.

Before you begin

  • To call the API, get an API key.
  • If you want to get estimates with your negotiated prices, you must have the billing.accounts.getPricing permission. If you're calling the API using a service account, the service account must have the permission.

    The following predefined roles have the billing.accounts.getPricing permission:

    • Billing Account Administrator
    • Billing Account Viewer
  • Optionally, enable discount sharing for your CUDs. If you don't enable discount sharing and your usage occurs in a project that isn't part of the commitment, your estimated costs and actual costs might differ significantly.

Understand the components of an estimate

When you're defining your workloads for a cost estimate, consider these factors:

  • Workload: Represents your use of a single Google Cloud product for the time frame of the estimate. For example, a workload might be An n2 Compute Engine virtual machine for 1 week.

    In your API request, you define a list of workloads in the workloads object.

  • Cost Scenario: A collection of workloads, representing the Google Cloud products that your application needs. For example, a cost scenario might be 5 n2 virtual machines and 4 Gibibytes (GiB) of Cloud Storage for one week.

    In your API request, you configure your cost scenario in the costScenario object, which includes your time frame and list of workloads.

  • Time frame: The duration that you want to estimate costs for. You can get estimates for durations between 1 hour and 10 years.

    In your API request, you define the time frame using the estimateDuration object.

  • Time segments: You can split your estimate into time segments, where your usage varies over a certain period of time. For example, you can request an estimate for a time frame of four weeks, during which you start with 5 VMs for a week, then increase to 8 VMs for two weeks, and reduce to 3 VMs for the final week.

    In your API request, you define time segments using the usageRateTimeline object, and setting the start of a segment using estimationTimeFrameOffset.

  • Usage: Represents the amount of usage during a time segment. For example, you might define a time segment of 5 days, during which you want to use 6 Gibibytes (GiB) in a Cloud Storage bucket.

    In your API request, you specify usage using the usage object. When you make your API request, if you provide an incorrect unit for usage, the error message includes the correct unit.

Limitations

  • The workloads that you can model using the API cannot perfectly mirror your real-world usage patterns. For example, you can model workloads that change hourly using the API, but Compute Engine usage is recorded at the microsecond level.

  • The estimates model usage that occurs in a single project. If you have committed use discounts (CUDs) and have enabled discount sharing across multiple projects, the fees and credits for the CUD are attributed across all projects that use the service. For example, if project A consumed $75 worth of usage and project B consumed $25, project A would be covered by up to 75% of available credit and project B would be covered by up to 25%.

    Learn about how your CUD credits are attributed.

  • If your usage occurs towards the end of a month, that usage might be recorded in the next invoice month.

  • The estimates don't include the cost of networking attached to the Compute Engine VMs in your cost scenario.

  • The estimates don't account for Sustained Use Discounts (SUDs).

  • The estimates don't account for credits on your account, such as promotional credits, or discounts from private offers on Cloud Marketplace.

  • The estimates don't account for future changes in pricing for Google Cloud products.

Example cost scenarios

The following examples show API calls for getting cost estimates. For detailed information on the request format, see the API reference.

In the API response, the net estimated costs are in the following objects:

  • segmentTotalCostEstimate: The estimated cost for a time segment.
  • workloadTotalCostEstimate: The estimated cost for a workload.

Estimate the cost of virtual machines at list price

The following API request gets the estimate for 5 custom n1 virtual machines (VMs), at list price, for 100 hours of usage.

In the request, usageRate indicates how many resources are part of the cost scenario.

POST https://cloudbilling.googleapis.com/v1beta:estimateCostScenario?key=BILLING_ACCOUNT_ID HTTP/1.1

Accept: application/json
Content-Type: application/json

{
  "costScenario": {
    "scenarioConfig": {
      "estimateDuration": "360000s"
    },
    "workloads": [
      {
        "name": "vm-example",
        "computeVmWorkload": {
          "instancesRunning": {
            "usageRateTimeline": {
              "usageRateTimelineEntries": [
                {
                  "usageRate": 5
                }
              ]
            }
          },
          "machineType": {
            "customMachineType": {
              "machineSeries": "n1",
              "virtualCpuCount": 4,
              "memorySizeGb": 4
            }
          },
          "region": "us-central1"
        }
      }
    ]
  }
}

The expected response is as follows:

Click to expand the example response.

{
  "costEstimationResult": {
    "segmentCostEstimates": [
      {
        "segmentStartTime": {
          "estimationTimeFrameOffset": "0s"
        },
        "workloadCostEstimates": [
          {
            "name": "vm-example",
            "skuCostEstimates": [
              {
                "sku": "services/6F81-5844-456A/skus/ACBC-6999-A1C4",
                "usageAmount": 2000,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "66",
                    "nanos": 348000000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "66",
                    "nanos": 348000000
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/51E2-59BD-7A6E",
                "usageAmount": 2000,
                "usageUnit": "GiBy.h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 892000000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 892000000
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "75",
                "nanos": 240000000
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "75",
                "nanos": 240000000
              }
            }
          }
        ],
        "segmentTotalCostEstimate": {
          "preCreditCostEstimate": {
            "currencyCode": "USD",
            "units": "75",
            "nanos": 240000000
          },
          "netCostEstimate": {
            "currencyCode": "USD",
            "units": "75",
            "nanos": 240000000
          }
        }
      }
    ],
    "skus": [
      {
        "sku": "services/6F81-5844-456A/skus/ACBC-6999-A1C4",
        "displayName": "Custom Instance Core running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 33174000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/51E2-59BD-7A6E",
        "displayName": "Custom Instance Ram running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 4446000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1
            }
          }
        ]
      }
    ],
    "currencyCode": "USD"
  }
}
  

Estimate the cost of Cloud Storage use at contract price

The following API request gets the estimate for 1 month of 500 GibiBytes (GiB) in asia-southeast2, at a contract price:

POST https://cloudbilling.googleapis.com/v1beta/billingAccounts/BILLING_ACCOUNT_ID:estimateCostScenario HTTP/1.1

Authorization: Bearer API_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "costScenario": {
    "workloads": [
      {
        "name": "storage-example",
        "cloudStorageWorkload": {
          "storageClass": "archive",
          "dataStored": {
            "usageRateTimeline": {
              "unit": "GiBy",
              "usageRateTimelineEntries": [
                {
                  "usageRate": 500
                }
              ]
            }
          },
          "region": {
            "name": "asia-southeast2"
          }
        }
      }
    ],
    "scenarioConfig": {
      "estimateDuration": "2628000s"
    }
  }
}

The expected response is as follows:

Click to expand the example response.

{
  "costEstimationResult": {
    "segmentCostEstimates": [
      {
        "segmentStartTime": {
          "estimationTimeFrameOffset": "0s"
        },
        "workloadCostEstimates": [
          {
            "name": "storage-example",
            "skuCostEstimates": [
              {
                "sku": "services/95FF-2EF5-5EA1/skus/62E5-3AA6-3149",
                "usageAmount": 493.15068493150687,
                "usageUnit": "GiBy.mo",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "1",
                    "nanos": 232876712
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "1",
                    "nanos": 232876712
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "1",
                "nanos": 232876712
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "1",
                "nanos": 232876712
              }
            }
          }
        ],
        "segmentTotalCostEstimate": {
          "preCreditCostEstimate": {
            "currencyCode": "USD",
            "units": "1",
            "nanos": 232876712
          },
          "netCostEstimate": {
            "currencyCode": "USD",
            "units": "1",
            "nanos": 232876712
          }
        }
      }
    ],
    "skus": [
      {
        "sku": "services/95FF-2EF5-5EA1/skus/62E5-3AA6-3149",
        "displayName": "Archive Storage Jakarta",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 2500000
                  }
                }
              ],
              "unit": "GiBy.mo",
              "unitCount": 1
            }
          }
        ]
      }
    ],
    "currencyCode": "USD"
  }
}
    

Estimate the cost of workloads that change over time

The following API request gets an estimate for 1 month of usage, with custom contract prices, for the following resources:

  • 7000 GiB of storage
  • 8 n2-standard-4 VMs
  • 3 additional n2-standard-4 VMs 14 days into the month
POST https://cloudbilling.googleapis.com/v1beta/billingAccounts/BILLING_ACCOUNT_ID:estimateCostScenario HTTP/1.1

Authorization: Bearer API_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "costScenario": {
    "workloads": [
      {
        "name": "combined-example-storage",
        "cloudStorageWorkload": {
          "region": {
            "name": "us-central1"
          },
          "storageClass": "archive",
          "dataStored": {
            "usageRateTimeline": {
              "unit": "GiBy",
              "usageRateTimelineEntries": [
                {
                  "usageRate": 7000
                }
              ]
            }
          }
        }
      },
      {
        "name": "combined-example-compute",
        "computeVmWorkload": {
          "machineType": {
            "predefinedMachineType": {
              "machineType": "n2-standard-4"
            }
          },
          "region": "us-central1",
          "instancesRunning": {
            "usageRateTimeline": {
              "usageRateTimelineEntries": [
                {
                  "usageRate": 8
                },
                {
                  "usageRate": 11,
                  "effectiveTime": {
                    "estimationTimeFrameOffset": "1209600s"
                  }
                }
              ]
            }
          }
        }
      }
    ],
    "scenarioConfig": {
      "estimateDuration": "2628000s"
    }
  }
}

This sample uses the estimationTimeFrameOffset field to determine when a new time segment starts. The number of VMs changes from 8 to 11 (usageRate) after 1209600 seconds (14 days), as shown in this snippet:

"usageRateTimeline": {
  "usageRateTimelineEntries": [
    {
      "usageRate": 8
    },
    {
      "usageRate": 11,
      "effectiveTime": {
        "estimationTimeFrameOffset": "1209600s"
      }
    }
  ]

Similarly, if you want to estimate the cost if your workload reduced to 3 VMs 20 days from the start of the time frame, you can add one more segment to usageRateTimelineEntries, shown in this example:

"usageRateTimeline": {
  "usageRateTimelineEntries": [
    {
      "usageRate": 8
    },
    {
      "usageRate": 11,
      "effectiveTime": {
        "estimationTimeFrameOffset": "1209600s"
      }
    }
    {
      "usageRate": 3,
      "effectiveTime": {
        "estimationTimeFrameOffset": "1728000s"
      }
    }
  ]

The expected response is as follows:

Click to expand the example response.

{
  "costEstimationResult": {
    "segmentCostEstimates": [
      {
        "segmentStartTime": {
          "estimationTimeFrameOffset": "0s"
        },
        "workloadCostEstimates": [
          {
            "name": "combined-example-storage",
            "skuCostEstimates": [
              {
                "sku": "services/95FF-2EF5-5EA1/skus/EC4B-C190-470D",
                "usageAmount": 6904.1095890410961,
                "usageUnit": "GiBy.mo",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 284931506
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 284931506
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "8",
                "nanos": 284931506
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "8",
                "nanos": 284931506
              }
            }
          },
          {
            "name": "combined-example-compute",
            "skuCostEstimates": [
              {
                "sku": "services/6F81-5844-456A/skus/BB77-5FDA-69D9",
                "usageAmount": 27648,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "873",
                    "nanos": 980928000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "873",
                    "nanos": 980928000
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/5B01-D157-A097",
                "usageAmount": 110592,
                "usageUnit": "GiBy.h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "468",
                    "nanos": 578304000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "468",
                    "nanos": 578304000
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "1342",
                "nanos": 559232000
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "1342",
                "nanos": 559232000
              }
            }
          }
        ],
        "segmentTotalCostEstimate": {
          "preCreditCostEstimate": {
            "currencyCode": "USD",
            "units": "1350",
            "nanos": 844163506
          },
          "netCostEstimate": {
            "currencyCode": "USD",
            "units": "1350",
            "nanos": 844163506
          }
        }
      }
    ],
    "skus": [
      {
        "sku": "services/95FF-2EF5-5EA1/skus/EC4B-C190-470D",
        "displayName": "Archive Storage Iowa",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 1200000
                  }
                }
              ],
              "unit": "GiBy.mo",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/BB77-5FDA-69D9",
        "displayName": "N2 Instance Core running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 31611000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/5B01-D157-A097",
        "displayName": "N2 Instance Ram running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 4237000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1
            }
          }
        ]
      }
    ],
    "currencyCode": "USD"
  }
}

  

Estimate the cost of workloads when you have a committed use discount (CUD)

The following example shows an API request for an a2-megagpu VM, with an NVIDIA Tesla A100 GPU and an Extreme persistent disk, for 5 hours (18,000 seconds), with contract pricing and a 1-year commitment.

POST https://cloudbilling.googleapis.com/v1beta/billingAccounts/BILLING_ACCOUNT_ID:estimateCostScenario HTTP/1.1

Authorization: Bearer API_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "costScenario": {
    "workloads": [{
      "computeVmWorkload": {
        "region": "us-central1",
        "machineType": {
          "predefinedMachineType": {
            "machineType": "a2-megagpu-16g"
          }
        },
        "guestAccelerator": {
          "acceleratorType": "nvidia-tesla-a100",
          "acceleratorCount": "1"
        },
        "persistentDisks": [{
          "diskType": "pd-extreme",
          "scope": "SCOPE_ZONAL",
          "diskSize": {
            "usageRateTimeline": {
              "unit": "GiBy",
              "usageRateTimelineEntries": [{
                "usageRate": 1000.0
              }]
            }
          },
          "provisionedIops": {
            "usageRateTimeline": {
              "usageRateTimelineEntries": [{
                "usageRate": 15000.0
              }]
            }
          }
        }],
        "instancesRunning": {
          "usageRateTimeline": {
            "usageRateTimelineEntries": [{
              "usageRate": 1.0
            }]
          }
        }
      }
    }],
    "commitments": [{
      "vmResourceBasedCud": {
        "region": "us-central1",
        "virtualCpuCount": "48",
        "memorySizeGb": 680.0,
        "plan": "TWELVE_MONTH",
        "machineSeries": "a2"
      }
    }],
    "scenarioConfig": {
      "estimateDuration": "18000s"
    }
  }
}

The expected response is as follows. The estimate for the savings from the CUD is in the commitmentCostEstimates object:

Click to expand the example response.

{
  "costEstimationResult": {
    "segmentCostEstimates": [
      {
        "segmentStartTime": {
          "estimationTimeFrameOffset": "0s"
        },
        "workloadCostEstimates": [
          {
            "name": "workload",
            "skuCostEstimates": [
              {
                "sku": "services/6F81-5844-456A/skus/2922-40C5-B19F",
                "usageAmount": 533.33333333333337,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "16",
                    "nanos": 859200000
                  },
                  "creditEstimates": [
                    {
                      "creditAmount": {
                        "currencyCode": "USD",
                        "units": "-8",
                        "nanos": -429600000
                      },
                      "creditType": "Committed Use Discount"
                    }
                  ],
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 429600000
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/2390-DCAF-DA38",
                "usageAmount": 7555.5555555555557,
                "usageUnit": "GiBy.h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "32",
                    "nanos": 12888888
                  },
                  "creditEstimates": [
                    {
                      "creditAmount": {
                        "currencyCode": "USD",
                        "units": "-7",
                        "nanos": -344133333
                      },
                      "creditType": "Committed Use Discount"
                    }
                  ],
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "24",
                    "nanos": 668755555
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/039F-D0DA-4055",
                "usageAmount": 5.5555555555555554,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "16",
                    "nanos": 299488888
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "16",
                    "nanos": 299488888
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/165B-942F-F345",
                "usageAmount": 7.6103500761035008,
                "usageUnit": "GiBy.mo",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "nanos": 951293759
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "nanos": 951293759
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/DCA4-F1BE-57C4",
                "usageAmount": 114.15525114155251,
                "usageUnit": "mo",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "7",
                    "nanos": 420091324
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "7",
                    "nanos": 420091324
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "73",
                "nanos": 542962859
              },
              "creditEstimates": [
                {
                  "creditAmount": {
                    "currencyCode": "USD",
                    "units": "-15",
                    "nanos": -773733333
                  },
                  "creditType": "Committed Use Discount"
                }
              ],
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "57",
                "nanos": 769229526
              }
            }
          }
        ],
        "segmentTotalCostEstimate": {
          "preCreditCostEstimate": {
            "currencyCode": "USD",
            "units": "83",
            "nanos": 479896191
          },
          "creditEstimates": [
            {
              "creditAmount": {
                "currencyCode": "USD",
                "units": "-15",
                "nanos": -773733333
              },
              "creditType": "Committed Use Discount"
            }
          ],
          "netCostEstimate": {
            "currencyCode": "USD",
            "units": "67",
            "nanos": 706162858
          }
        },
        "commitmentCostEstimates": [
          {
            "name": "test1",
            "skuCostEstimates": [
              {
                "sku": "services/6F81-5844-456A/skus/3A31-931E-6360",
                "usageAmount": 266.66666666666669,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "5",
                    "nanos": 310666666
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "5",
                    "nanos": 310666666
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/220C-35D0-70E0",
                "usageAmount": 1733.3333333333333,
                "usageUnit": "GiBy.h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "4",
                    "nanos": 626266666
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "4",
                    "nanos": 626266666
                  }
                }
              }
            ],
            "commitmentTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "9",
                "nanos": 936933332
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "9",
                "nanos": 936933332
              }
            }
          }
        ]
      }
    ],
    "skus": [
      {
        "sku": "services/6F81-5844-456A/skus/3A31-931E-6360",
        "displayName": "Commitment v1: A2 Cpu in Americas for 1 Year",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 19915000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/220C-35D0-70E0",
        "displayName": "Commitment v1: A2 Ram in Americas for 1 Year",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 2669000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/039F-D0DA-4055",
        "displayName": "Nvidia Tesla A100 GPU running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "units": "2",
                    "nanos": 933908000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/165B-942F-F345",
        "displayName": "Extreme PD Capacity",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 125000000
                  }
                }
              ],
              "unit": "GiBy.mo",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/DCA4-F1BE-57C4",
        "displayName": "Extreme PD IOPS",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 65000000
                  }
                }
              ],
              "unit": "mo",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/2922-40C5-B19F",
        "displayName": "A2 Instance Core running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 31611000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/2390-DCAF-DA38",
        "displayName": "A2 Instance Ram running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 4237000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1
            }
          }
        ]
      }
    ],
    "currencyCode": "USD"
  }
}
    

Estimate the cost of a VM with a premium license, at list price

The following example shows an API request for 5 custom n1 virtual machines with a premium license of Windows Server 2022 DC at list price, for 100 hours.

POST https://cloudbilling.googleapis.com/v1beta:estimateCostScenario?key=[YOUR_API_KEY] HTTP/1.1

Accept: application/json
Content-Type: application/json

{
  "costScenario": {
    "scenarioConfig": {
      "estimateDuration": "360000s"
    },
    "workloads": [
      {
        "name": "vm-example",
        "computeVmWorkload": {
          "instancesRunning": {
            "usageRateTimeline": {
              "usageRateTimelineEntries": [
                {
                  "usageRate": 5
                }
              ]
            }
          },
          "machineType": {
            "customMachineType": {
              "machineSeries": "n1",
              "virtualCpuCount": 4,
              "memorySizeGb": 4
            }
          },
          "region": "us-central1",
          "licenses": "projects/windows-cloud/global/licenses/windows-server-2022-dc"
        }
      }
    ]
  }
}

The expected response is as follows:

Click to expand the example response.

{
  "costEstimationResult": {
    "segmentCostEstimates": [
      {
        "segmentStartTime": {
          "estimationTimeFrameOffset": "0s"
        },
        "workloadCostEstimates": [
          {
            "name": "vm-example",
            "skuCostEstimates": [
              {
                "sku": "services/6F81-5844-456A/skus/ACBC-6999-A1C4",
                "usageAmount": 2000,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "66",
                    "nanos": 348000000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "66",
                    "nanos": 348000000
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/51E2-59BD-7A6E",
                "usageAmount": 2000,
                "usageUnit": "GiBy.h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 892000000
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "8",
                    "nanos": 892000000
                  }
                }
              },
              {
                "sku": "services/6F81-5844-456A/skus/92D2-8A8F-DF54",
                "usageAmount": 2000.0,
                "usageUnit": "h",
                "costEstimate": {
                  "preCreditCostEstimate": {
                    "currencyCode": "USD",
                    "units": "92"
                  },
                  "netCostEstimate": {
                    "currencyCode": "USD",
                    "units": "92"
                  }
                }
              }
            ],
            "workloadTotalCostEstimate": {
              "preCreditCostEstimate": {
                "currencyCode": "USD",
                "units": "167",
                "nanos": 240000000
              },
              "netCostEstimate": {
                "currencyCode": "USD",
                "units": "167",
                "nanos": 240000000
              }
            }
          }
        ],
        "segmentTotalCostEstimate": {
          "preCreditCostEstimate": {
            "currencyCode": "USD",
            "units": "167",
            "nanos": 240000000
          },
          "netCostEstimate": {
            "currencyCode": "USD",
            "units": "167",
            "nanos": 240000000
          }
        }
      }
    ],
    "skus": [
      {
        "sku": "services/6F81-5844-456A/skus/92D2-8A8F-DF54",
        "displayName": "Licensing Fee for Windows Server 2022 Datacenter Edition on VM",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 46000000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1.0
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/51E2-59BD-7A6E",
        "displayName": "Custom Instance Ram running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 4446000
                  }
                }
              ],
              "unit": "GiBy.h",
              "unitCount": 1
            }
          }
        ]
      },
      {
        "sku": "services/6F81-5844-456A/skus/ACBC-6999-A1C4",
        "displayName": "Custom Instance Core running in Americas",
        "prices": [
          {
            "priceType": "RATE",
            "rate": {
              "tiers": [
                {
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 33174000
                  }
                }
              ],
              "unit": "h",
              "unitCount": 1
            }
          }
        ]
      }
    ],
    "currencyCode": "USD"
  }
}