-
Notifications
You must be signed in to change notification settings - Fork 813
Live API: response_modalities=[TEXT] causes 1011 Internal Error on gemini-3.1-flash-live-preview #2238
Copy link
Copy link
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: Python
- OS: Linux (Ubuntu)
- Language runtime version: 3.13.2
- Package version: 1.70.0
Description
When connecting to gemini-3.1-flash-live-preview via the Live API with response_modalities=[TEXT], the connection immediately fails with a 1011 Internal error encountered WebSocket close frame.
Using response_modalities=[AUDIO] with the same model and API key works without issues. The workaround is to use AUDIO modality with output_audio_transcription to obtain text responses, but this is suboptimal for text-only use cases.
Steps to reproduce
import asyncio
from google import genai
from google.genai import types
client = genai.Client(api_key="YOUR_API_KEY")
async def main():
# This FAILS with 1011
config_text = types.LiveConnectConfig(
response_modalities=[types.Modality.TEXT],
)
async with client.aio.live.connect(
model="gemini-3.1-flash-live-preview", config=config_text
) as session:
await session.send_realtime_input(text="Hello")
async for msg in session.receive():
print(msg.text)
asyncio.run(main())Error
websockets.exceptions.ConnectionClosedError: received 1011 (internal error) Internal error encountered.
google.genai.errors.APIError: 1011 None. Internal error encountered.
Working comparison (AUDIO modality)
# This WORKS
config_audio = types.LiveConnectConfig(
response_modalities=[types.Modality.AUDIO],
speech_config=types.SpeechConfig(
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Puck")
)
),
output_audio_transcription=types.AudioTranscriptionConfig(),
)
async with client.aio.live.connect(
model="gemini-3.1-flash-live-preview", config=config_audio
) as session:
# Connected successfully, receives audio + transcription
...Additional notes
- Tested with both
v1alphaandv1betaAPI versions — same result - Tested with raw WebSocket (bypassing the SDK) — same result
- Tested with ephemeral tokens +
BidiGenerateContentConstrained— same result - The model is listed in
client.models.list()and is the only model supportingbidiGenerateContent - Regular (non-Live) API calls work fine with the same API key
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.