# Do I get charged for generated tokens if client disconnects during a Vertex AI streaming response?

**URL:** <https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490>\
**Category:** Gemini API\
**Tags:** open-ai, vertexai\
**Created:** [June 18, 2025, 5:00am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490 "2025-06-18T05:00:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blue\_hope](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/blue_hope/32/38047_2.png) [@blue\_hope](https://discuss.ai.google.dev/u/blue_hope)\
**Post date:** [June 18, 2025, 5:00am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/1 "2025-06-18T05:00:13Z")

</div>

Hi, I’m using Vertex AI’s generative models (e.g., Gemini) with the streaming API in a production backend environment.

I wanted to clarify how billing works when a client disconnects **before the entire response is received**. Specifically:

- If the client initiates a request to the model (via streaming),
- But then disconnects midway (due to timeout, network error, or user cancellation),
- Will I still be charged for **all tokens that the model had already generated** , even if they were **not delivered** to the client?

From what I understand, OpenAI and other providers charge based on generated tokens regardless of whether they were actually received by the client. Does Vertex AI behave the same way?

Any clarification would be appreciated, especially for optimizing cost and error-handling strategies in production.  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Lalit\_Kumar](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/lalit_kumar/32/37058_2.png) [@Lalit\_Kumar](https://discuss.ai.google.dev/u/Lalit_Kumar)\
**Post date:** [June 18, 2025, 6:45am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/3 "2025-06-18T06:45:05Z")

</div>

Hello,

You will be charged for all tokens that the model had already generated. For detailed information you can refer to [Vertex AI pricing](https://cloud.google.com/vertex-ai/generative-ai/pricing).

---

<div class="post-metadata">

**Author:** ![blue\_hope](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/blue_hope/32/38047_2.png) [@blue\_hope](https://discuss.ai.google.dev/u/blue_hope)\
**Post date:** [June 25, 2025, 6:03am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/5 "2025-06-25T06:03:56Z")

</div>

Thanks.

I have another question.

In that case, for issues like Gemini accidentally outputting infinite newlines—as described in [https://discuss.ai.google.dev/t/random-endless-n-output-in-gemini-api-1-5-pro-responses/52757—will](https://discuss.ai.google.dev/t/random-endless-n-output-in-gemini-api-1-5-pro-responses/52757%E2%80%94will) we be billed for all the tokens, even if the client cuts off the stream?

---

<div class="post-metadata">

**Author:** ![Jun\_Yellow](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jun_yellow/32/52702_2.png) [@Jun\_Yellow](https://discuss.ai.google.dev/u/Jun_Yellow)\
**Post date:** [June 25, 2025, 9:35am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/6 "2025-06-25T09:35:11Z")

</div>

I also encountered the same issue, especially when the model outputs tables. It’s very prone to infinite loops, which then leads to maximum output consumption penalties—this is quite frustrating.

---

<div class="post-metadata">

**Author:** ![Lalit\_Kumar](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/lalit_kumar/32/37058_2.png) [@Lalit\_Kumar](https://discuss.ai.google.dev/u/Lalit_Kumar)\
**Post date:** [June 26, 2025, 8:48am UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/8 "2025-06-26T08:48:09Z")

</div>

Hello,

Could you please share your prompt and model detail where you are facing hallucination issues, so that we can try to recreate it and discuss it with our team internally?

---

<div class="post-metadata">

**Author:** ![system](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/system/32/1_2.png) [@system](https://discuss.ai.google.dev/u/system)\
**Post date:** [November 5, 2026, 6:24pm UTC](https://discuss.ai.google.dev/t/do-i-get-charged-for-generated-tokens-if-client-disconnects-during-a-vertex-ai-streaming-response/89490/10 "2026-11-05T18:24:23Z")

</div>

Closed on November 5, 2026, 6:24pm UTC

This thread was automatically closed 60 days after the last reply. If you are running into an issue, please create a new post.
