Skip to Content
🚀 Orga AI is in open beta.

Node SDK architecture

@orga-ai/node acts as the secure middle tier between your frontend and Orga Cloud. It owns the only copy of your permanent API key, turns that into short-lived credentials, and responds to client requests with everything they need to start WebRTC sessions.

Layers

ComponentResponsibility
Client SDKsAsk your route for { ephemeralToken, iceServers }.
Node SDKHolds API key, calls Orga Cloud, returns consolidated SessionConfig.
Orga CloudIssues tokens and TURN/STUN credentials, validates usage.

Request lifecycle

  1. Client request – React/React Native calls your proxy route (typically /api/orga-client-secrets).
  2. Token exchange – Node SDK posts your API key to Orga; receives an ephemeral token that expires in minutes.
  3. ICE fetch – With that token, the SDK immediately fetches TURN/STUN servers so the client doesn’t have to make extra calls.
  4. Response – The SDK packages everything into a SessionConfig object. The client uses it to call /v1/realtime/calls.

Inside the OrgaAI class

MethodVisibilityPurpose
constructor(config)publicStores API key, timeout, base URL, and debug flag.
getSessionConfig()publicPrimary API: orchestrates token + ICE fetches and returns { ephemeralToken, iceServers }.
fetchEphemeralToken()internalMakes the POST request to /v1/realtime/client-secrets.
fetchIceServers()internalMakes the GET request to /v1/realtime/ice-config using the ephemeral token.

Because it’s a tiny surface area, you can reuse a single instance across requests (e.g., module-level singleton in Express) and avoid re-reading env vars every time.

Deployment considerations

  • Rate limiting / auth – Layer your own authentication or quota controls before calling getSessionConfig(); the SDK focuses solely on Orga communication.
  • Timeouts – Default is 10s. Increase it for high-latency regions or wrap calls in your own retry logic.
  • Observability – Enable debug: true in non-production environments to log the credential exchange; in prod, log request IDs + conversation_id but never tokens.
  • Edge vs serverful – Works in Node 18+ and edge runtimes that support fetch. On very tight memory footprints, instantiate the OrgaAI client lazily to avoid state leakage.
Last updated on