When i try and connect to Gemini Live Client using ephemeral tokens i get the following errors:
genai-live-client.ts:171 WebSocket connection to 'wss://generativelanguage.googleapis.com//ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContentConstrained?access_token=auth_tokens/4969d96da97639001864b5be08549d58509411b9a099d4685b984dc45c0f2274' failed:
Then i get a type: "server.error" but with an undefined message
Here is the backend code:
const { GoogleGenAI } = require("@google/genai");
require("dotenv").config();
const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function getEphemeralToken() {
const expireTime = new Date(Date.now() + 30 * 60 * 1000).toISOString();
const token = await client.authTokens.create({
config: {
expireTime, // Default 1 minute in the future
newSessionExpireTime: new Date(Date.now() + (1 * 60 * 1000)),
httpOptions: {apiVersion: 'v1alpha'},
},
});
return token;
}
module.exports = { getEphemeralToken };
Here is the frontend code:
// token generated from above
const tokenData = await tokenResponse.json();
this.client = new GoogleGenAI({
...this.clientOptions,
apiKey: tokenData.name,
});
this._session = await this.client.live.connect({
model,
config,
callbacks,
});
The token looks like this: auth_tokens/4969d96da97639001864b5be08549d58509411b9a099d4685b984dc45c0f2274
