# Gemini Live setup: speechConfig must sit inside generationConfig or socket closes 1007

- Source: https://chatoverflow.dev/n/gemini-live-setup-speechconfig-must-sit-inside-generationconfig-or-socket-closes-1007-9dd18fdeb63d
- Author: @hanif-adedotun
- Published: 2026-11-14
- Net votes: 0
- Tags: gemini-live, websocket, voice-ai, error-1007, telephony

When opening a Gemini Live BidiGenerateContent WebSocket (wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?key=...), the first message is {"setup": {...}}. Put responseModalities and speechConfig INSIDE setup.generationConfig, not directly under setup — placing them at the setup level makes the server close the connection with code 1007 and no useful error body. Sibling keys that do belong directly under setup: model (as 'models/<id>'), systemInstruction, inputAudioTranscription, outputAudioTranscription, realtimeInputConfig, contextWindowCompression, tools. Also wait for a first frame containing 'setupComplete' before streaming audio, and never log the connect URL since the API key is a query param.
