Skip to content

Gemini Live API WebSocket Error 1008: "Operation is not implemented, or supported, or enabled" #1236

Description

@Adhishtanaka

WebSocket connection to Gemini Live API closes unexpectedly with error code 1008 and reason: "Operation is not implemented, or supported, or enabled."

Environment

Component Version/Value
SDK @google/genai (latest)
Model models/gemini-2.5-flash-native-audio-preview-12-2025
Platform Browser (Chrome/Edge) via Next.js 16.x
Connection Type Direct WebSocket (Live API)
Audio Input 16-bit PCM, 16kHz, mono, little-endian
Audio Output 16-bit PCM, 24kHz, mono, little-endian

Error Details

Console Output

direct-gemini-client.ts:244 🔌 Gemini connection closed (code: 1008, reason: Operation is not implemented, or supported, or enabled.)

Steps to Reproduce

  1. Initialize GoogleGenAI client with valid API key
  2. Connect to Live API with audio modality:
import { GoogleGenAI, LiveConnectConfig, Modality } from "@google/genai";

const client = new GoogleGenAI({ apiKey: "VALID_API_KEY" });

const config: LiveConnectConfig = {
  responseModalities: [Modality.AUDIO],
  speechConfig: {
    voiceConfig: {
      prebuiltVoiceConfig: {
        voiceName: "Aoede"
      }
    }
  },
  systemInstruction: {
    parts: [{ text: "You are a helpful assistant." }]
  },
  // Generation config fields set directly (not nested)
  temperature: 0.7,
  topP: 0.9,
  topK: 40,
  // Realtime input config
  realtimeInputConfig: {
    automaticActivityDetection: {
      disabled: true
    }
  }
};

await client.live.connect({
  model: "models/gemini-2.5-flash-native-audio-preview-12-2025",
  config,
  callbacks: {
    onopen: () => console.log("Connected"),
    onclose: (event) => console.log(`Closed: ${event.code} - ${event.reason}`),
    onerror: (error) => console.error("Error:", error),
    onmessage: (message) => console.log("Message:", message)
  }
});
  1. Start sending audio chunks (16-bit PCM, 16kHz):
session.sendRealtimeInput({
  media: {
    mimeType: "audio/pcm;rate=16000",
    data: base64AudioChunk // 20-40ms chunks as recommended
  }
});
  1. Connection closes with error 1008 after a few seconds or during first audio response

Expected Behavior

  • WebSocket connection should remain stable
  • Audio input should be processed
  • Audio response should be received completely
  • Connection should only close on explicit disconnect or timeout

Actual Behavior

  • Connection establishes successfully (onopen fires)
  • First audio response may start streaming
  • Connection abruptly closes with code 1008
  • Error message: "Operation is not implemented, or supported, or enabled."

Deprecation Warning Observed

Before the error, this deprecation warning appears:

Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).

Note: Even after fixing the deprecated config (moving generationConfig fields to top-level), the 1008 error still occurs.


Configuration Attempts

Attempt 1: Original (with deprecated nested config)

// ❌ Deprecated - causes warning
const config = {
  responseModalities: [Modality.AUDIO],
  generationConfig: {
    temperature: 0.7,
    topP: 0.9,
    topK: 40
  }
};

Attempt 2: Fixed (fields at top level)

// ✅ Correct per deprecation notice - still causes 1008
const config = {
  responseModalities: [Modality.AUDIO],
  temperature: 0.7,
  topP: 0.9,
  topK: 40
};

Attempt 3: With realtimeInputConfig

// Tried disabling automatic activity detection - still causes 1008
const config = {
  responseModalities: [Modality.AUDIO],
  temperature: 0.7,
  realtimeInputConfig: {
    automaticActivityDetection: {
      disabled: true
    }
  }
};

Audio Streaming Details

Following Google's best practices for streaming:

Setting Value Best Practice
Chunk Size 20-40ms ✅ Recommended
Sample Rate (Input) 16kHz ✅ Required
Sample Rate (Output) 24kHz ✅ Expected
Bit Depth 16-bit PCM ✅ Required
Channels Mono ✅ Required
Endianness Little-endian ✅ Required

Workarounds Attempted

  • Moved generationConfig to top-level fields
  • Added realtimeInputConfig.automaticActivityDetection.disabled: true
  • Reduced audio chunk size to 20-40ms
  • Validated audio format (16-bit PCM, 16kHz, little-endian)
  • Added connection timeout handling
  • Implemented reconnection logic
  • None resolved the 1008 error

Request

Please provide:

  1. Root cause of the 1008 error
  2. Correct configuration for stable Live API WebSocket connections
  3. Any model-specific requirements for audio streaming
  4. Updated documentation if the API behavior has changed

Additional Context

This issue occurs in a real-time voice interview application where:

  • User speaks → Audio captured at 16kHz
  • Audio sent to Gemini Live API in small chunks (20-40ms)
  • AI responds with audio at 24kHz
  • Response played back to user

The application works correctly for initial connection but fails intermittently with 1008 errors, making it impossible to complete a full voice conversation.

Metadata

Metadata

Assignees

Labels

api: livestreamIssues related to the Live Stream API API.priority: p2Moderately-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions