I’m trying to integrate Gemini Live into my app, using https://github.com/google-gemini/live-api-web-console/ as a reference. In the starter repo, the API key is used directly, but in my app, I want to use the ephemeral token instead.
The problem is that the ephemeral token generated on the backend doesn’t work in the frontend. It gives the API key not valid error.
It does work if I connect directly from the backend.
I tried adding the v1alpha API version to the httpsOptions and removing conflicting config in the frontend, similar to what I saw in other forum threads, but it still doesn’t work.
Yes, I saw that thread and tried the same, but didn’t work.
Hi @Goutham_Subramanyam,
The core of the issue likely lies in a mismatch between how your backend generates the ephemeral token (especially regarding the v1alpha API version) and how your frontend attempts to use that token to establish a WebSocket connection with the Gemini Live API.
The error message “API key not valid” can sometimes be a generic indicator of a protocol or version mismatch rather than just an invalid key. Please check it.
- Backend (Python google.generativeai.client): Ensure your client initialization explicitly uses api_version=‘v1alpha’. Your backend screenshot shows this: api_version=‘v1alpha’. This looks correct.
- Frontend (WebSocket Connection): The frontend error message shows Attempting to connect to gemini-2.5-flash-native-audio-preview-09-2025. This endpoint might be implicitly tied to a specific API version. If your ephemeral token was generated for v1alpha but the frontend is trying to connect to a different version’s endpoint, it will likely fail. You need to ensure the WebSocket URL or connection parameters on the frontend are compatible with the v1alpha token.
Hope this helps resolve the issue.
@Goutham_Subramanyam did you solve the problem? I get the same problem with ephemeral token. Backend and Frontend use the same “api_version=‘v1alpha’” and the model gemini-2.5-flash-native-audio-preview-12-2025 or gemini-2.0-flash-exp.