top of page

Contact

We're always looking for new and exciting opportunities. Let's connect.

800-406-7711

coming soon 55412.gif
bottom of page
// npm install ws import WebSocket from 'ws'; const ws = new WebSocket('wss://api.x.ai/v1/realtime?agent_id=agent_ouzQwLpxYkee1q8O', { headers: { Authorization: `Bearer ${process.env.XAI_API_KEY}` }, }); ws.on('open', () => { ws.send(JSON.stringify({ type: 'conversation.item.create', item: { type: 'message', role: 'user', content: [{ type: 'input_text', text: 'Hello!' }] }, })); ws.send(JSON.stringify({ type: 'response.create' })); }); ws.on('message', raw => { const event = JSON.parse(raw.toString()); if (event.type === 'response.output_audio_transcript.delta') { process.stdout.write(event.delta); } else if (event.type === 'response.output_audio.delta') { const pcm = Buffer.from(event.delta, 'base64'); // decode and play } });