Skip to Content
🚀 Orga AI is in open beta.
DocumentationServer SdksNodeArchitecture

Architecture

The Orga Node SDK (@orga‑ai/node) operates as the secure backend layer in the Orga AI ecosystem.
It sits between your client applications and the Orga Cloud API, exchanging permanent API keys for short‑lived credentials used in real‑time sessions.

Understanding these layers helps you design scalable, secure integrations.


Layers at a Glance


Division of Responsibilities

LayerResponsibility
Client SDKsRequest ephemeral tokens and ICE configurations from your proxy endpoint (never directly from Orga).
Node SDKUses your API key to securely fetch credentials from Orga’s API, then returns { ephemeralToken, iceServers } to clients.
Orga Cloud APIIssues and validates short‑lived tokens for secure, authenticated WebRTC sessions.

How It Works

When a client requests credentials from your backend:

  1. Your backend route calls orga.getSessionConfig().
  2. The Node SDK internally handles both Orga API calls (for token + ICE).
  3. It responds to the client with a consolidated SessionConfig object.
  4. The client uses this data to start its WebRTC connection with Orga Cloud.

đź”’ Security Principle:
The Orga API key is never shared with clients. Only temporary tokens are sent over the wire.


SDK Class Responsibilities

OrgaAI Class

The core class of the SDK encapsulates all operations needed for secure server‑side communication.

ResponsibilityMethod
Request ephemeral tokenfetchEphemeralToken() (internal)
Request ICE configurationfetchIceServers() (internal)
Return full config objectgetSessionConfig() (public, preferred)
Logging & Debug Outputdebug: true flag in constructor

Key Concepts

  • Ephemeral tokens — short‑lived JWTs issued using your API key; they expire quickly and are safe to distribute to clients.
  • ICE configuration — STUN/TURN servers provided by Orga to establish peer connections through NAT/firewalls.
  • Timeouts — All requests are automatically timed out (default 10s) for stability.
  • Debug logs — Enable debug: true to print request flow information in development.

Example Data Flow

Frontend (React / RN) ↓ /api/orga-client-secrets Backend (Node SDK) ↓ POST /v1/realtime/client-secrets ↓ GET /v1/realtime/ice-config Orga Cloud ↑ { ephemeralToken, iceServers } Backend ↑ returns SessionConfig to client Frontend ↑ starts WebRTC session

Design Principles

GoalImplementation
SecurityAPI key usage restricted to trusted backend.
SimplicityOne function, getSessionConfig(), hides all internal HTTP calls.
ExtensibilityWill support Python, Go, and other languages in future releases.

Environment Requirements

RequirementNotes
Node.js ≥18Required for native fetch and AbortController.
ESM or CommonJSBoth supported.
Network AccessMust allow outbound HTTPS to https://api.orga-ai.com.
Environment VarsORGA_API_KEY, USER_EMAIL (temporary requirement).

Example Integration Overview

import express from "express"; import { OrgaAI } from "@orga-ai/node"; const router = express.Router(); const orga = new OrgaAI({ apiKey: process.env.ORGA_API_KEY!, userEmail: process.env.USER_EMAIL!, // will be optional soon debug: false, }); router.get("/api/orga-client-secrets", async (_req, res) => { try { const data = await orga.getSessionConfig(); res.json(data); } catch (err) { console.error("Orga error:", err); res.status(500).json({ error: "Internal server error" }); } }); export default router;

Next Steps

Last updated on