# Request for OpenAI Team: Need Split Frontend and Backend Example for Real-Time API

**URL:** <https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596>\
**Category:** API\
**Created:** [December 16, 2024, 8:49am UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596 "2024-12-16T08:49:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas.K](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tomas.k/32/511709_2.png) [@Tomas.K](https://community.openai.com/u/Tomas.K)\
**Post date:** [December 16, 2024, 8:49am UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/1 "2024-12-16T08:49:53Z")

</div>

Dear OpenAI Team and community,

I’m reaching out to request your assistance in providing a working example of OpenAI Real-Time API with a split frontend and backend setup. The current documentation only includes a frontend solution, which poses a risk of exposing the API key. A comprehensive example demonstrating how to implement both frontend and backend components would be immensely helpful for developers looking to integrate your API without compromising security.

Thank you for your attention to this matter.

Best regards,

Tomas K  
Selendia AI

---

<div class="post-metadata">

**Author:** ![robertb](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/robertb/32/234200_2.png) [@robertb](https://community.openai.com/u/robertb)\
**Post date:** [December 16, 2024, 10:01am UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/2 "2024-12-16T10:01:11Z")

</div>

While not an official example, here is our Real-Time API front-end and back-end solution. We are leveraging the open-source Your Priorities platform and the Policy Synth AI library.

Our solution integrates a hybrid voice/text interface. We are using WebSockets to send audio to the client but plan to upgrade this functionality to WebRTC soon.

Back-end:

> <https://github.com/CitizensFoundation/your-priorities-app/blob/master/server_api/agents/assistants/voiceAssistant.ts>

Front-end:

> <https://github.com/CitizensFoundation/your-priorities-app/blob/master/webApps/client/src/yp-assistants/yp-assistant-base.ts>

One example of this code in action:

[![](https://us1.discourse-cdn.com/openai1/original/4X/8/2/f/82ff3737e94cf734338951779ecd111e292214aa.jpeg "Amplifier Demo: Competitor Analysis AI Agent in Action") ](https://www.youtube.com/watch?v=gZ5fkIC3Obw)

The AI agent library driving our solution:

> **[GitHub - CitizensFoundation/policy-synth: Policy Synth is a Typescript class library for...](https://github.com/CitizensFoundation/policy-synth)**
>
> Policy Synth is a Typescript class library for creating multi-scale AI agent logic flows, API's and state of the art realtime web applications. The drive behind the project is to help governments and citizens make better decisions together by seamlessly integrating collective and artificial intelligence.

---

<div class="post-metadata">

**Author:** ![Tomas.K](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tomas.k/32/511709_2.png) [@Tomas.K](https://community.openai.com/u/Tomas.K)\
**Post date:** [December 16, 2024, 1:14pm UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/3 "2024-12-16T13:14:15Z")

</div>

Hi @robertb , thank you for fast reply. Unfortunatelly you are running javascript code on frontend so its big security risk.

 ![image](https://us1.discourse-cdn.com/openai1/original/4X/1/c/1/1c1ac1fea7521c849a5a36781f54cd108b38e2b1.jpeg)

---

<div class="post-metadata">

**Author:** ![robertb](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/robertb/32/234200_2.png) [@robertb](https://community.openai.com/u/robertb)\
**Post date:** [December 16, 2024, 1:15pm UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/4 "2024-12-16T13:15:28Z")

</div>

The OpenAI API key is never exposed to the front-end and we use our own user/role system to control access. So pretty much exactly like in the quote above about secure usage of the API.

---

<div class="post-metadata">

**Author:** ![Tomas.K](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tomas.k/32/511709_2.png) [@Tomas.K](https://community.openai.com/u/Tomas.K)\
**Post date:** [December 16, 2024, 1:16pm UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/5 "2024-12-16T13:16:34Z")

</div>

We would like to see working example code of connection between backend and openai websocket for Real Time API.

---

<div class="post-metadata">

**Author:** ![Tomas.K](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tomas.k/32/511709_2.png) [@Tomas.K](https://community.openai.com/u/Tomas.K)\
**Post date:** [December 19, 2024, 11:57am UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/6 "2024-12-19T11:57:34Z")

</div>

Update: solved by update from Openai, rollout webRTC (Implementing an ephemeral API key). Thank you 🙏

---

<div class="post-metadata">

**Author:** ![Tomas.K](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tomas.k/32/511709_2.png) [@Tomas.K](https://community.openai.com/u/Tomas.K)\
**Post date:** [December 19, 2024, 12:10pm UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/7 "2024-12-19T12:10:45Z")

</div>

solution is also over node.js server.

---

<div class="post-metadata">

**Author:** ![VeitB](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/veitb/32/712987_2.png) [@VeitB](https://community.openai.com/u/VeitB)\
**Post date:** [December 21, 2024, 12:10pm UTC](https://community.openai.com/t/request-for-openai-team-need-split-frontend-and-backend-example-for-real-time-api/1057596/8 "2024-12-21T12:10:50Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
