Hello,
I’m using Delphi (Object Pascal), so I’m unable to use the official Google GenAI libraries.
I’m trying to connect to the Gemini Multimodal Live API via the following WebSocket URLs:
wss://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?key={my_key}
wss://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?key={my_key}
wss://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-001:streamGenerateContent?key={my_key}
However, the WebSocket handshake fails in both:
- My Delphi application, and
- Browser-based WebSocket testing tools (e.g., Chrome extensions).
The server rejects the connection during the handshake phase, and no session is established.
My Questions
- What is my mistake? (Could you please point out what I’m doing wrong?)
- Are these
streamGenerateContent
WebSocket endpoints intended to be used directly via raw WebSocket clients? - If so, are any additional headers or protocols required beyond the
api_key
query parameter? - Or is this functionality only available via the official Python SDK (
google-genai
) or other client libraries?
WebSocket Connection Details
URL: wss://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-001:streamGenerateContent?key={my_key}
Host: generativelanguage.googleapis.com
Path: /v1beta/models/gemini-2.0-flash-001:streamGenerateContent
SSL: Enabled
Port: 443
Log:
Attempting to connect to WebSocket...
Disconnected from Gemini API WebSocket
I would appreciate clarification on whether these endpoints are publicly available for custom WebSocket clients, or only accessible through official SDKs.
Thanks in advance!