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.
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.