API Documentation

WebSocket relay endpoints, section-to-.gh file routing, and full slider payload reference for Grasshopper/Swiftlet integration.

Grasshopper / Swiftlet Connection

Connect Grasshopper (or Swiftlet) to the same WebSocket URL as the browser. Declare yourself as a Grasshopper client by sending a handshake as your first message. The relay will then stream live slider payloads directly to your session.

Step 1 — Connect via WebSocket

wss://base44.app/functions/rhinoWsRelay

Step 2 — Send Grasshopper Handshake (first message)

{
  "role": "grasshopper"
}

After this, the relay registers you as a Grasshopper client and will stream every browser slider update to you in real time.

Step 3 — You will receive slider payloads like this

{
  "procedure": "grasshopper/rd",
  "request_id": "req_001",
  "section": "RideDynamics",
  "inputs": {
    "reach": 450,
    "rear_sag": 25,
    "front_sag": 25
  }
}

Step 4 — Send computed result back over the same WebSocket

{
  "type": "geometry",
  "request_id": "req_001",
  "lines": [
    [
      [
        0,
        0,
        0
      ],
      [
        100,
        0,
        0
      ]
    ]
  ],
  "points": [
    [
      0,
      0,
      0
    ]
  ],
  "text": [
    {
      "text": "label",
      "position": [
        0,
        0,
        0
      ]
    }
  ],
  "vectors": [],
  "metadata": {
    "body_angle_hip": 95.4,
    "bar_drop": 32
  }
}

The relay broadcasts this to all connected browser clients — the frontend renders lines and points automatically.

Alternative — HTTP POST result back (no WS required for Grasshopper)

POSThttps://base44.app/functions/rhinoWsRelay

POST the geometry JSON (same shape as Step 4) to this HTTP endpoint. The relay will push it to all connected browser clients.

Connection Architecture

Now (local): Frontend → rhinoWsRelay (Base44 backend function) → ngrok tunnel → your local Rhino.Compute. Set RHINO_COMPUTE_URL to your ngrok URL in Settings → Environment Variables.

AWS (future): rhinoWsRelay → AWS ALB → EC2 pool. Each user session can be pinned to an instance (sticky sessions) or a session token issued per-connection. Tier-based instance sizing: Yes — AWS supports this via separate Auto Scaling Groups per tier (free/pro/rd) with different EC2 instance types (t3.medium for free, c6i.xlarge for R&D). The relay routes based on user.plan read from the auth token.

Token & Compute Billing (planned)

Rhino.Compute: $0.10/core-hour. Track uptime per WebSocket session (connect→disconnect = minutes used). Tokens map 1:1 to compute-minutes budgeted per billing period. Monthly subscribers get N tokens/month, annual subscribers get 12× upfront. Overages either throttle (drop to lower tier instance) or prompt payment.

Session tracking: the relay function should emit a heartbeat every 60s and write to a ComputeSession entity. An automation runs every 5 minutes to sum active sessions per user and deduct from their token balance.