Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Inquiry Regarding Costs for Retrying Requests in Google Cloud Vision API

Dear Google Cloud Support,

I hope this message finds you well. I am currently using the Google Cloud Vision API and have a couple of questions regarding retries and billing

  1. I am utilizing google.api_core.retry.Retry to handle retries for my requests. Could you please clarify if retries incur additional costs, or if only the initial request is billed?
  2. If retries do indeed incur costs, I would like to track the number of requests made, including retries. Could you provide guidance on how to measure and track the total number of requests, including retries, to ensure accurate billing?

Thank you for your assistance. I look forward to your response.

Best regards,

Solved Solved
0 1 129
1 ACCEPTED SOLUTION

Hi @takeichi,

Welcome to Google Cloud Community!

When using the Google Cloud Vision API with retry mechanisms via google.api_core.retry.Retry, it is crucial to understand the implications on billing and how to effectively track retries.

For Billing and Retries:  

Retry Costs: Each request to the Google Cloud Vision API, including any retries, is billed individually. As a result, if a request fails and triggers a retry, the retry will be charged as a separate request. Google Cloud charges for every processed request, whether it is the initial attempt or a retry. For additional details, you can refer to this documentation.

For Tracking Requests:

  • Utilize the Google Cloud Console to monitor API usage. The "Billing" section provides detailed reports and charts about your API usage, which can assist in cost estimation. However, this may not offer a precise breakdown of retries.
  • Implement detailed logging in your application to monitor each request and its retries, including request ID, timestamps, and statuses. This will help with internal tracking and reporting. For logging best practices, check the Google Cloud Logging Documentation.
  • Use Google Cloud’s monitoring tools, such as Cloud Monitoring to set up custom metrics and alerts. You can create metrics based on logs to track API calls and retries. This may need some extra setup but gives you detailed information on API usage. 

Steps to Track Requests with Retries:

1. Implement Logging: Add logging to your application to track every API request, including retries. This should involve:

  • Logging the request ID, timestamp, and result of each request.
  • Tracking retry attempts using libraries or custom code.

2. Use Google Cloud Monitoring:

  • Set up Cloud Monitoring to keep an eye on your API usage. Create custom dashboards and alerts for important metrics.
  • Define metrics based on your logs or use existing ones. For example, you can create metrics to count API calls and retries.

3. Review Billing ReportsRegularly check your Google Cloud Billing Reports to make sure charges match your expectations. Detailed reports help analyze usage patterns and understand the cost of retries. For help with billing reports, see the Billing Reports Overview.

I hope the above information is helpful.

View solution in original post

1 REPLY 1

Hi @takeichi,

Welcome to Google Cloud Community!

When using the Google Cloud Vision API with retry mechanisms via google.api_core.retry.Retry, it is crucial to understand the implications on billing and how to effectively track retries.

For Billing and Retries:  

Retry Costs: Each request to the Google Cloud Vision API, including any retries, is billed individually. As a result, if a request fails and triggers a retry, the retry will be charged as a separate request. Google Cloud charges for every processed request, whether it is the initial attempt or a retry. For additional details, you can refer to this documentation.

For Tracking Requests:

  • Utilize the Google Cloud Console to monitor API usage. The "Billing" section provides detailed reports and charts about your API usage, which can assist in cost estimation. However, this may not offer a precise breakdown of retries.
  • Implement detailed logging in your application to monitor each request and its retries, including request ID, timestamps, and statuses. This will help with internal tracking and reporting. For logging best practices, check the Google Cloud Logging Documentation.
  • Use Google Cloud’s monitoring tools, such as Cloud Monitoring to set up custom metrics and alerts. You can create metrics based on logs to track API calls and retries. This may need some extra setup but gives you detailed information on API usage. 

Steps to Track Requests with Retries:

1. Implement Logging: Add logging to your application to track every API request, including retries. This should involve:

  • Logging the request ID, timestamp, and result of each request.
  • Tracking retry attempts using libraries or custom code.

2. Use Google Cloud Monitoring:

  • Set up Cloud Monitoring to keep an eye on your API usage. Create custom dashboards and alerts for important metrics.
  • Define metrics based on your logs or use existing ones. For example, you can create metrics to count API calls and retries.

3. Review Billing ReportsRegularly check your Google Cloud Billing Reports to make sure charges match your expectations. Detailed reports help analyze usage patterns and understand the cost of retries. For help with billing reports, see the Billing Reports Overview.

I hope the above information is helpful.