# Published Conversational Agent Cannot Connect to TTS API

**URL:** <https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032>\
**Category:** Google AI Studio\
**Tags:** ai-studio\
**Created:** [March 25, 2026, 7:24pm UTC](https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032 "2026-03-25T19:24:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Louis15](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/louis15/32/108892_2.png) [@Louis15](https://discuss.ai.google.dev/u/Louis15)\
**Post date:** [March 25, 2026, 7:24pm UTC](https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032/1 "2026-03-25T19:24:33Z")

</div>

I initially posted this as a comment but it probably warrants its own topic.

I have reproduced this multiple times now. Steps:

1. Build a simple conversational voice agent app.

2. Add a Gemini key in the Secrets panel.

3. Test in AI Studio (works).

4. Publish and test (doesn’t work - connection is never established or drops instantly).

Debugging with the AI itself suggests two issues:

1. A conflict between the Gemini SDK’s default WebSocket URL and the AI Studio proxy interceptor, which resulted in a double slash (//ws/) in the connection URL.

2. AI Studio does server-side string substitution on the fly, while Cloud Run just serves the raw compiled JS bundle containing the literal string “MY\_GEMINI\_API\_KEY”, where “MY\_GEMINI\_API\_KEY” is the name of the secret holding your gemini key.

It is relatively easy to get a workaround for issue 1 but all efforts to get the agent in AI studio to fix issue 2 have failed, consuming a lot of tokens in the process. It alternates between fixing the published app (and breaking it in Studio) and vice versa.

Some help or guidance on this from the AI Studio team would be appreciated. I have had to cancel some demos because of the issue. I had never previously published a voice agent so I don’t know if the issue is due to the latest updates, but the net effect of this issue is that a voice agent cannot be published successfully. If anyone has been able to do so recently, please advise.

---

<div class="post-metadata">

**Author:** ![UWSkier](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/uwskier/32/33319_2.png) [@UWSkier](https://discuss.ai.google.dev/u/UWSkier)\
**Post date:** [April 1, 2026, 9:57pm UTC](https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032/2 "2026-04-01T21:57:02Z")

</div>

+1 here. I can reproduce this at will by creating a new voice agent and attempting to publish. 404 errors in the CloudRun log and websocket errors to the same URL in the browser console.

---

<div class="post-metadata">

**Author:** ![Le\_Vuong](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/le_vuong/32/110834_2.png) [@Le\_Vuong](https://discuss.ai.google.dev/u/Le_Vuong)\
**Post date:** [April 2, 2026, 5:27am UTC](https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032/3 "2026-04-02T05:27:53Z")

</div>

+1 here as well. Same errors I reported at [Help! AI WS connection works in preview environment but doesn't work in deployed! - #2 by Louis15](https://discuss.ai.google.dev/t/help-ai-ws-connection-works-in-preview-environment-but-doesnt-work-in-deployed/137274/2) and it’s a widespread issue. After a while Gemini returns with a timed out connection as well.

---

<div class="post-metadata">

**Author:** ![Patrick\_Doyle](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/patrick_doyle/32/31941_2.png) [@Patrick\_Doyle](https://discuss.ai.google.dev/u/Patrick_Doyle)\
**Post date:** [April 15, 2026, 5:13pm UTC](https://discuss.ai.google.dev/t/published-conversational-agent-cannot-connect-to-tts-api/136032/4 "2026-04-15T17:13:36Z")

</div>

Experiencing same issues for voice agent. What is the solution?
