Are failed or pending requests using OpenAI-compatible Gemini API endpoints billed?

Hi there,

I’m using Gemini via the OpenAI-compatible API endpoint:
https://generativelanguage.googleapis.com/v1beta/openai/...
with the openai Python client library.

I’d like to better understand the billing and failure behavior in this context:

  1. If a request fails (e.g., invalid prompt, rate limit, quota error), does it still incur cost or token usage?
  2. Are requests that hang or time out (i.e., pending) also billed?
  3. What are the typical failure cases I should account for (timeouts, 429s, malformed inputs)?
  4. Does Google provide billing visibility for these failed/pending calls when using the OpenAI-compatible endpoint?

I’m trying to prevent unnecessary charges and improve my retry/error-handling logic. If anyone has experience using Gemini this way (via openai library), your insights would be super helpful!

Thanks in advance!

Hi Ngyn_An,

Here’s what I know:

  1. Failed Requests: If a request fails due to an invalid prompt, rate limit, or quota error, it typically does not incur charges. However, if the request is successfully received and processed by the server (even if it fails during execution), it may still count towards your usage.

  2. Pending Requests: Requests that hang or time out due to network issues or server delays generally do not incur charges.

  3. Typical Failure Cases: Common failure scenarios include:

  • Invalid or malformed inputs
  • Rate limiting (HTTP 429)
  • Quota errors
  • Timeouts
  • Server errors (HTTP 500 series)
  1. Billing Visibility: Google provides billing visibility through the Google Cloud Console (https://console.cloud.google.com/), where you can monitor your usage and costs. However, detailed logs of failed or pending requests may not be explicitly listed.

Pro Tips:
To prevent unnecessary charges, consider implementing retry logic with exponential backoff and validating inputs before sending requests. Also, keep an eye on your usage in the Cloud Console to ensure you’re within your budget.

1 Like