Gemini 3.1 flash live preview API not working

Hello!

I was trying to build a nextjs web app that leverages the Gemini Live API, and was following this guide: https://ai.google.dev/gemini-api/docs/live-api/get-started-sdk

My application is unable to run as expected, and when I look at the behaviour, I see that I receive a 404 error response when I try to retrieve an ephemeral token.

When I try check what models are available for my API key using the “https://generativelanguage.googleapis.com/v1alpha/models?key=” endpoint, I do not see any live API available for my key.

What would I need to do to get access to the Live API?

Thank you!

Hello! Stumbled upon the same problem, just wanted to check if you found the fix?

Hi!

Yes, I managed to figure it out.

Previously, I was simply using an API key for my application that I had generated on AI Studio.

Based on what I found online, I saw that my API key that I use may need to be linked to a valid Google Cloud project.

So, I went and created a new Google Cloud project. In that project, I enabled the “Gemini API”.

Then, in the Google AI Studio, I imported my Google Cloud project, and generated an API key linked to that imported project.

Using that API key worked for me. I also enabled billing for the project, as I saw that could be a reason for the ephemeral token not working (I had tried doing this first for just my API key without the Google Cloud project, but that alone did not work).

You can try adding in the Google Cloud project without enabling billing (if that is possible), and see if that works too!

One thing to note:

My old API key, which did not work, started with “AQ.”.

My new API key, which works, does not have that prefix.

Hope this helps :slight_smile: