-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
content:editRequest for content editsRequest for content editsdocumentationDocumentation editsDocumentation editsproduct:ai-gatewayAI Gateway: https://developers.cloudflare.com/ai-gateway/AI Gateway: https://developers.cloudflare.com/ai-gateway/
Description
Existing documentation URL(s)
What changes are you suggesting?
hi cloudflare team,
I'm trying to use the realtime api of google. All the code you provided are working, but i need to send an user content to google, but there is no response. so please give more code, so that I can figure out what to do.
here is my code.
import WebSocket from "ws";
import delay from "delay";
async function main(){
const ws = new WebSocket("wss://gateway.ai.cloudflare.com/....", ['cf-aig-authorization.<token>']);
let opened=false;
ws.on("open", () => {
console.log("Connected to server.");
opened=true;
});
ws.on("message", (message:any) => {
const {type, data}=message;
console.log('message:', message.toString());
});
await delay(1000*1);
while(true){
console.log('check opened');
if(opened){
break;
}
await delay(1000*1);
}
ws.send(
JSON.stringify({
setup: {
model: "models/gemini-2.0-flash-exp",
generationConfig: { responseModalities: ["TEXT"] },
},
}),
);
await delay(1000*5);
console.log('sending msg');
ws.send(JSON.stringify({
clientContent:{
turns:[
{
role:'user',
parts:['hello'],
}
],
turn_complete:true,
}
}));
console.log('sent msg');
await delay(1000*10);
}
main()
Additional information
No response
Metadata
Metadata
Assignees
Labels
content:editRequest for content editsRequest for content editsdocumentationDocumentation editsDocumentation editsproduct:ai-gatewayAI Gateway: https://developers.cloudflare.com/ai-gateway/AI Gateway: https://developers.cloudflare.com/ai-gateway/