Skip to main content

Setting up a Relay Server

Connecting directly to tensorstudio through SDK on browser exposes your api-key. If you are running your own relay server, e.g. with the Realtime Console, you can instead connect to the relay server URL.

1. Install Realtime Console

First, install the OpenAI Realtime Console globally:

2. Set environment variables for realtime-console

Create a .env file in realtime-console directory

3. Start the Relay Server

Run relay server in a new terminal:
The relay server will start running on ws://localhost:8081 .

Start using Tensorstudio Speech API through NodeJS SDK

Install NodeJS SDK

Using Node.js SDK

Production Deployment

For production:
  1. Use secure WebSocket (WSS) with SSL/TLS
  2. Update the relay server URL to your production domain
  3. Add authentication if needed
  4. Use environment variables for configuration
Example production configuration:

Security Considerations

  • Never expose your OpenAI API key in client-side code
  • Use HTTPS/WSS in production
  • Implement rate limiting
  • Add authentication to your relay server
  • Monitor server usage and implement proper error handling

Common Issues

  1. Connection Refused: Make sure the relay server is running
  2. SSL/TLS Errors: Check certificate configuration for WSS
  3. Authentication Errors: Verify API key in .env file