python-genai: Live API Error: ConnectionClosedError - "Invalid Frame Payload Data"
Description
The live API has stopped working since yesterday and now throws an error during use for "response_modalities" = ["TEXT"]. Previously, it was functioning without any issues.
Environment details
- Programming language: Python
- OS: Linux Mint 21.2 (but the issue happens on other operating systems as well)
- Language runtime version: Python 3.13.1
- Package version: google-genai 0.5.0
Steps to Reproduce
Use the file from this repository: gemini-2/live_api_starter.py.
- Add
GOOGLE_API_KEY. - Change
DEFAULT_MODE = "screen". - Update
CONFIG = {"generation_config": {"response_modalities": ["TEXT"]}}. - Run the file.
Enter the following commands:
- First, type: “What do you see on my screen?” (this works and returns a valid response).
- Then, type: “What do you see on my screen now?”.
- Observe the error.
Observed Behavior
The following error occurs during the second interaction:
ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
Traceback (most recent call last):
File "/projects/test/gemini_realtime_test.py", line 207, in receive_audio
async for response in turn:
...<4 lines>...
print(text, end="")
File "/.venv/lib/python3.13/site-packages/google/genai/live.py", line 129, in receive
while result := await self._receive():
^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/google/genai/live.py", line 197, in _receive
raw_response = await self._ws.recv(decode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/websockets/asyncio/connection.py", line 313, in recv
raise self.protocol.close_exc from self.recv_exc
websockets.exceptions.ConnectionClosedError: received 1007 (invalid frame payload data) Request trace id: d9d7aa6c895b1708, [ORIGINAL ERROR] generic::invalid_argument: Image tensors read from serialized content ; then sent 1007 (invalid frame payload data) Request trace id: d9d7aa6c895b1708, [ORIGINAL ERROR] generic::invalid_argument: Image tensors read from serialized content
Expected Behavior
The second question should also return a valid response without errors, as it did before yesterday.
Additional Information
Error Code: 1007 (invalid frame payload data) Request Trace ID: d9d7aa6c895b1708
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 17 (1 by maintainers)
Hey Guys I experimented same issue with this, tried a lot of different solutions and nothing, after that I figured it out stuff that this companies done, so it’s a country problem, this is available only for some counties, for that reason gives error, so I started a VPN connection to US and starting working without any issue, so, not model issue, not code issue, not 3rd party issue (my case livekit) it’s google stopping request outside the US or some others selected countries, as always complicating development life. USE VPN should solve the problem 😉
Is it possible that this regression has returned?
If I have response modality TEXT, I get an error 1007 for Invalid Frame Payload Data.
Without text modality it works.
@RichardSieg Yes, when this issue was originally created, they seemed to have fixed it for the latest model available then (ie,
gemini-2.0-flash-exp[as you can see the commentedL35here), but the underlying issue still persists for the latest/newer model(s).Has anyone been able to find a workaround for this? I am still facing this error.
(PS - PFA a minimal reproducible example)
Looking into it.