Arjun
08/29/2025, 12:22 PMAI Evy
08/29/2025, 12:22 PMAI Evy
08/29/2025, 12:22 PMAI Evy
08/29/2025, 12:22 PMhtml
<script src="<https://cdn.jsdelivr.net/gh/reecesel/retell-client-js-sdk@main/dist/retell-bundle-2.0.4.min.js>"></script>
However, you'll need a backend server to handle authentication, as you cannot expose your API key directly on the frontend . The frontend needs to make a request to your backend server to create the web call, which then returns the call information to start the WebSocket connection with Retell [(2) ]() .
For creating a chat session, you would use the Create Chat API [(3) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
The process requires both the JavaScript SDK for your frontend and a backend where the frontend can request a call, so the backend can send the call information to the frontend to start the WebSocket connection without needing an API key on the client side [(2) ]() .AI Evy
08/29/2025, 12:22 PMArjun
08/29/2025, 12:23 PMArjun
08/29/2025, 12:23 PMAI Evy
08/29/2025, 12:23 PMAI Evy
08/29/2025, 12:23 PMhtml
<script src="<https://cdn.jsdelivr.net/gh/reecesel/retell-client-js-sdk@main/dist/retell-bundle-2.0.4.min.js>"></script>
However, you'll still need a backend server to authenticate web calls, as you cannot expose your API key on the frontend . GitHub Pages only serves static files, so you'd need an external backend service to create the web call sessions.
For chat functionality, you would use the Create Chat Completion API:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const response = await client.chat.createChatCompletion({
chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
content: 'hi how are you doing?',
}) ;
console.log(response.messages) ;
[(2) ]()
The main limitation is that GitHub Pages cannot run server-side code for the required authentication step [(1) ]() .AI Evy
08/29/2025, 12:23 PMAI Evy
08/29/2025, 12:23 PM