More

AI and User-Generated Rivet Actors

This guide shows you how to programmatically create sandboxed Rivet environments and deploy custom actor code to them.

Use Cases

Deploying AI and user-generated Rivet Actors to sandboxed namespaces is useful for:

  • AI-generated code deployments: Deploy code generated by LLMs in sandboxed environments
  • User sandbox environments: Give users their own sandboxed Rivet namespace to experiment
  • Preview deployments: Create ephemeral environments for testing pull requests
  • Multi-tenant applications: Isolate each customer in their own sandboxed namespace

Rivet Actors For AI-Generated Backends

Traditional architectures require AI agents to coordinate across multiple disconnected systems: a database schemas, API logic, and synchronizing schemas & APIs.

With Rivet Actors, state and logic live together in a single actor definition. This consolidation means:

  • Less LLM context required: No need to understand multiple systems or keep them in sync
  • Fewer errors: State and behavior can’t drift apart when they’re defined together
  • More powerful generation: AI agents can focus on business logic instead of infrastructure plumbing

How It Works

The deployment process involves four key steps:

  1. Create sandboxed Rivet namespace: Programmatically create a sandboxed Rivet namespace using the Cloud API or self-hosted Rivet API
  2. Generate tokens: Create the necessary tokens for authentication:
    • Runner token: Authenticates the serverless runner to execute actors
    • Publishable token: Used by frontend clients to connect to actors
    • Access token: Provides API access for configuring the namespace
  3. Deploy AI or user-generated code: Deploy the actor code and frontend programmatically to your serverless platform of choice (such as Vercel, Netlify, AWS Lambda, or any other provider). We’ll be using Freestyle for this example since it’s built for this use case.
  4. Connect Rivet to your deployed code: Configure Rivet to run actors on your deployment in your sandboxed namespace

Setup