agents icon indicating copy to clipboard operation
agents copied to clipboard

Gemini Realtime Proactivity not working, missing http_options

Open florent-martineau opened this issue 1 year ago • 2 comments

Hello,

I'm using the gemini-2.5-flash-preview-native-audio-dialog model like this:

google.beta.realtime.RealtimeModel(
                        model="models/gemini-2.5-flash-preview-native-audio-dialog",
                        proactivity=True,
)

I get the following error:

websockets.exceptions.ConnectionClosedError: received 1007 (invalid frame payload data) Invalid JSON payload received. Unknown name "proactivity" at 'setup': Cannot find field.; then sent 1007 (invalid frame payload data) Invalid JSON payload received. Unknown name "proactivity" at 'setup': Cannot find field.

If I remove proactivity=True, it works well.

Looking at the Live API docs here, it seems that the genai client should have the http_options option set up like this:

client = genai.Client(api_key="GOOGLE_API_KEY", http_options={"api_version": "v1alpha"})

There is currently no way (that I know of) to add this http_options with the current plugin.

I made a test and edited the plugins/google/beta/realtime/realtime_api.py like this and it worked:

        self._client = genai.Client(
            api_key=self._opts.api_key,
            vertexai=self._opts.vertexai,
            project=self._opts.project,
            location=self._opts.location,
            http_options={"api_version": "v1alpha"},
        )

Let me know if I can be of any help

florent-martineau avatar Jun 04 '25 09:06 florent-martineau

Chiming in on this. Looking at the client creation code, wouldn’t it be better for the model to accept a client object during initialization, much like how session objects are passed to other models?

ChenghaoMou avatar Jun 05 '25 08:06 ChenghaoMou

@ChenghaoMou we definitely can.. for now I've fixed the root cause of having to set api_version, this is simpler for users in any case.

davidzhao avatar Jun 06 '25 05:06 davidzhao