Introduction

Ever wanted to embed an interactive AI playground on your website so users can try out your model or app in real-time? The Sandbox AI Protocol (SAIP) makes this possible. SAIP powers Trialrun.dev, a platform that provides sandboxed, embeddable AI playgrounds. It enables developers to deploy AI apps in isolated containers and seamlessly embed them as widgets on any site, offering users a low-latency, safe trial run of the AI. Inspired by the handshake approach of WebRTC (where peers use a central server to find each other, then communicate directly (Signaling and video calling - Web APIs | MDN)), SAIP ensures that once the connection is set up, interactions are fast and direct between the user’s browser and the AI sandbox. This litepaper gives an accessible, product-focused overview of how SAIP works and why it matters for developers, users, and open-source contributors.

What is SAIP? In simple terms, SAIP is a protocol and system architecture for running AI apps in secure sandboxes and embedding them as interactive widgets on websites. Each sandbox is a Docker-powered container running an AI application (such as a Model Context Protocol server) in isolation. A central service coordinates all sandboxes and clients: it tracks sandbox configurations and acts as a broker for initial handshakes. Once handshakes are done, the user’s widget talks directly to the sandbox container’s API, eliminating middleman latency. The result: users get a responsive experience, and developers get peace of mind that their AI backend is contained and secure. In the sections below, we’ll dive into how SAIP works, its system architecture, a step-by-step example flow, and the future vision for this approach.

How It Works

At a high level, SAIP uses a handshake protocol between three parties: (1) the sandbox container that runs the AI app, (2) the central SAIP API (with its database), and (3) the embedded widget running in the user’s browser. The process is reminiscent of how WebRTC establishes peer-to-peer connections via a signaling server (Signaling and video calling - Web APIs | MDN). In SAIP’s case, the central API plays a role similar to a WebRTC signaling server – it doesn’t carry the ongoing data, but helps the two ends find each other and exchange configuration details for a secure connection.

Here’s the basic handshake sequence that makes the magic happen:

image.png

(image) Figure: In the SAIP handshake, the Sandbox Container and the Embedded Widget each communicate with the Central API briefly. The container registers itself (1), and the widget requests the config (2). The central server then provides the widget with the sandbox’s details (3). Finally, the widget and container talk directly via the sandbox’s API (4), enabling real-time interaction.

This handshake process ensures that every sandboxed AI environment is preconfigured and secure before any user interacts with it. The central API acts as a gatekeeper: it only hands out configuration for a valid sandbox ID to authorized widgets, and it only accepts a container handshake if it has a matching pending sandbox ID. Because the actual AI computations happen inside an isolated Docker container, the user can play with the AI model freely without affecting the host website or any other system. For developers, this means you can let users experiment with your AI model (e.g. an NLP tool, a generative art model, or an agent following the Model Context Protocol) in a sandbox that’s fenced off from your production data. For users, it means a safe, sandboxed trial of an AI app with snappy performance.

System Architecture

Let’s break down the key components of the Sandbox AI Protocol architecture and how they work together: