Lambda connection to realtime api

Hi there, does anybody has a example of how to integrate the realtime api with a lambda in aws?

Regards.

Welcome to the dev community @micuentadecasa

What are you trying to do on a Lambda function with realtime API?

Hi @sps , I have to develop a lambda that receives an audio via a websocket, let’s say from a streamlit app (but it should be generic), and retransmit this audio to the realtime api, and return the audio from the realtime api to the streamlit app (or other source like a react app), having into account the stateless nature of the lambdas, of course. The idea is to do a generic wrapper for the realtime that can be used in any app.

Given the intricacies of managing web-sockets and the fact that Lambda functions have a maximum lifespan of 15 minutes and are billed based on GB seconds per instance, if I were to implement a real-time API, I would opt for a webRTC implementation. I would then use the function to generate an ephemeral API token to initiate a peer-to-peer connection between the client and OpenAI. Since there is no intermediary involved, the delays are minimal.

Here’s how you can create an ephemeral API token.

hi @sps , thanks for the info, I think it is a good idea, do you have some source code repository with code to see how can I implement it? by the way I´m using Azure OpenAI realtime API, not OpenAI API.